/* ===== Củ Hành - giao diện (Bootstrap 5.3 + tuỳ biến) ===== */
:root {
    --bs-primary: #8b5cf6; --bs-primary-rgb: 139, 92, 246;
    --ch-accent: #8b5cf6; --ch-accent-dark: #7c3aed;
    --ch-radius: 10px;
}
[data-bs-theme="dark"] {
    --bs-body-bg: #0d0b14; --bs-body-bg-rgb: 13, 11, 20;
    --bs-tertiary-bg: #181523; --bs-tertiary-bg-rgb: 24, 21, 35;
    --bs-border-color: #2a2540;
    --ch-card: #181523; --ch-nav: rgba(13, 11, 20, .92); --ch-footer: #090710;
}
[data-bs-theme="light"] { --ch-card: #fff; --ch-nav: rgba(255, 255, 255, .94); --ch-footer: #f1eef9; }
a { color: var(--ch-accent); } a:hover { color: var(--ch-accent-dark); }
.btn-primary { --bs-btn-bg: var(--ch-accent); --bs-btn-border-color: var(--ch-accent); --bs-btn-hover-bg: var(--ch-accent-dark); --bs-btn-hover-border-color: var(--ch-accent-dark);
    --bs-btn-active-bg: #6d28d9; --bs-btn-active-border-color: #6d28d9; --bs-btn-disabled-bg: var(--ch-accent); --bs-btn-disabled-border-color: var(--ch-accent); }
.btn-outline-primary { --bs-btn-color: var(--ch-accent); --bs-btn-border-color: var(--ch-accent); --bs-btn-hover-bg: var(--ch-accent); --bs-btn-hover-border-color: var(--ch-accent); --bs-btn-active-bg: var(--ch-accent-dark); }
.form-control:focus, .form-select:focus { border-color: var(--ch-accent); box-shadow: 0 0 0 .2rem rgba(139, 92, 246, .25); }
.page-link { color: var(--ch-accent); } .page-item.active .page-link { background: var(--ch-accent); border-color: var(--ch-accent); }
.nav-pills .nav-link.active { background: var(--ch-accent); }
.card { background: var(--ch-card); border-color: var(--bs-border-color); }

/* Thanh điều hướng */
.site-nav { background: var(--ch-nav); backdrop-filter: blur(8px); border-bottom: 1px solid var(--bs-border-color); z-index: 1030; }
.brand-mark { color: var(--ch-accent); }
.dropdown-menu-cols { columns: 2; min-width: 260px; }
.search-box { min-width: 240px; }
.search-suggest { position: absolute; top: 100%; left: 0; right: 0; min-width: 320px; z-index: 1060; margin-top: 4px; background: var(--ch-card); border: 1px solid var(--bs-border-color); border-radius: var(--ch-radius); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); overflow: hidden; }
.search-suggest a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; color: inherit; text-decoration: none; }
.search-suggest a:hover, .search-suggest a.active { background: rgba(139, 92, 246, .15); }
.search-suggest img { width: 36px; height: 54px; object-fit: cover; border-radius: 4px; }
.search-suggest .s-meta { font-size: .78rem; color: var(--bs-secondary-color); }

/* Lưới phim và thẻ phim */
.movie-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.movie-grid-sm { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.movie-grid-1 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 575px) { .movie-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; } }
.movie-card { display: block; color: inherit; text-decoration: none; }
.movie-card .poster { position: relative; aspect-ratio: 2 / 3; border-radius: var(--ch-radius); overflow: hidden; background: #1c1830; transition: transform .2s, box-shadow .2s; }
.movie-card:hover .poster { transform: translateY(-4px) scale(1.02); box-shadow: 0 12px 28px rgba(139, 92, 246, .35); }
.movie-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.movie-card .play-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 3rem; color: #fff; background: rgba(0, 0, 0, .45); opacity: 0; transition: opacity .2s; }
.movie-card:hover .play-overlay { opacity: 1; }
.movie-card .badge-quality, .movie-card .badge-vip, .movie-card .badge-ep, .movie-card .badge-rating { position: absolute; font-size: .68rem; font-weight: 600; padding: 2px 6px; border-radius: 4px; color: #fff; }
.badge-quality { top: 6px; left: 6px; background: var(--ch-accent); }
.badge-vip { top: 6px; right: 6px; background: #f59e0b; color: #1a1200 !important; }
.badge-ep { bottom: 6px; left: 6px; background: rgba(0, 0, 0, .7); }
.badge-rating { bottom: 6px; right: 6px; background: rgba(0, 0, 0, .7); color: #fbbf24 !important; }
.card-title-line { margin-top: 8px; font-weight: 600; font-size: .9rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { font-size: .78rem; color: var(--bs-secondary-color); }
.section-title { border-left: 4px solid var(--ch-accent); padding-left: 10px; }

/* Skeleton loading */
.skeleton { position: relative; }
.skeleton::before { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, #1c1830 30%, #2b2548 50%, #1c1830 70%); background-size: 200% 100%; animation: sk 1.3s infinite linear; z-index: 0; }
.skeleton img { position: relative; z-index: 1; opacity: 0; transition: opacity .3s; }
.poster:not(.skeleton) img { opacity: 1; }
@keyframes sk { to { background-position: -200% 0; } }

/* Slider trang chủ và đầu trang chi tiết */
.hero-slide { min-height: 56vh; background-size: cover; background-position: center 20%; position: relative; display: flex; align-items: flex-end; }
.hero-shade, .detail-shade { position: absolute; inset: 0; background: linear-gradient(0deg, var(--bs-body-bg) 4%, rgba(13, 11, 20, .55) 55%, rgba(13, 11, 20, .35)), linear-gradient(90deg, rgba(13, 11, 20, .85), transparent 70%); }
/* Khung slider và đầu trang phim luôn nền tối + chữ trắng để dễ đọc ở cả hai giao diện */
[data-bs-theme="light"] .hero-shade, [data-bs-theme="light"] .detail-shade { background: linear-gradient(0deg, rgba(10, 8, 18, .95), rgba(10, 8, 18, .55) 60%, rgba(10, 8, 18, .45)); }
.detail-hero { color: #fff; }
.detail-hero .text-secondary { color: rgba(255, 255, 255, .72) !important; }
.hero-body { position: relative; padding-bottom: 36px; color: #fff; }
.hero-info { max-width: 560px; }
.detail-hero { position: relative; background-size: cover; background-position: center 25%; padding: 90px 0 24px; }
.detail-body { position: relative; }
.detail-poster { width: 100%; border-radius: var(--ch-radius); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.detail-desc { line-height: 1.7; }
.chip { display: inline-block; padding: 2px 10px; margin: 0 6px 6px 0; border: 1px solid var(--bs-border-color); border-radius: 20px; text-decoration: none; font-size: .82rem; color: inherit; }
.chip:hover { border-color: var(--ch-accent); color: var(--ch-accent); }
.rating-box .star { background: none; border: 0; padding: 0 2px; font-size: 1.35rem; color: #4b4668; cursor: pointer; }
.rating-box .star.on { color: #fbbf24; }

/* Tập phim */
.ep-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.ep-btn { position: relative; min-width: 52px; text-align: center; padding: 6px 12px; border: 1px solid var(--bs-border-color); border-radius: 8px; background: var(--ch-card); color: inherit; text-decoration: none; font-weight: 600; }
.ep-btn:hover, .ep-btn.current { background: var(--ch-accent); border-color: var(--ch-accent); color: #fff; }
.ep-btn.locked { opacity: .75; }
.ep-vip { color: #f59e0b; font-size: .65rem; position: absolute; top: 2px; right: 3px; }

/* Trình phát */
.player-wrap { background: #000; border-radius: var(--ch-radius); overflow: hidden; position: relative; }
/* Plyr tự căn tỉ lệ 16:9 (kể cả YouTube/Vimeo), nên chỉ iframe lạ mới dùng khung .ratio của Bootstrap */
.player-stage > iframe { border: 0; }
.player-stage .plyr { width: 100%; }
.player-stage { --plyr-color-main: #8b5cf6; }
.player-error { color: #fff; background: #111; }
.cinema-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .93); opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 1040; }
body.cinema .cinema-overlay { opacity: 1; pointer-events: auto; }
body.cinema .player-wrap, body.cinema .player-tools { position: relative; z-index: 1050; }
.lock-panel { position: relative; min-height: 340px; display: flex; align-items: center; justify-content: center; border-radius: var(--ch-radius); background-size: cover; background-position: center; overflow: hidden; color: #fff; }
.lock-panel::before { content: ""; position: absolute; inset: 0; background: rgba(8, 6, 14, .82); backdrop-filter: blur(6px); }
.lock-inner { position: relative; padding: 24px; max-width: 480px; }

/* Bình luận */
.comment { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--bs-border-color); }
.comment .avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #2a2540; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; color: #fff; }
.comment .replies { margin-top: 8px; margin-left: 4px; padding-left: 14px; border-left: 2px solid var(--bs-border-color); }
.comment-body { white-space: pre-wrap; word-break: break-word; }

/* Khác */
.ad-slot { text-align: center; margin: 12px 0; overflow: hidden; } .ad-slot img { max-width: 100%; border-radius: 6px; }
.ad-label { display: block; font-size: .65rem; color: var(--bs-secondary-color); text-transform: uppercase; letter-spacing: .06em; }
.auth-box { max-width: 440px; padding-top: 24px; }
.avatar-lg { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }
.history-item { color: inherit; padding: 10px; border: 1px solid var(--bs-border-color); border-radius: var(--ch-radius); background: var(--ch-card); }
.history-item img { object-fit: cover; border-radius: 6px; }
.plan-card { transition: transform .2s; } .plan-card:hover { transform: translateY(-3px); border-color: #f59e0b; }
.static-page { max-width: 820px; line-height: 1.75; }
.site-footer { background: var(--ch-footer); border-top: 1px solid var(--bs-border-color); }
.site-footer a { color: var(--bs-secondary-color); text-decoration: none; } .site-footer a:hover { color: var(--ch-accent); }
/* Thông báo (toast) góc trên bên phải, tự ẩn */
.toast-box { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; width: 380px; max-width: calc(100vw - 32px); pointer-events: none; }
.toast-box:empty { display: none; }
.toast-item { pointer-events: auto; position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 12px 34px 14px 14px; border-radius: 10px; background: var(--ch-card); color: var(--bs-body-color); border: 1px solid var(--bs-border-color); border-left: 4px solid var(--ch-accent); box-shadow: 0 10px 30px rgba(0, 0, 0, .35); overflow: hidden; animation: toast-in .25s ease-out; }
.toast-item.hide { opacity: 0; transform: translateX(30px); transition: opacity .3s, transform .3s; }
.toast-icon { font-size: 1.2rem; line-height: 1.3; }
.toast-msg { flex: 1; font-size: .92rem; line-height: 1.4; word-break: break-word; }
.toast-x { position: absolute; top: 6px; right: 8px; border: 0; background: none; color: inherit; opacity: .55; font-size: 1.25rem; line-height: 1; cursor: pointer; }
.toast-x:hover { opacity: 1; }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; transform-origin: left; animation: toast-bar linear forwards; }
.toast-item.paused .toast-bar { animation-play-state: paused; }
.toast-success { border-left-color: #22c55e; } .toast-success .toast-icon, .toast-success .toast-bar { color: #22c55e; background: #22c55e; }
.toast-error { border-left-color: #ef4444; } .toast-error .toast-icon, .toast-error .toast-bar { color: #ef4444; background: #ef4444; }
.toast-info { border-left-color: #38bdf8; } .toast-info .toast-icon, .toast-info .toast-bar { color: #38bdf8; background: #38bdf8; }
.toast-bar { opacity: .55; }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .toast-item, .toast-bar { animation: none; } }

/* ===== Khu quản trị ===== */
.admin-shell { display: flex; min-height: 100vh; }
.admin-side { width: 230px; flex: none; background: var(--ch-footer); border-right: 1px solid var(--bs-border-color); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.admin-brand { display: block; font-weight: 700; font-size: 1.2rem; text-decoration: none; color: inherit; margin: 4px 8px 14px; }
.admin-side .nav-link { color: var(--bs-body-color); padding: 7px 10px; border-radius: 8px; font-size: .92rem; }
.admin-side .nav-link:hover { background: rgba(139, 92, 246, .12); }
.admin-side .nav-link.active { background: var(--ch-accent); color: #fff; }
.admin-side .nav-link i { width: 20px; display: inline-block; }
.side-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--bs-secondary-color); margin: 14px 10px 4px; }
.admin-main { flex: 1; min-width: 0; }
.admin-top { padding: 10px 20px; border-bottom: 1px solid var(--bs-border-color); background: var(--ch-nav); position: sticky; top: 0; z-index: 20; }
.admin-content { padding: 20px; }
.admin-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); white-space: nowrap; }
.stat-card { display: flex; gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--bs-border-color); border-radius: var(--ch-radius); background: var(--ch-card); color: inherit; height: 100%; }
.stat-card:hover { border-color: var(--ch-accent); color: inherit; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.3rem; flex: none; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; } .stat-label { font-size: .82rem; color: var(--bs-secondary-color); }
@media (max-width: 991px) { .admin-side { position: fixed; left: -240px; z-index: 1050; transition: left .2s; } .admin-side.open { left: 0; } }

/* Ô chọn diễn viên / đạo diễn (admin) */
.people-picker { position: relative; }
.chip-sel { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border: 1px solid var(--ch-accent); border-radius: 20px; background: rgba(139, 92, 246, .12); font-size: .85rem; }
.chip-sel .chip-x { border: 0; background: none; color: inherit; font-size: 1.1rem; line-height: 1; padding: 0 4px; cursor: pointer; opacity: .7; }
.chip-sel .chip-x:hover { opacity: 1; color: #ef4444; }
.chip-actor { display: flex; width: 100%; border-radius: 8px; margin-bottom: 4px; padding: 4px 6px 4px 10px; }
.chip-actor .chip-name { min-width: 130px; font-weight: 600; }
.chip-actor .chip-role { flex: 1; }
.picker-results { position: absolute; left: 0; right: 0; z-index: 30; max-height: 240px; overflow-y: auto; background: var(--ch-card); border: 1px solid var(--bs-border-color); border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); margin-top: 2px; }
.picker-item { display: block; width: 100%; text-align: left; padding: 7px 12px; border: 0; background: none; color: inherit; }
.picker-item:hover, .picker-item:focus { background: rgba(139, 92, 246, .18); }
.picker-empty { padding: 8px 12px; color: var(--bs-secondary-color); font-size: .85rem; }

/* Tua: hiệu ứng khi chạm đúp / dùng phím tắt */
.player-wrap { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.seek-flash { position: absolute; top: 50%; z-index: 6; padding: 12px 18px; border-radius: 40px; background: rgba(0, 0, 0, .65); color: #fff; font-weight: 700; font-size: 1.05rem; pointer-events: none; transform: translateY(-50%); animation: seek-pop .65s ease-out forwards; }
.seek-flash.left { left: 10%; } .seek-flash.right { right: 10%; } .seek-flash.center { left: 50%; margin-left: -40px; }
@keyframes seek-pop { 0% { opacity: 0; transform: translateY(-50%) scale(.85); } 20% { opacity: 1; transform: translateY(-50%) scale(1); } 100% { opacity: 0; transform: translateY(-50%) scale(1.06); } }

/* Nút tua 10 giây dạng mũi tên vòng tròn */
.plyr__control[data-plyr="rewind"] svg, .plyr__control[data-plyr="fast-forward"] svg { width: 24px; height: 24px; }

/* ===== Thanh điều khiển gọn (PC + điện thoại): hàng tiến trình ở trên, hàng nút ở dưới ===== */
.player-stage { --plyr-control-spacing: 8px; --plyr-font-size-time: 13px; }
.player-stage .plyr--video .plyr__controls { flex-wrap: wrap; align-items: center; row-gap: 0; padding: 26px 10px 8px; }
.player-stage .plyr__controls .plyr__controls__item:first-child { margin-right: 0; }
/* Thanh tiến trình chiếm trọn hàng đầu, không bị thanh âm lượng làm biến mất */
.player-stage .plyr__controls .plyr__progress__container { order: -1; flex: 0 0 100%; min-width: 100%; margin: 0 0 2px; }
.player-stage .plyr__controls > .plyr__progress { order: -1; flex: 0 0 100%; min-width: 100%; margin: 0 0 2px; } /* phòng khi Plyr không bọc thanh tiến trình trong container */
/* Hàng nút: trái = phát, tua, loa, thời gian; phải = phụ đề, cài đặt, PIP, toàn màn hình */
.player-stage .plyr__controls [data-plyr="play"] { order: 1; }
.player-stage .plyr__controls [data-plyr="rewind"] { order: 2; }
.player-stage .plyr__controls [data-plyr="fast-forward"] { order: 3; }
.player-stage .plyr__controls [data-plyr="mute"] { order: 4; }
.player-stage .plyr__controls .plyr__time--current { order: 6; }
.player-stage .plyr__controls .plyr__time--duration { order: 7; margin-right: auto; display: inline-block !important; } /* luôn hiện "0:28 / 7:28" kể cả trên điện thoại */
.player-stage .plyr__controls [data-plyr="captions"] { order: 10; }
.player-stage .plyr__controls .plyr__menu { order: 11; }
.player-stage .plyr__controls [data-plyr="pip"] { order: 12; }
.player-stage .plyr__controls [data-plyr="airplay"] { order: 13; }
.player-stage .plyr__controls [data-plyr="fullscreen"] { order: 14; }
/* Âm lượng: chỉ hiện nút loa; thanh trượt bung ra khi rê chuột / focus (PC), ẩn hẳn trên điện thoại */
.player-stage .plyr__controls .plyr__volume { order: 5; width: 0; min-width: 0; max-width: 90px; overflow: hidden; margin: 0; padding: 0; transition: width .2s ease; }
.player-stage .plyr__controls [data-plyr="mute"]:hover + .plyr__volume,
.player-stage .plyr__controls .plyr__volume:hover,
.player-stage .plyr__controls .plyr__volume:focus-within { width: 90px; }
@media (hover: none), (max-width: 767.98px) { .player-stage .plyr__controls .plyr__volume { display: none !important; } }
/* Menu cài đặt / tốc độ / chất lượng: quá dài thì cuộn trong khung trình phát (chiều cao tối đa do player.js tính theo khung) */
.player-stage .plyr__menu__container { max-height: var(--ch-menu-max, 240px); max-width: calc(100vw - 24px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
@media (max-width: 575.98px) {
    .player-stage { --plyr-control-spacing: 4px; --plyr-font-size-time: 12px; }
    .player-stage .plyr--video .plyr__controls { padding: 22px 6px 6px; }
    .player-stage .plyr__controls .plyr__control { padding: 5px; }
}

/* ===== PIP dạng trình phát mini nổi trong trang (dùng khi nguồn không có PIP gốc: YouTube, Vimeo, iframe, Firefox...) ===== */
.mini-bar { display: none; }
#player-root.mini { position: fixed; right: 16px; bottom: 16px; width: min(380px, 70vw); z-index: 1060; border-radius: 12px; box-shadow: 0 14px 44px rgba(0, 0, 0, .65); }
#player-root.mini .mini-bar { display: flex; position: absolute; top: 0; left: 0; right: 0; z-index: 12; align-items: center; gap: 6px; padding: 4px 8px; color: #fff; background: linear-gradient(rgba(0, 0, 0, .8), transparent); cursor: move; touch-action: none; opacity: 0; transition: opacity .2s; }
#player-root.mini:hover .mini-bar, #player-root.mini .mini-bar:focus-within { opacity: 1; }
.mini-bar .mini-title { flex: 1; min-width: 0; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-bar button { border: 0; background: none; color: #fff; font-size: 1rem; line-height: 1; padding: 3px 6px; cursor: pointer; }
.mini-bar button:hover { color: var(--ch-accent); }
/* Trong chế độ mini chỉ giữ các nút thiết yếu cho gọn */
#player-root.mini .plyr__controls [data-plyr="rewind"], #player-root.mini .plyr__controls [data-plyr="fast-forward"],
#player-root.mini .plyr__controls .plyr__time--duration, #player-root.mini .plyr__controls [data-ch="mini"],
#player-root.mini .plyr__controls [data-plyr="captions"] { display: none !important; }
#player-root.mini .plyr__controls .plyr__time--current { margin-right: auto; }
.player-stage .plyr__controls [data-ch="mini"] { order: 12; }
@media (max-width: 575.98px) { #player-root.mini { width: 62vw; right: 8px; bottom: 8px; } }
