/* ============================================================
   WatchAIFilms — CSS frontend
   Ports the approved mockup design system
   (mockup-giao-di-n-xemtiepphim) + additions for the real player,
   pagination and PHP-specific states.
   ============================================================ */
:root{
  --bg:#0a0a0c;
  --bg-2:#121215;
  --surface:#1a1a1e;
  --surface-2:#232328;
  --line:#2c2c31;
  --text:#f5f5f4;
  --muted:#a8a29e;
  --faint:#78716c;
  --red:#e50914;
  --red-dark:#b00610;
  --gold:#f5c518;
  --green:#46d369;
  --radius:10px;
  --header-h:60px;
}
html{ box-sizing:border-box; }
*,*::before,*::after{ box-sizing:inherit; }
body{
  margin:0; background:var(--bg); color:var(--text);
  font-family:"Inter",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  font-size:15px; line-height:1.55;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4,p,ul,ol,figure{ margin:0; padding:0; }
ul{ list-style:none; }
button{ font:inherit; color:inherit; background:none; border:0; cursor:pointer; }
input{ font:inherit; }
img{ display:block; max-width:100%; }
a{ color:inherit; text-decoration:none; }
::selection{ background:var(--red); color:#fff; }

/* ---------- Header ---------- */
.site-header{
  position:sticky; top:0; z-index:60;
  background:rgba(10,10,12,.92); backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);
}
.header-in{
  max-width:1280px; margin:0 auto; height:var(--header-h);
  display:flex; align-items:center; gap:14px; padding:0 16px;
}
.logo{ white-space:nowrap; line-height:0; }
.logo img{ height:34px; width:auto; display:block; }
footer .logo img{ height:30px; }
.main-nav{ display:none; gap:4px; margin-left:8px; align-items:center; }
.main-nav > a, .main-nav .nav-drop-btn{
  padding:8px 12px; border-radius:8px; font-weight:600; font-size:14px; color:var(--muted);
  display:inline-block;
}
.main-nav > a:hover, .main-nav > a.on, .main-nav .nav-drop-btn:hover{ color:var(--text); background:var(--surface); }
.nav-drop{ position:relative; }
.nav-drop-menu{
  display:none; position:absolute; top:calc(100% + 6px); left:0; min-width:210px;
  background:var(--bg-2); border:1px solid var(--line); border-radius:12px; padding:8px;
  box-shadow:0 18px 44px rgba(0,0,0,.55); z-index:70;
}
.nav-drop:hover .nav-drop-menu, .nav-drop:focus-within .nav-drop-menu{ display:block; }
.nav-drop-menu a{
  display:block; padding:8px 11px; border-radius:8px; font-size:13.5px; font-weight:600; color:var(--muted);
}
.nav-drop-menu a:hover{ color:var(--text); background:var(--surface); }
.search-box{
  margin-left:auto; display:flex; align-items:center; gap:8px;
  background:var(--surface); border:1px solid var(--line); border-radius:999px;
  padding:7px 12px; flex:0 1 340px; min-width:0;
}
.search-box svg{ flex:none; }
.search-box input{
  background:none; border:0; outline:0; color:var(--text); width:100%; min-width:0; font-size:14px;
}
.search-box input::placeholder{ color:var(--faint); }
@media (min-width:860px){ .main-nav{ display:flex; } }

/* ---------- Layout ---------- */
.wrap{ max-width:1280px; margin:0 auto; padding:0 16px; }

/* ---------- Hero ---------- */
.hero{ position:relative; margin:0 -16px; }
.hero-media{ position:relative; height:min(68vw,560px); overflow:hidden; }
.hero-media img{ width:100%; height:100%; object-fit:cover; }
.hero-shade{ position:absolute; inset:0; box-shadow:inset 0 -140px 90px -30px var(--bg), inset 0 60px 60px -30px rgba(0,0,0,.55), inset 90px 0 90px -40px rgba(0,0,0,.65); }
.hero-body{
  position:relative; margin-top:-108px; padding:0 16px 8px; max-width:640px;
}
.hero-flag{
  display:inline-flex; align-items:center; gap:6px; background:var(--red); color:#fff;
  font-size:11px; font-weight:800; letter-spacing:.06em; padding:4px 9px; border-radius:5px; text-transform:uppercase;
}
.hero-title{ font-size:clamp(26px,5.4vw,44px); font-weight:900; line-height:1.12; letter-spacing:-.01em; margin:10px 0 8px; text-shadow:0 2px 18px rgba(0,0,0,.6); }
.hero-meta{ display:flex; flex-wrap:wrap; gap:6px 12px; align-items:center; color:#e7e5e4; font-size:13.5px; font-weight:500; }
.hero-desc{ color:#d6d3d1; margin-top:10px; font-size:14.5px; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.hero-actions{ display:flex; gap:10px; margin-top:16px; flex-wrap:wrap; }
/* Hero slider: several hot films stacked, auto-advancing, with arrows + dots. */
.hero-slider{ height:min(74vw,600px); overflow:hidden; }
.hero-slide{
  position:absolute; inset:0; opacity:0; visibility:hidden;
  transition:opacity .55s ease, visibility 0s linear .55s;
}
.hero-slide.active{ opacity:1; visibility:visible; z-index:1; transition:opacity .55s ease; }
.hero-slide .hero-media{ position:absolute; inset:0; height:auto; }
.hero-slide .hero-body{ position:absolute; left:0; right:0; bottom:0; margin:0; padding:0 16px 48px; z-index:2; }
.hero-arrow{
  position:absolute; top:50%; transform:translateY(-50%); z-index:3;
  width:40px; height:56px; border-radius:9px; color:#fff;
  background:rgba(12,12,15,.55); border:1px solid rgba(255,255,255,.18);
  display:flex; align-items:center; justify-content:center; backdrop-filter:blur(3px);
}
.hero-arrow:hover{ background:rgba(12,12,15,.88); }
.hero-arrow.prev{ left:10px; }
.hero-arrow.next{ right:10px; }
.hero-dots{ position:absolute; left:0; right:0; bottom:16px; z-index:3; display:flex; gap:7px; justify-content:center; }
.hero-dot{ width:22px; height:4px; border-radius:99px; background:rgba(255,255,255,.35); padding:0; }
.hero-dot.on{ background:var(--red); }
@media (max-width:560px){
  .hero-arrow{ display:none; }
  .hero-slide .hero-body{ padding-bottom:42px; }
  .hero-slide .hero-title{ font-size:23px; }
  .hero-slide .hero-desc{ display:none; }
}
.btn{
  display:inline-flex; align-items:center; gap:8px; font-weight:700; font-size:15px;
  padding:11px 20px; border-radius:8px; transition:background .15s ease, transform .15s ease;
}
.btn:active{ transform:scale(.97); }
.btn-play{ background:#fff; color:#111; }
.btn-play:hover{ background:#e7e5e4; }
.btn-ghost{ background:rgba(255,255,255,.16); color:#fff; backdrop-filter:blur(4px); }
.btn-ghost:hover{ background:rgba(255,255,255,.26); }
.btn-red{ background:var(--red); color:#fff; }
.btn-red:hover{ background:var(--red-dark); }
.btn-dark{ background:var(--surface); border:1px solid var(--line); color:var(--text); }
.btn-dark:hover{ background:var(--surface-2); }
.match{ color:var(--green); font-weight:800; }
.badge-age{ border:1px solid var(--faint); padding:0 6px; border-radius:4px; font-size:12px; color:#e7e5e4; }
.star{ color:var(--gold); font-weight:800; }

/* ---------- Rows / carousels ---------- */
.row-block{ margin-top:30px; }
.row-head{ display:flex; align-items:baseline; justify-content:space-between; gap:12px; margin-bottom:12px; }
.row-title{ font-size:19px; font-weight:800; letter-spacing:-.01em; }
.row-more{ font-size:13px; font-weight:600; color:var(--muted); white-space:nowrap; }
.row-more:hover{ color:var(--text); }
.rail-wrap{ position:relative; }
.rail{
  display:grid; grid-auto-flow:column; grid-auto-columns:240px; gap:10px;
  overflow-x:auto; scroll-snap-type:x mandatory; padding-bottom:6px;
  scrollbar-width:none; margin:0 -16px; padding-left:16px; padding-right:16px;
}
.rail::-webkit-scrollbar{ display:none; }
.rail-btn{
  display:none; position:absolute; top:38%; z-index:5; width:38px; height:56px;
  background:rgba(20,20,23,.88); border:1px solid var(--line); border-radius:8px;
  align-items:center; justify-content:center;
}
.rail-btn:hover{ background:var(--surface-2); }
.rail-btn.prev{ left:-6px; } .rail-btn.next{ right:-6px; }
@media (min-width:769px){
  .rail{ grid-auto-columns:280px; gap:12px; }
  .rail-btn{ display:flex; }
}
.card{ scroll-snap-align:start; cursor:pointer; text-align:left; width:100%; display:block; }
.card-poster{ position:relative; border-radius:var(--radius); overflow:hidden; aspect-ratio:16/9; background:var(--surface); display:block; }
.card-poster img{ width:100%; height:100%; object-fit:cover; transition:transform .25s ease; }
.card:hover .card-poster img{ transform:scale(1.05); }
.poster-fallback{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  font-size:52px; font-weight:900; color:var(--faint); background:var(--surface-2);
}
.card-ep{
  position:absolute; left:7px; bottom:7px; background:rgba(0,0,0,.78); color:#fff;
  font-size:11px; font-weight:700; padding:2px 7px; border-radius:5px;
}
.card-watch{
  position:absolute; right:7px; bottom:7px; z-index:2; width:27px; height:27px;
  border-radius:50%; background:var(--red); color:#fff; font-size:11px;
  display:flex; align-items:center; justify-content:center; padding-left:2px;
  box-shadow:0 4px 12px rgba(0,0,0,.45);
}
.card-rate{
  position:absolute; top:7px; right:7px; background:rgba(0,0,0,.78); color:var(--gold);
  font-size:11px; font-weight:800; padding:2px 7px; border-radius:5px;
}
.card-rank{
  position:absolute; top:0; left:0; background:var(--red); color:#fff;
  font-size:12px; font-weight:900; padding:3px 9px; border-bottom-right-radius:9px; z-index:2;
}
.card-name{ font-size:13.5px; font-weight:600; line-height:1.35; margin-top:8px; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.card-sub{ font-size:12px; color:var(--faint); margin-top:2px; display:block; }

/* ---------- Ad slots ---------- */
.ad-slot{ margin:20px auto; text-align:center; max-width:100%; overflow:hidden; min-height:0; }
.ad-slot:empty{ display:none; }
.ad-slot ins, .ad-slot iframe, .ad-slot img{ max-width:100%; }

/* ---------- Detail page ---------- */
.detail-hero{ position:relative; margin:0 -16px; }
.detail-media{ height:min(52vw,480px); overflow:hidden; position:relative; }
.detail-media img{ width:100%; height:100%; object-fit:cover; }
/* Large cover: show the FULL original image (uncropped) over its own blurred background. */
.detail-media .media-bg{
  position:absolute; inset:0; object-fit:cover;
  filter:blur(18px) brightness(.55); transform:scale(1.25);
}
.detail-media .media-fg{ position:relative; object-fit:contain; }
.detail-shade{ position:absolute; inset:0; box-shadow:inset 0 -110px 80px -20px var(--bg), inset 0 40px 50px -20px rgba(0,0,0,.5); }
.detail-main{ position:relative; margin-top:-72px; display:flex; gap:18px; align-items:flex-end; padding:0 16px; }
.detail-poster{ position:relative; width:min(300px,74vw); flex:none; border-radius:10px; overflow:hidden; box-shadow:0 10px 30px rgba(0,0,0,.55); aspect-ratio:16/9; background:var(--surface); }
.detail-poster img{ width:100%; height:100%; object-fit:cover; }
/* Detail-page poster: 16:9 rectangle, shows the FULL original image uncropped —
   the extra space on the sides is filled by the same image, blurred. */
.detail-poster .dp-bg{
  position:absolute; inset:0; object-fit:cover;
  filter:blur(14px) brightness(.55); transform:scale(1.2);
}
.detail-poster .dp-fg{ position:relative; object-fit:contain; }
.detail-poster-link{ display:block; position:relative; height:100%; }
.detail-play{
  position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
  width:46px; height:46px; border-radius:50%; background:rgba(229,9,20,.94); color:#fff;
  display:flex; align-items:center; justify-content:center; font-size:17px; padding-left:3px;
  box-shadow:0 8px 22px rgba(0,0,0,.5); pointer-events:none;
}
@media (min-width:769px){ .detail-poster{ width:340px; } .detail-main{ margin-top:-96px; } }
@media (max-width:640px){
  .detail-main{ flex-direction:column; align-items:stretch; gap:12px; margin-top:-46px; }
  .detail-poster{ width:100%; max-width:440px; }
}
.detail-info h1{ font-size:clamp(22px,4.6vw,36px); font-weight:900; line-height:1.15; }
.detail-info .hero-meta{ margin-top:8px; }
.detail-info .original-title{ color:var(--faint); font-size:14px; margin-top:4px; font-weight:500; }
.detail-cols{ display:grid; gap:26px; margin-top:24px; }
@media (min-width:960px){ .detail-cols{ grid-template-columns:1fr 340px; } }
.section-title{ font-size:17.5px; font-weight:800; margin-bottom:10px; display:flex; align-items:center; gap:9px; }
.section-title::before{ content:""; width:4px; height:19px; border-radius:2px; background:var(--red); flex:none; }
.desc-text{ color:#d6d3d1; font-size:14.5px; }
.facts{ background:var(--bg-2); border:1px solid var(--line); border-radius:12px; padding:14px 16px; }
.facts dl{ display:grid; grid-template-columns:104px 1fr; row-gap:9px; font-size:13.5px; }
.facts dt{ color:var(--faint); font-weight:600; }
.facts dd{ margin:0; font-weight:600; }
.facts dd a:hover{ color:var(--red); }
.genre-chips{ display:flex; flex-wrap:wrap; gap:7px; }
.chip{
  font-size:12.5px; font-weight:600; padding:5px 11px; border-radius:999px;
  background:var(--surface); border:1px solid var(--line); color:#e7e5e4;
  display:inline-block;
}
a.chip:hover, button.chip:hover{ border-color:var(--faint); }
.chip.on{ background:var(--red); border-color:var(--red); color:#fff; }

/* episode grid */
.ep-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(52px,1fr)); gap:8px; }
.ep-btn{
  background:var(--surface); border:1px solid var(--line); border-radius:8px;
  padding:9px 0; font-weight:700; font-size:13.5px; text-align:center; display:block;
}
.ep-btn:hover{ border-color:var(--faint); }
.ep-btn.on{ background:var(--red); border-color:var(--red); color:#fff; }
.ep-range{ display:flex; gap:7px; flex-wrap:wrap; margin-bottom:12px; }

/* ---------- Watch page ---------- */
.watch-head{ padding-top:14px; }
.crumb{ font-size:12.5px; color:var(--faint); font-weight:600; }
.crumb a{ color:var(--muted); font-weight:600; }
.crumb a:hover{ color:var(--text); }
.watch-title{ font-size:20px; font-weight:800; margin-top:4px; }
.watch-title span{ color:var(--red); }
.player-wrap{
  position:relative; margin-top:12px; border-radius:12px; overflow:hidden;
  background:#000; aspect-ratio:16/9; border:1px solid #34343c;
  box-shadow:0 16px 44px rgba(0,0,0,.45);
}
.player-facade{
  position:absolute; inset:0; cursor:pointer;
  background:radial-gradient(120% 120% at 50% 0%, #23232e 0%, #101016 55%, #08080c 100%);
}
/* Vertical video (Reel/Shorts/TikTok): tall 9:16 frame, centered, never stretched wide. */
.player-wrap.is-vertical{
  aspect-ratio:9/16; max-width:480px; margin-left:auto; margin-right:auto;
}
.player-facade .player-thumb{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; opacity:.85; }
.player-facade::after{ content:""; position:absolute; inset:0; background:rgba(0,0,0,.28); }
.player-facade .player-play{
  position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); z-index:2;
  width:68px; height:68px; border-radius:50%; background:rgba(229,9,20,.94); color:#fff;
  display:flex; align-items:center; justify-content:center; font-size:24px; padding-left:4px;
  box-shadow:0 12px 34px rgba(0,0,0,.5);
}
.player-facade:hover .player-play{ background:var(--red); }
.player-facade .player-play{ animation:playPulse 2.2s ease-out infinite; }
@keyframes playPulse{
  0%{ box-shadow:0 12px 34px rgba(0,0,0,.5), 0 0 0 0 rgba(229,9,20,.45); }
  70%{ box-shadow:0 12px 34px rgba(0,0,0,.5), 0 0 0 18px rgba(229,9,20,0); }
  100%{ box-shadow:0 12px 34px rgba(0,0,0,.5), 0 0 0 0 rgba(229,9,20,0); }
}
.player-facade .player-caption{
  position:absolute; left:0; right:0; bottom:0; z-index:2;
  padding:30px 14px 11px; font-size:13.5px; font-weight:700; color:#fff;
  background:linear-gradient(transparent, rgba(0,0,0,.75));
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; pointer-events:none;
}
.player-wrap > iframe, .player-wrap > video{
  position:absolute; inset:0; width:100%; height:100%; border:0; background:#000;
}
.player-empty{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  color:var(--muted); font-size:14.5px; padding:20px; text-align:center;
}
/* Pre-roll ad: full-page overlay, but the ad frame shrinks to fit
   the real creative size (banner 300x250, 728x90, 300x600, video...)
   and scales down on narrow screens so nothing is cropped. */
.preroll{
  position:fixed; inset:0; z-index:9999; background:rgba(4,4,8,.96);
  display:flex; align-items:center; justify-content:center; padding:20px;
  overflow-y:auto;
}
.preroll[hidden]{ display:none; }
body.preroll-open{ overflow:hidden; }
.preroll-box{
  width:-webkit-fit-content; width:fit-content;
  max-width:min(970px, 94vw);
  text-align:center; margin:auto;
}
.preroll-tag{
  display:inline-block; font-size:11px; font-weight:800; letter-spacing:.08em;
  color:#fbbf24; border:1px solid rgba(251,191,36,.5); border-radius:999px; padding:2px 10px;
}
.preroll-ad{
  margin:16px auto 18px; padding:10px; overflow:hidden;
  display:flex; align-items:flex-start; justify-content:center;
  background:#0b0b10; border:1px solid var(--line); border-radius:12px;
}
.preroll-ad img, .preroll-ad video{ max-width:100%; height:auto; display:block; }
.preroll-ad iframe{ max-width:100%; display:block; border:0; }
.preroll-close{
  background:var(--red); color:#fff; border:0; border-radius:999px; cursor:pointer;
  font-size:16px; font-weight:700; padding:14px 34px; min-height:48px;
}
.preroll-close:disabled{ background:#3f3f46; color:#d4d4d8; cursor:not-allowed; }
.preroll-note{ color:var(--muted); font-size:13.5px; margin-top:14px; line-height:1.5; }
@media (max-width:640px){
  .preroll{ padding:12px; }
  .preroll-box{ max-width:94vw; }
  .preroll-ad{ padding:6px; margin:12px auto 14px; }
  .preroll-close{ width:100%; max-width:360px; }
}
/* Promise line under the home slider: the difference from YouTube. */
.home-promise{
  text-align:center; color:var(--muted); font-size:13.5px; line-height:1.6;
  margin:2px 8px 4px;
}
.home-promise b{ color:var(--text); }
.watch-bar{
  display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin-top:14px;
  background:var(--bg-2); border:1px solid var(--line); border-radius:12px; padding:12px 14px;
}
.srv-group{ display:flex; align-items:center; gap:7px; flex-wrap:wrap; }
.srv-label{ font-size:13px; font-weight:700; color:var(--muted); }
.srv-btn{
  background:var(--surface); border:1px solid var(--line); border-radius:8px;
  font-weight:700; font-size:14px; padding:10px 16px; display:inline-block;
}
.srv-btn.on{ background:var(--red); border-color:var(--red); color:#fff; }
.nav-ep{ margin-left:auto; display:flex; gap:8px; }
.nav-ep .btn{ padding:11px 18px; font-size:14px; }
.btn[aria-disabled="true"]{ opacity:.4; cursor:not-allowed; }
.watch-tips{
  flex-basis:100%; font-size:12.5px; color:var(--faint);
  border-top:1px dashed var(--line); padding-top:9px;
}
/* Watch-page blocks are separate panels, distinct from the page background. */
.watch-section{
  margin-top:20px; background:var(--bg-2); border:1px solid var(--line);
  border-radius:14px; padding:18px;
}
.watch-section.plain{ background:none; border:0; border-radius:0; padding:0; }

/* ---------- Browse page ---------- */
.browse-head{ padding-top:20px; }
.browse-head h1{ font-size:23px; font-weight:900; }
.browse-head p{ color:var(--muted); font-size:13.5px; margin-top:3px; }
.filter-block{ margin-top:16px; }
.filter-label{ font-size:12.5px; font-weight:700; color:var(--faint); margin-bottom:8px; }
.grid-results{ display:grid; grid-template-columns:repeat(2,1fr); gap:16px 12px; margin-top:20px; }
@media (min-width:600px){ .grid-results{ grid-template-columns:repeat(3,1fr); } }
@media (min-width:960px){ .grid-results{ grid-template-columns:repeat(4,1fr); gap:20px 14px; } }
.empty{ text-align:center; color:var(--muted); padding:52px 16px; font-size:14.5px; }
.empty b{ color:var(--text); display:block; font-size:17px; margin-bottom:5px; }
.pagination{ display:flex; gap:8px; justify-content:center; margin-top:30px; flex-wrap:wrap; }
.pagination a, .pagination .page-current{
  padding:8px 14px; border:1px solid var(--line); border-radius:8px;
  background:var(--surface); font-weight:700; font-size:13.5px;
}
.pagination a:hover{ border-color:var(--faint); }
.pagination .page-current{ background:var(--red); border-color:var(--red); color:#fff; }

/* ---------- Footer ---------- */
footer{ margin-top:56px; border-top:1px solid var(--line); background:var(--bg-2); }
.foot-in{ max-width:1280px; margin:0 auto; padding:26px 16px 34px; }
.foot-nav{ display:flex; flex-wrap:wrap; gap:8px 20px; margin:12px 0 14px; font-size:13.5px; font-weight:600; }
.foot-nav a{ color:var(--muted); font-weight:600; }
.foot-nav a:hover{ color:var(--text); }
.foot-note{ font-size:12.5px; color:var(--faint); max-width:720px; margin-top:8px; }

/* ---------- 404 ---------- */
.not-found{ text-align:center; padding:64px 16px; }
.not-found h1{ font-size:24px; font-weight:900; }
.not-found p{ color:var(--muted); margin:8px 0 20px; }

@media (prefers-reduced-motion:reduce){
  .card-poster img{ transition:none; }
  .player-facade .player-play{ animation:none; }
  .hero-slide{ transition:none; }
}
