/* ============================================================
   XemTiếpPhim — CSS frontend
   Port nguyên hệ thống thiết kế từ mockup đã duyệt
   (mockup-giao-di-n-xemtiepphim) + bổ sung cho player thật,
   phân trang và các trạng thái riêng của bản PHP.
   ============================================================ */
:root{
  --bg:#0a0a0c;
  --bg-2:#121215;
  --surface:#1a1a1e;
  --surface-2:#232328;
  --line:#2c2c31;
  --text:#f5f5f4;
  --muted:#a8a29e;
  --faint:#78716c;
  --red:#e50914;
  --red-dark:#b00610;
  --shopee:#ee4d2d;
  --shopee-dark:#d63f21;
  --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:"Be Vietnam Pro",system-ui,-apple-system,"Segoe UI",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{ font-size:21px; font-weight:900; letter-spacing:-.02em; white-space:nowrap; }
.logo b{ color:var(--red); font-weight:900; }
.logo span{ color:var(--text); }
.logo small{ display:block; font-size:10px; font-weight:500; color:var(--faint); letter-spacing:.04em; margin-top:-3px; }
.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; }
body.has-sticky-bar{ padding-bottom:76px; }
@media (min-width:769px){ body.has-sticky-bar{ padding-bottom:0; } }

/* ---------- 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; }
.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:128px; 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:168px; 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:2/3; 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-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; }

/* ---------- Affiliate box ---------- */
.aff-box{
  background:var(--bg-2); border:1px solid var(--line); border-radius:14px; padding:16px;
}
.aff-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px; }
.aff-title{ font-size:16.5px; font-weight:800; display:flex; align-items:center; gap:8px; }
.aff-title .dot{ width:8px; height:8px; border-radius:50%; background:var(--shopee); flex:none; }
.aff-note{ font-size:11.5px; color:var(--faint); font-weight:600; border:1px solid var(--line); padding:2px 8px; border-radius:999px; white-space:nowrap; }
.aff-grid{ display:grid; gap:12px; }
@media (min-width:769px){ .aff-grid{ grid-template-columns:repeat(3,1fr); } }
.prod{
  display:flex; gap:12px; background:var(--surface); border:1px solid var(--line);
  border-radius:12px; padding:10px; align-items:stretch;
}
@media (min-width:769px){ .prod{ flex-direction:column; } }
.prod-img{ width:86px; height:86px; flex:none; border-radius:8px; object-fit:cover; background:#fff; }
@media (min-width:769px){ .prod-img{ width:100%; height:auto; aspect-ratio:1/1; } }
.prod-info{ flex:1; min-width:0; display:flex; flex-direction:column; }
.prod-scene{ font-size:11px; font-weight:700; color:var(--shopee); letter-spacing:.02em; }
.prod-name{ font-size:13.5px; font-weight:600; line-height:1.4; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.prod-price{ margin-top:5px; display:flex; align-items:baseline; gap:8px; flex-wrap:wrap; }
.prod-price b{ color:var(--shopee); font-size:16.5px; font-weight:800; }
.prod-price s{ color:var(--faint); font-size:12.5px; }
.prod-off{ background:var(--shopee); color:#fff; font-size:11px; font-weight:800; padding:1px 6px; border-radius:4px; }
.prod-btns{ display:flex; gap:7px; margin-top:9px; }
.buy-btn{
  flex:1; text-align:center; font-size:12.5px; font-weight:700; padding:8px 6px; border-radius:7px;
  display:inline-flex; align-items:center; justify-content:center; gap:5px; transition:filter .15s ease;
}
.buy-btn:hover{ filter:brightness(1.12); }
.buy-shopee{ background:var(--shopee); color:#fff; }
.buy-tiktok{ background:#fff; color:#111; }

/* affiliate strip giữa nội dung */
.aff-strip{
  margin-top:30px; display:flex; gap:14px; align-items:center;
  background:var(--bg-2); border:1px dashed #44403c; border-radius:14px; padding:14px 16px;
}
.aff-strip img{ width:64px; height:64px; border-radius:9px; object-fit:cover; background:#fff; flex:none; }
.aff-strip .grow{ flex:1; min-width:0; }
.aff-strip h3{ font-size:15px; font-weight:800; }
.aff-strip p{ font-size:13px; color:var(--muted); }
.aff-strip .buy-btn{ flex:none; padding:10px 16px; font-size:13.5px; }
@media (max-width:560px){ .aff-strip{ flex-wrap:wrap; } .aff-strip .buy-btn{ flex:1; } }

/* ---------- 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; }
.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{ width:112px; flex:none; border-radius:10px; overflow:hidden; box-shadow:0 10px 30px rgba(0,0,0,.55); aspect-ratio:2/3; background:var(--surface); }
.detail-poster img{ width:100%; height:100%; object-fit:cover; }
@media (min-width:769px){ .detail-poster{ width:168px; } .detail-main{ margin-top:-96px; } }
.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; }
.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 var(--line);
}
.player-facade{ position:absolute; inset:0; cursor:pointer; }
.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-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;
}
.watch-bar{ display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin-top: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:13.5px; padding:8px 14px; 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:9px 15px; font-size:13.5px; }
.btn[aria-disabled="true"]{ opacity:.4; cursor:not-allowed; }
.watch-section{ margin-top:26px; }

/* ---------- 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(5,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; }

/* ---------- Sticky bottom bar (mobile, trang xem phim) ---------- */
.sticky-bar{
  position:fixed; left:0; right:0; bottom:0; z-index:70; display:none;
  background:rgba(14,14,17,.97); border-top:1px solid var(--line);
  padding:9px 12px calc(9px + env(safe-area-inset-bottom)); gap:11px; align-items:center;
}
body.has-sticky-bar .sticky-bar{ display:flex; }
@media (min-width:769px){ body.has-sticky-bar .sticky-bar{ display:none; } }
.sticky-bar img{ width:44px; height:44px; border-radius:8px; object-fit:cover; background:#fff; flex:none; }
.sticky-info{ flex:1; min-width:0; }
.sticky-info .n{ font-size:12px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; }
.sticky-info .p{ font-size:14px; font-weight:800; color:var(--shopee); display:block; }
.sticky-info .p s{ color:var(--faint); font-size:11.5px; font-weight:500; margin-left:5px; }
.sticky-cta{
  flex:none; background:var(--shopee); color:#fff; font-weight:800; font-size:13.5px;
  padding:11px 15px; border-radius:9px;
}
.sticky-cta:active{ background:var(--shopee-dark); }

/* ---------- 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; }
}
