/* =====================================================
   FILMVIP — Site theme (สีทั้งหมดคุมด้วย CSS vars จากแอดมิน)
   ===================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', 'Noto Sans Thai', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* ---------- Navbar ---------- */
.navbar {
    position: sticky; top: 0; z-index: 900;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid color-mix(in srgb, var(--surface2) 70%, transparent);
}
.nav-inner { display: flex; align-items: center; gap: 22px; height: 64px; }
.nav-brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 900; letter-spacing: .5px; color: var(--primary); white-space: nowrap; }
.nav-brand img { height: 36px; width: auto; }
.nav-menu { display: flex; gap: 4px; align-items: center; }
.nav-menu > a, .nav-menu > .nav-drop > span {
    padding: 8px 14px; border-radius: var(--radius); font-size: 15px; font-weight: 600;
    color: var(--muted); transition: .18s; white-space: nowrap; cursor: pointer;
}
.nav-menu > a:hover, .nav-menu > a.active { color: var(--text); background: var(--surface2); }
.nav-drop { position: relative; }
.nav-drop-menu {
    position: absolute; top: calc(100% + 8px); left: 0; min-width: 230px; max-height: 420px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--surface2); border-radius: var(--radius);
    padding: 8px; display: none; box-shadow: 0 16px 40px rgba(0,0,0,.55);
}
.nav-drop:hover .nav-drop-menu, .nav-drop.open .nav-drop-menu { display: block; }
.nav-drop-menu a { display: block; padding: 8px 12px; border-radius: 8px; font-size: 14px; color: var(--muted); }
.nav-drop-menu a:hover { background: var(--surface2); color: var(--text); }

.nav-search { flex: 1; max-width: 420px; margin-left: auto; position: relative; }
.nav-search input {
    width: 100%; background: var(--surface); border: 1px solid var(--surface2); color: var(--text);
    padding: 10px 16px 10px 42px; border-radius: 999px; font-size: 14px; outline: none; transition: .2s;
}
.nav-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.nav-search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; }
.nav-search .suggest {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--surface);
    border: 1px solid var(--surface2); border-radius: var(--radius); overflow: hidden; display: none;
    box-shadow: 0 16px 40px rgba(0,0,0,.55); z-index: 50;
}
.nav-search .suggest a { display: flex; gap: 12px; padding: 10px 12px; align-items: center; }
.nav-search .suggest a:hover { background: var(--surface2); }
.nav-search .suggest img { width: 38px; height: 56px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.nav-search .suggest .t { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-user { display: flex; align-items: center; gap: 10px; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--primary); color: #fff; border: none; border-radius: 999px;
    padding: 10px 20px; font-size: 14px; font-weight: 700; transition: .2s;
}
.btn:hover { background: var(--primary2); transform: translateY(-1px); }
.btn.ghost { background: var(--surface2); color: var(--text); }
.btn.ghost:hover { background: var(--surface); }

.nav-burger { display: none; background: var(--surface); border: 1px solid var(--surface2); color: var(--text); width: 44px; height: 40px; border-radius: 10px; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 0; flex-shrink: 0; }
.nav-burger span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .25s ease, opacity .2s ease; }
.nav-burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-burger.open span:nth-child(2) { opacity: 0; }
.nav-burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ฉากหลังมืดของเมนูมือถือ */
.nav-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 880;
    opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.nav-backdrop.show { opacity: 1; pointer-events: auto; }
@media (min-width: 821px) { .nav-backdrop { display: none; } }
body.nav-locked { overflow: hidden; }

/* ---------- Announcement bar ---------- */
.announce {
    background: linear-gradient(90deg, var(--primary), var(--primary2));
    color: #fff; text-align: center; font-size: 14px; padding: 9px 44px; position: relative;
}
.announce button { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; color: #fff; font-size: 17px; }

/* ---------- Hero slider ---------- */
.hero { position: relative; border-radius: calc(var(--radius) + 6px); overflow: hidden; margin: 22px 0; min-height: 380px; background: var(--surface); }
.hero-slide { position: absolute; inset: 0; opacity: 0; transition: opacity .7s ease; pointer-events: none; }
.hero-slide.on { opacity: 1; pointer-events: auto; }
.hero-slide .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.38); }
.hero-info {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 34px 34px 30px;
    background: linear-gradient(transparent, rgba(0,0,0,.88));
    display: flex; align-items: flex-end; gap: 22px; flex-wrap: wrap;
}
.hero-info img.poster { width: 120px; border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.6); }
.hero-text { flex: 1; min-width: 240px; }
.hero-text h2 { font-size: 26px; margin-bottom: 6px; text-shadow: 0 2px 8px rgba(0,0,0,.7); }
.hero-text p { color: #cfcfd8; font-size: 14px; max-width: 640px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hero-meta { display: flex; gap: 10px; margin: 10px 0 14px; flex-wrap: wrap; }
.hero-dots { position: absolute; top: 16px; right: 18px; display: flex; gap: 7px; z-index: 5; }
.hero-dots button { width: 10px; height: 10px; border-radius: 50%; border: none; background: rgba(255,255,255,.4); }
.hero-dots button.on { background: var(--primary); transform: scale(1.25); }

.badge {
    display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 800;
    background: rgba(255,255,255,.15); color: #fff; backdrop-filter: blur(3px);
}
.badge.imdb { background: rgba(0,0,0,.7); color: var(--accent); }
.badge.year { background: rgba(255,255,255,.14); }
.badge.audio { background: color-mix(in srgb, var(--primary) 85%, #000); }

/* ---------- Section title ---------- */
.section-title {
    display: flex; align-items: center; gap: 12px; margin: 34px 0 18px; font-size: 20px; font-weight: 800;
}
.section-title::before { content: ''; width: 5px; height: 22px; background: var(--primary); border-radius: 3px; display: inline-block; }
.section-title .more { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: 600; }
.section-title .more:hover { color: var(--primary); }

/* ---------- Movie grid + cards ---------- */
/* PC = 6 การ์ดต่อแถว (36 ต่อหน้า), แท็บเล็ต 4, มือถือ 3/2 */
.movie-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 18px; }
@media (max-width: 1200px) { .movie-grid { grid-template-columns: repeat(4, 1fr); } }
.movie-card {
    background: var(--surface); border-radius: var(--radius); overflow: hidden; position: relative;
    transition: transform .25s ease, box-shadow .25s ease; display: block;
}
.movie-card:hover { transform: translateY(-6px); box-shadow: 0 14px 30px rgba(0,0,0,.5), 0 0 0 2px color-mix(in srgb, var(--primary) 55%, transparent); z-index: 5; }
.movie-card .poster-wrap { position: relative; aspect-ratio: 2/3; overflow: hidden; background: var(--surface2); }
.movie-card .poster-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.movie-card:hover .poster-wrap img { transform: scale(1.06); }
.movie-card .overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: .25s;
}
.movie-card:hover .overlay { opacity: 1; }
.movie-card .overlay svg { width: 52px; height: 52px; fill: var(--primary); filter: drop-shadow(0 4px 10px rgba(0,0,0,.6)); }
.movie-card .info { padding: 11px 12px; }
.movie-card .title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; }
.movie-card .meta { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.movie-card .imdb-badge { position: absolute; top: 9px; right: 9px; background: rgba(0,0,0,.72); color: var(--accent); padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 800; z-index: 4; }
.movie-card .ep-badge {
    position: absolute; bottom: 9px; right: 9px; padding: 3px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 800; z-index: 4;
    color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.ep-badge.ep-end { background: var(--primary); }
.ep-badge.ep-ongoing { background: #2563eb; }
.movie-card .new-flag {
    position: absolute; top: 9px; left: 9px; background: var(--success); color: #04220f;
    padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 900; z-index: 4; letter-spacing: .4px;
}
.movie-card .type-flag {
    position: absolute; bottom: 9px; left: 9px; background: rgba(0,0,0,.72); padding: 2px 8px; border-radius: 6px;
    font-size: 11px; font-weight: 700; z-index: 4; color: #ddd;
}

/* ---------- Horizontal scroll row (เห็นพอดี 6 การ์ดต่อจอ PC) ---------- */
.hscroll { display: flex; gap: 16px; overflow-x: auto; padding: 4px 2px 14px; scroll-snap-type: x mandatory; }
.hscroll > * { flex: 0 0 calc((100% - 80px) / 6); scroll-snap-align: start; }
@media (max-width: 1100px) { .hscroll > * { flex-basis: calc((100% - 48px) / 4); } }
@media (max-width: 820px) { .hscroll > * { flex-basis: calc((100% - 32px) / 3); } }
@media (max-width: 560px) { .hscroll > * { flex-basis: calc((100% - 16px) / 2); } }
.hscroll::-webkit-scrollbar { height: 7px; }
.hscroll::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 4px; }
.hscroll::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ---------- Filter bar ---------- */
.filter-bar {
    background: var(--surface); border: 1px solid var(--surface2); border-radius: var(--radius);
    padding: 14px 18px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 22px 0;
}
.filter-select {
    background: var(--surface2); color: var(--text); border: 1px solid transparent; padding: 10px 14px;
    border-radius: 9px; font-size: 14px; outline: none; min-width: 170px; cursor: pointer;
}
.filter-select:focus { border-color: var(--primary); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.chip {
    background: var(--surface); border: 1px solid var(--surface2); color: var(--muted); border-radius: 999px;
    padding: 6px 15px; font-size: 13px; font-weight: 600; transition: .18s;
}
.chip:hover { color: var(--text); border-color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Pagination ---------- */
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 44px 0 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
    min-width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9px; background: var(--surface); border: 1px solid var(--surface2);
    padding: 0 13px; font-size: 14px; font-weight: 700; color: var(--text);
}
.pagination a:hover { border-color: var(--primary); }
.pagination .active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .dots { background: none; border: none; color: var(--muted); }

/* ---------- Empty state ---------- */
.empty-state { padding: 70px 30px; background: var(--surface); border-radius: var(--radius); text-align: center; color: var(--muted); font-size: 15px; }

/* ---------- Watch page ---------- */
.watch-layout { display: grid; grid-template-columns: 1fr 350px; gap: 22px; margin-top: 22px; }
.player-box { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; box-shadow: 0 14px 44px rgba(0,0,0,.55); }
.player-box .video-js { width: 100%; height: 540px; }
@media (max-width: 1100px) { .player-box .video-js { height: 420px; } }

/* Gate overlay (ป๊อปอัพกดโฆษณาก่อนเล่น) */
.gate-overlay {
    position: absolute; inset: 0; z-index: 30; background: rgba(5,5,8,.92); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.gate-modal {
    background: var(--surface); border: 1px solid var(--surface2); border-radius: calc(var(--radius) + 6px);
    max-width: 430px; width: 100%; padding: 30px 26px; text-align: center;
    box-shadow: 0 30px 80px rgba(0,0,0,.7); animation: pop .35s cubic-bezier(.2,1.4,.4,1);
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.gate-modal .icon { font-size: 52px; margin-bottom: 8px; }
.gate-modal h3 { font-size: 19px; margin-bottom: 8px; }
.gate-modal p { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.gate-progress { height: 8px; background: var(--surface2); border-radius: 99px; overflow: hidden; margin: 14px 0; }
.gate-progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary2)); border-radius: 99px; transition: width .6s; }
.gate-count { font-size: 13px; color: var(--muted); }
.gate-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary2)); color: #fff; border: none;
    padding: 14px 26px; border-radius: 999px; font-size: 16px; font-weight: 800; width: 100%;
    box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 40%, transparent); transition: .2s;
}
.gate-btn:hover { transform: translateY(-2px); }
.gate-btn:disabled { opacity: .55; cursor: wait; }
.gate-waiting { color: var(--accent); font-size: 13.5px; margin-top: 12px; display: none; }

.movie-details { background: var(--surface); border-radius: var(--radius); padding: 22px; margin-top: 18px; }
.movie-details h1 { font-size: 22px; color: var(--primary); display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.movie-details .meta { color: var(--muted); font-size: 14px; display: flex; gap: 8px 16px; flex-wrap: wrap; margin: 10px 0 14px; }
.movie-details .synopsis { font-size: 14.5px; color: #d6d6de; line-height: 1.8; white-space: pre-line; }
.fav-btn {
    background: var(--surface2); color: var(--text); border: 1px solid var(--surface2); padding: 9px 18px;
    border-radius: 999px; font-size: 14px; font-weight: 700; transition: .2s;
}
.fav-btn.active { background: var(--primary); border-color: var(--primary); }
.report-btn { background: none; border: 1px solid var(--surface2); color: var(--muted); padding: 9px 18px; border-radius: 999px; font-size: 13px; }
.report-btn:hover { color: var(--primary); border-color: var(--primary); }

.watch-sidebar { display: flex; flex-direction: column; gap: 16px; }
.sidebar-box { background: var(--surface); border-radius: var(--radius); padding: 16px; }
.sidebar-box h3 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.sidebar-box h3::before { content: ''; width: 4px; height: 16px; border-radius: 2px; background: var(--primary); }
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 7px; max-height: 400px; overflow-y: auto; }
.ep-grid a {
    background: var(--surface2); border-radius: 8px; padding: 9px 4px; text-align: center; font-size: 13.5px;
    font-weight: 700; transition: .15s; border: 1px solid transparent;
}
.ep-grid a:hover { border-color: var(--primary); }
.ep-grid a.active { background: var(--primary); color: #fff; }
.ep-grid a.missing { opacity: .3; pointer-events: none; text-decoration: line-through; }
.audio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.audio-row button {
    background: var(--surface2); border: 1px solid transparent; color: var(--text); padding: 9px 16px;
    border-radius: 9px; font-size: 13.5px; font-weight: 700; flex: 1; transition: .18s;
}
.audio-row button.active { background: var(--primary); }
.audio-row button:hover:not(.active) { border-color: var(--primary); }

.nav-eps { display: flex; gap: 8px; margin-top: 12px; }
.nav-eps a, .nav-eps button {
    flex: 1; text-align: center; background: var(--surface2); border: none; color: var(--text);
    padding: 11px; border-radius: 9px; font-weight: 700; font-size: 14px;
}
.nav-eps a:hover { background: var(--primary); }

/* ---------- Favorites page ---------- */
.fav-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 6px; flex-wrap: wrap; gap: 10px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--surface2); margin-top: 60px; padding: 44px 0 26px; }
.footer-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 40px; }
.site-footer h4 { font-size: 14px; margin-bottom: 14px; color: var(--text); letter-spacing: .3px; }
.site-footer h4 span { margin-right: 4px; }
.site-footer p { color: var(--muted); font-size: 13.5px; line-height: 1.9; }
.f-logo { font-size: 24px; font-weight: 900; color: var(--primary); margin-bottom: 10px; letter-spacing: .5px; }
.f-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.f-chips a {
    background: var(--surface2); border: 1px solid transparent; color: var(--muted);
    border-radius: 999px; padding: 6px 14px; font-size: 12.5px; font-weight: 600; transition: .18s;
}
.f-chips a:hover { color: var(--text); border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface2)); }
.f-more { display: inline-block; margin-top: 14px; font-size: 12.5px; color: var(--primary); font-weight: 700; }
.f-more:hover { text-decoration: underline; }
.f-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.f-badges span {
    background: color-mix(in srgb, var(--primary) 14%, transparent); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
    color: var(--text); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600;
}
.copyright { text-align: center; color: var(--muted); font-size: 12.5px; padding: 18px 0 0; border-top: 1px solid var(--surface2); margin-top: 30px; }

/* ---------- Ad slots ---------- */
.ad-slot { margin: 18px 0; text-align: center; overflow: hidden; border-radius: var(--radius); }
.ad-slot img { max-width: 100%; border-radius: var(--radius); display: inline-block; }
.ad-text-banner { display: inline-block; background: var(--surface); border: 1px dashed var(--surface2); color: var(--muted); padding: 16px 30px; border-radius: var(--radius); font-size: 14px; }
.ad-label { font-size: 10px; color: var(--muted); letter-spacing: 2px; text-transform: uppercase; display: block; margin-bottom: 6px; }

/* ---------- Back to top ---------- */
#backTop {
    position: fixed; right: 22px; bottom: 24px; width: 44px; height: 44px; border-radius: 50%;
    background: var(--primary); color: #fff; border: none; font-size: 19px; z-index: 600;
    opacity: 0; pointer-events: none; transition: .25s; box-shadow: 0 8px 22px rgba(0,0,0,.45);
}
#backTop.show { opacity: 1; pointer-events: auto; }

/* ---------- Toast ---------- */
#toast {
    position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(80px);
    background: var(--surface); border: 1px solid var(--surface2); color: var(--text); padding: 12px 22px;
    border-radius: 999px; font-size: 14px; z-index: 1000; transition: .3s; box-shadow: 0 10px 30px rgba(0,0,0,.5);
    max-width: 90vw;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
    .watch-layout { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; gap: 8px; }
    .hero-info img.poster { display: none; }
}
@media (max-width: 820px) {
    .nav-inner { flex-wrap: wrap; height: auto; padding: 9px 20px; row-gap: 9px; }
    .nav-search { order: 5; max-width: none; flex-basis: 100%; margin: 0; }

    /* เมนูมือถือ: เลื่อนลงจากใต้แถบเมนูจริง (ตามความสูงจริง ไม่ใช่เลขตายตัว) */
    .nav-menu {
        position: absolute; top: 100%; left: 0; right: 0;
        display: none; flex-direction: column; align-items: stretch; gap: 2px;
        background: var(--surface); border-bottom: 1px solid var(--surface2);
        padding: 10px 16px 16px; max-height: calc(100vh - 150px); overflow-y: auto;
        box-shadow: 0 18px 40px rgba(0,0,0,.55);
    }
    .nav-menu.open { display: flex; animation: navDrop .22s ease; }
    @keyframes navDrop { from { opacity: 0; transform: translateY(-8px); } }
    .nav-menu > a, .nav-menu > .nav-drop > span {
        padding: 13px 14px; font-size: 15px; border-radius: 10px; white-space: normal;
    }
    .nav-menu > a.active { background: color-mix(in srgb, var(--primary) 18%, var(--surface2)); }
    .nav-burger { display: inline-flex; margin-left: auto; order: 4; }

    /* เมนูย่อยหมวดหมู่: กางในแนวตั้ง กดแตะแล้วเปิด (ไม่ใช่ hover) */
    .nav-drop-menu {
        position: static; display: none; box-shadow: none; border: none; background: transparent;
        padding: 2px 0 4px 14px; max-height: none; overflow: visible;
    }
    .nav-drop.open .nav-drop-menu { display: block; }
    .nav-drop-menu a { padding: 11px 12px; }

    .movie-grid { grid-template-columns: repeat(3, 1fr); gap: 11px; }
    .hero { min-height: 300px; }
    .hero-text h2 { font-size: 20px; }
    .player-box .video-js { height: 300px; }
    .filter-select { flex: 1; min-width: 130px; }
}
@media (max-width: 460px) {
    .movie-grid { grid-template-columns: repeat(2, 1fr); }
    .gate-modal { padding: 22px 16px; }
}
