/* === AVMovieX UX v14 — คงช่องค้นหาหน้าแรก + ปรับทั้งไซต์ === */
:root {
  --avx-bg: #0a0a0e;
  --avx-surface: #121018;
  --avx-line: rgba(168, 85, 247, 0.22);
  --avx-accent: #8b5cf6;
  --avx-text: #f5f3ff;
  --avx-muted: rgba(237, 233, 254, 0.62);
}

html { scroll-behavior: smooth; }
body {
  -webkit-font-smoothing: antialiased;
  background: var(--avx-bg);
  color: var(--avx-text);
}

/* focus */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(167, 139, 250, 0.85) !important;
  outline-offset: 2px !important;
}

/* Header / Nav */
header {
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 10, 14, 0.86) !important;
}
header a {
  min-height: 40px;
  display: inline-flex !important;
  align-items: center;
  padding-left: 0.7rem !important;
  padding-right: 0.7rem !important;
}

@media (max-width: 767px) {
  header {
    min-height: auto !important;
  }
  /* เมนูมือถือ: แถวเดียวเลื่อน ไม่ตัดบรรทัด */
  header nav,
  header .flex.items-center.gap-1,
  header .flex.items-center.gap-2 {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    scrollbar-width: none;
  }
  header nav::-webkit-scrollbar { display: none; }
  header a {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.8125rem !important;
  }
}

/* คงช่องค้นหาหน้าแรก — แตะเฉพาะ contrast เล็กน้อย ไม่เปลี่ยนโครง */
form[role="search"] input::placeholder {
  color: rgba(196, 181, 253, 0.45) !important;
}

/* Category pills หน้าแรก: มือถือเลื่อนแนวนอน */
@media (max-width: 640px) {
  section:has(a[href^="/genre/"]) ul,
  div:has(> a[href^="/genre/"]) {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.5rem !important;
    justify-content: flex-start !important;
    padding-bottom: 0.4rem;
  }
  a[href^="/genre/"],
  a[href="/genres"] {
    flex: 0 0 auto;
    min-height: 36px;
    display: inline-flex !important;
    align-items: center;
  }
}

/* Cards */
a[href^="/watch/"] {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: 0.85rem !important;
  overflow: hidden;
  background: var(--avx-surface) !important;
  border: 1px solid rgba(168, 85, 247, 0.14) !important;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
a[href^="/watch/"]:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(139, 92, 246, 0.28);
  border-color: rgba(139, 92, 246, 0.4) !important;
}
a[href^="/watch/"] .line-clamp-2,
a[href^="/watch/"] [class*="line-clamp"] {
  min-height: 2.6em;
  line-height: 1.35 !important;
  font-size: 0.8125rem !important;
  color: rgba(255, 255, 255, 0.92) !important;
}
a[href^="/watch/"] .text-\[11px\],
a[href^="/watch/"] [class*="text-purple-400"] {
  color: rgba(196, 181, 253, 0.62) !important;
  font-variant-numeric: tabular-nums;
}

/* quality badges */
.avx-qbadges {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  pointer-events: none;
}
.avx-qbadge {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.4rem;
  border-radius: 0.3rem;
  background: rgba(0, 0, 0, 0.72);
  color: #f5f3ff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.avx-qbadge.k4 { color: #fde68a; border-color: rgba(251, 191, 36, 0.35); }
.avx-qbadge.hdtv { color: #c4b5fd; border-color: rgba(167, 139, 250, 0.35); }
.avx-qbadge.uncen { color: #fca5a5; border-color: rgba(248, 113, 113, 0.35); }

/* empty preview video must not cover poster */
a[href^="/watch/"] video:not([src]),
a[href^="/watch/"] video[src=""] {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  z-index: 0 !important;
}
a[href^="/watch/"] video[src]:not([src=""]) {
  display: block !important;
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  z-index: 6 !important;
  pointer-events: none;
}
a[href^="/watch/"] img,
a[href^="/watch/"] picture img {
  position: relative !important;
  z-index: 1 !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Genres page */
.avx-genres-wrap ul,
ul:has(> li > a[href^="/genre/"]) {
  justify-content: flex-start !important;
  max-width: 72rem;
  margin-inline: auto;
}
.avx-genres-filter {
  max-width: 28rem;
  margin: 0 auto 1.25rem;
  width: 100%;
}
.avx-genres-filter input {
  width: 100%;
  min-height: 44px;
  border-radius: 0.6rem;
  border: 1px solid var(--avx-line);
  background: var(--avx-surface);
  color: #fff;
  padding: 0.65rem 0.9rem;
}

/* Watch page extras */
.avx-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  margin-top: 0.65rem;
  font-size: 0.8125rem;
  color: rgba(196, 181, 253, 0.78);
}
.avx-meta-row a { color: #ddd6fe; text-decoration: none; }
.avx-meta-row a:hover { text-decoration: underline; color: #fff; }
.avx-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 34px;
  padding: 0.25rem 0.7rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(168, 85, 247, 0.3);
  background: rgba(139, 92, 246, 0.12);
  color: #e9d5ff;
  font-size: 0.75rem;
  cursor: pointer;
}
.avx-copy-btn:hover { background: rgba(139, 92, 246, 0.22); }
.avx-player-wrap { position: relative; }
.avx-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.28);
  cursor: pointer;
  z-index: 3;
  border: 0;
}
.avx-play-overlay[hidden] { display: none !important; }
.avx-play-overlay span {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 16px 0 16px 28px;
  border-color: transparent transparent transparent rgba(255, 255, 255, 0.95);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
  margin-left: 6px;
}
.avx-rate {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: rgba(196, 181, 253, 0.75);
}
.avx-rate select {
  background: #15121e;
  color: #fff;
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 0.4rem;
  min-height: 32px;
  padding: 0.2rem 0.45rem;
}
.avx-related { margin-top: 2rem; }
.avx-related h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
  color: #fff;
}

/* Continue watching strip */
.avx-continue {
  max-width: 80rem;
  margin: 0 auto 1.25rem;
  padding: 0 1rem;
}
.avx-continue-inner {
  border: 1px solid rgba(168, 85, 247, 0.22);
  background: rgba(139, 92, 246, 0.08);
  border-radius: 0.75rem;
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
}
.avx-continue a {
  color: #ede9fe;
  text-decoration: none;
  font-weight: 600;
}
.avx-continue a:hover { text-decoration: underline; }
.avx-continue .meta { color: rgba(196, 181, 253, 0.7); font-size: 0.8rem; }

/* Search extras */
.avx-recent, .avx-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: -0.5rem 0 1rem;
}
.avx-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(168, 85, 247, 0.28);
  background: rgba(139, 92, 246, 0.1);
  color: #e9d5ff;
  font-size: 0.78rem;
  text-decoration: none;
  cursor: pointer;
}
.avx-chip:hover { background: rgba(139, 92, 246, 0.2); }
.avx-empty {
  border: 1px dashed rgba(168, 85, 247, 0.28);
  border-radius: 0.75rem;
  padding: 1.25rem;
  color: rgba(237, 233, 254, 0.7);
  font-size: 0.9rem;
}
.avx-suggest-box {
  position: relative;
  width: 100%;
}
.avx-suggest-list {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #15121e;
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 0.6rem;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
.avx-suggest-list a {
  display: block;
  padding: 0.65rem 0.85rem;
  color: #efeaff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
}
.avx-suggest-list a:hover { background: rgba(139, 92, 246, 0.15); }

/* Footer */
footer {
  display: block !important;
  margin-top: 3.5rem !important;
  padding: 2.25rem 1rem 2.75rem !important;
  border-top: 1px solid rgba(139, 92, 246, 0.2) !important;
  background: linear-gradient(180deg, rgba(18, 16, 24, 0.4), rgba(18, 16, 24, 0.95)) !important;
  color: rgba(237, 233, 254, 0.78) !important;
}
footer a { color: rgba(196, 181, 253, 0.92) !important; }
footer a:hover { color: #fff !important; }
footer p { color: rgba(237, 233, 254, 0.55) !important; text-align: center; }

/* Watch tags */
a[href^="/genre/"][class*="rounded-full"] {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
}

@media (hover: none) and (pointer: coarse) {
  a[href^="/watch/"] { -webkit-tap-highlight-color: rgba(139, 92, 246, 0.18); }
  a[href^="/watch/"]:active { transform: scale(0.985); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  a[href^="/watch/"]:hover { transform: none; }
}


/* --- รหัสหนังให้ชัดบนหน้าปกติ --- */
.avx-cover-code {
  z-index: 10 !important;
  background: rgba(0, 0, 0, 0.78) !important;
  color: #f3e8ff !important;
  -webkit-text-fill-color: #f3e8ff !important;
  border: 1px solid rgba(196, 181, 253, 0.35);
  text-shadow: none !important;
  letter-spacing: 0.04em;
}
.avx-card-code {
  color: #e9d5ff !important;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}
a[href^="/watch/"] .avx-qbadges {
  z-index: 10;
}

/* โลโก้แบบ 1 */
header a[aria-label="AVMovieX"] {
  display: inline-flex !important;
  align-items: center !important;
  padding-left: 0.25rem !important;
  padding-right: 0.4rem !important;
  min-height: 40px;
  max-width: 200px;
}
header img.avx-logo,
header a[aria-label="AVMovieX"] img {
  display: block !important;
  height: 32px !important;
  width: auto !important;
  max-width: 168px !important;
  object-fit: contain !important;
  object-position: left center !important;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,.35));
}
@media (min-width: 640px) {
  header img.avx-logo,
  header a[aria-label="AVMovieX"] img {
    height: 36px !important;
    max-width: 196px !important;
  }
}
@media (max-width: 480px) {
  header img.avx-logo,
  header a[aria-label="AVMovieX"] img {
    height: 28px !important;
    max-width: 128px !important;
  }
}

