/*
Theme Name: Phim Theme
Theme URI: https://example.com
Author: williamkane
Author URI: https://example.com
Description: Theme WordPress tự code cho website xem phim - quản lý Phim, Tập phim, Thể loại, Diễn viên, Đạo diễn.
Version: 1.11.0
Text Domain: phim-theme
*/

/* ==========================================================================
   Reset & base
   ========================================================================== */
* { box-sizing: border-box; }
body {
    margin: 0;
    background: #0f1115;
    color: #e8e8e8;
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; margin: 0; padding: 0; }

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

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
    background: #14161c;
    border-bottom: 1px solid #23262f;
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
}
.site-logo {
    font-size: 22px;
    font-weight: 700;
    color: #ff4757;
}
.main-nav > ul {
    display: flex;
    align-items: center;
    gap: 20px;
}
.main-nav li {
    position: relative;
}
.main-nav a {
    display: block;
    font-size: 14px;
    color: #cfd2d8;
    white-space: nowrap;
}
.main-nav a:hover,
.main-nav li:focus-within > a { color: #ff4757; }

/* Dropdown cho menu cha (ví dụ: Genres -> Creampie, Big Tits, ...) */
.main-nav .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    display: block;
    min-width: 190px;
    max-width: 260px;
    margin: 0;
    padding: 7px 0;
    background: #181b22;
    border: 1px solid #2b2f3a;
    border-radius: 5px;
    box-shadow: 0 10px 25px rgba(0,0,0,.35);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
}
.main-nav .menu-item-has-children:hover > .sub-menu,
.main-nav .menu-item-has-children:focus-within > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.main-nav .sub-menu li {
    width: 100%;
}
.main-nav .sub-menu a {
    padding: 8px 14px;
    font-size: 14px;
    line-height: 1.35;
    white-space: normal;
}
.main-nav .sub-menu a:hover,
.main-nav .sub-menu li:focus-within > a {
    background: #222631;
    color: #ff4757;
}
.main-nav > ul > .menu-item-has-children > a::after {
    content: ' ▾';
    font-size: 11px;
}

/* Nếu có rất nhiều genre, dropdown vẫn gọn và không kéo dài cả màn hình. */
.main-nav > ul > .menu-item-has-children > .sub-menu {
    max-height: 70vh;
    overflow-y: auto;
}

.search-form {
    display: flex;
}
.search-form input[type="search"] {
    background: #1c1f27;
    border: 1px solid #2b2f3a;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px 0 0 4px;
    outline: none;
}
.search-form button {
    background: #ff4757;
    border: none;
    color: #fff;
    padding: 8px 14px;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
}

/* ==========================================================================
   Layout: content + sidebar
   ========================================================================== */
.site-content-wrap {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
    padding: 30px 0 60px;
}
@media (max-width: 1000px) {
    .movie-grid,
    .movie-grid--full { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}
@media (max-width: 900px) {
    .site-content-wrap { grid-template-columns: 1fr; }
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 16px;
    padding-left: 10px;
    border-left: 3px solid #ff4757;
}

/* ==========================================================================
   Movie grid & card
   ========================================================================== */
.movie-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}
.movie-card {
    position: relative;
    background: #181b22;
    border-radius: 6px;
    overflow: hidden;
    transition: transform .15s ease;
}
.movie-card:hover { transform: translateY(-4px); }
.movie-card .poster-wrap {
    position: relative;
    overflow: hidden;
}
.movie-card .poster-wrap img { width: 100%; height: auto; display: block; }
.movie-card .movie-title {
    font-size: 13px;
    padding: 8px;
    font-weight: 600;
    white-space: normal;
    overflow: visible;
    word-break: break-word;
    line-height: 1.35;
}

/* ==========================================================================
   Single movie page
   ========================================================================== */
.movie-hero {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 20px;
    margin-bottom: 30px;
    background: #181b22;
    border: 1px solid #23262f;
    border-radius: 8px;
    padding: 18px;
}
@media (max-width: 700px) {
    .movie-hero { grid-template-columns: 1fr; }
}
.movie-hero__poster img {
    border-radius: 6px;
    width: 100%;
}
.movie-hero__body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.movie-hero__title {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 14px;
    word-break: break-word;
}
.movie-hero__row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}
.movie-hero__label {
    flex: 0 0 auto;
    width: 56px;
    padding-top: 5px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #8a8e97;
}
.movie-hero__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.movie-tag {
    display: inline-block;
    font-size: 12px;
    line-height: 1.4;
    padding: 4px 10px;
    border-radius: 20px;
    background: #23262f;
    color: #cfd2d8;
    transition: background .15s ease, color .15s ease;
}
.movie-tag:hover { background: #ff4757; color: #fff; }
.movie-tag--cast { background: #1c2530; }
.movie-tag--cast:hover { background: #4caf50; color: #fff; }
.movie-desc { font-size: 14px; color: #c7cad1; }

.player-box {
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 20px;
}
.player-box .player-empty {
    color: #fff;
    text-align: center;
    padding-top: 40%;
    aspect-ratio: 16/9;
}

.phim-player-stage {
    position: relative;
    aspect-ratio: 16/9;
}
.phim-player-stage video,
.phim-player-stage iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}
.phim-player-notice {
    position: absolute;
    top: 0; left: 0; right: 0;
    padding: 8px 12px;
    background: rgba(0,0,0,.75);
    color: #fff;
    font-size: 13px;
    text-align: center;
}

/* ==========================================================================
   Server switch (chọn server dưới player)
   ========================================================================== */
.phim-server-switch {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding: 10px 12px; background: #14161c;
}
.phim-server-btn {
    background: transparent; border: 1px solid #3a3d45; color: #a9adb6;
    font-size: 13px; padding: 6px 16px; border-radius: 20px; cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.phim-server-btn:hover { border-color: #e5342f; color: #fff; }
.phim-server-btn.is-active { background: #e5342f; border-color: #e5342f; color: #fff; }

/* ==========================================================================
   Player action buttons: Report error / Request a movie
   ========================================================================== */
.phim-player-actions { display: flex; justify-content: flex-end; gap: 10px; margin: 10px 0 20px; flex-wrap: wrap; }
.phim-report-error-btn,
.phim-request-movie-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: transparent; border: 1px solid #3a3d45; color: #a9adb6;
    font-size: 13px; padding: 7px 14px; border-radius: 4px; cursor: pointer;
}
.phim-report-error-btn:hover { border-color: #e5342f; color: #fff; }
.phim-request-movie-btn:hover { border-color: #4caf50; color: #fff; }

.phim-report-modal, .phim-request-modal { position: fixed; inset: 0; z-index: 1000; }
.phim-report-modal-backdrop, .phim-request-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.7); }
.phim-report-modal-box, .phim-request-modal-box {
    position: relative; max-width: 420px; margin: 10vh auto 0;
    background: #181b22; border-radius: 8px; padding: 20px; color: #e8e8e8;
}
.phim-report-modal-box h3, .phim-request-modal-box h3 { margin: 0 0 14px; font-size: 17px; }
.phim-report-modal-box label, .phim-request-modal-box label { display: block; font-size: 13px; color: #a9adb6; margin-bottom: 12px; }
.phim-report-modal-box select,
.phim-report-modal-box textarea,
.phim-request-modal-box input,
.phim-request-modal-box textarea {
    display: block; width: 100%; margin-top: 6px; background: #0f1115; color: #e8e8e8;
    border: 1px solid #3a3d45; border-radius: 4px; padding: 8px; font-family: inherit; font-size: 14px;
    box-sizing: border-box;
}
.phim-report-modal-actions, .phim-request-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.phim-report-modal-actions button, .phim-request-modal-actions button { border-radius: 4px; padding: 8px 16px; font-size: 13px; cursor: pointer; border: 1px solid #3a3d45; }
.phim-report-cancel, .phim-request-cancel { background: transparent; color: #a9adb6; }
.phim-report-submit { background: #e5342f; border-color: #e5342f; color: #fff; }
.phim-request-submit { background: #4caf50; border-color: #4caf50; color: #fff; }
.phim-report-msg, .phim-request-msg { font-size: 13px; margin: 10px 0 0; min-height: 1em; }
.phim-report-msg.is-success, .phim-request-msg.is-success { color: #4caf50; }
.phim-report-msg.is-error, .phim-request-msg.is-error { color: #e5342f; }

/* ==========================================================================
   Sidebar widgets
   ========================================================================== */
.widget {
    background: #181b22;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 20px;
}
.widget-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 12px;
}
.widget-movie-item {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.widget-movie-item img {
    width: 50px;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
}
.widget-movie-item .t { font-size: 13px; font-weight: 600; }
.widget-movie-item .y { font-size: 12px; color: #8a8e97; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
    background: #14161c;
    border-top: 1px solid #23262f;
    padding: 24px 0;
    text-align: center;
    font-size: 13px;
    color: #8a8e97;
}

/* ==========================================================================
   Home main content widgets + grid dùng trong widget
   ========================================================================== */
.widget--main { background: transparent; padding: 0; margin-bottom: 32px; }
.movie-grid--widget { margin-bottom: 0; }
.movie-grid--full {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* ==========================================================================
   Search widget đẹp
   ========================================================================== */
.widget-search-form {
    display: flex;
    align-items: center;
    background: #0f1115;
    border: 1px solid #2a2e38;
    border-radius: 999px;
    padding: 6px 6px 6px 16px;
    transition: border-color .2s ease, box-shadow .2s ease;
}
.widget-search-form:focus-within {
    border-color: #ff4757;
    box-shadow: 0 0 0 3px rgba(255,71,87,.15);
}
.widget-search-form .wsf-icon { color: #6c7280; display: flex; margin-right: 8px; }
.widget-search-form input[type="search"] {
    flex: 1;
    background: transparent;
    border: 0;
    outline: none;
    color: #e8e8e8;
    font-size: 14px;
    padding: 8px 0;
}
.widget-search-form input[type="search"]::placeholder { color: #6c7280; }
.widget-search-form button {
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    border: 0;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    padding: 9px 18px;
    border-radius: 999px;
    cursor: pointer;
    transition: opacity .15s ease;
}
.widget-search-form button:hover { opacity: .9; }

/* ==========================================================================
   Most viewed widget (tabs Month/Year/All)
   ========================================================================== */
.widget-mostviewed .mv-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    border-bottom: 1px solid #23262f;
}
.widget-mostviewed .mv-tab {
    background: transparent;
    border: 0;
    color: #8a8e97;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 10px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}
.widget-mostviewed .mv-tab.is-active { color: #ff4757; border-bottom-color: #ff4757; }
.widget-mostviewed .mv-panel { display: none; }
.widget-mostviewed .mv-panel.is-active { display: block; }
.widget-mostviewed .mv-empty { font-size: 13px; color: #6c7280; }

/* Tabs Month/Year/All trên trang page-most-viewed.php (link thật, không phải JS toggle) */
.mv-page-tabs {
    display: flex;
    gap: 6px;
    margin: 4px 0 18px;
    border-bottom: 1px solid #23262f;
}
.mv-page-tab {
    display: inline-block;
    color: #8a8e97;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    padding: 8px 14px;
    border-bottom: 2px solid transparent;
}
.mv-page-tab:hover { color: #d0d2d8; }
.mv-page-tab.is-active { color: #ff4757; border-bottom-color: #ff4757; }

/* ==========================================================================
   Related movies (widget area single-related-movies trên trang chi tiết phim)
   ========================================================================== */
.single-related { margin-top: 28px; }

/* ==========================================================================
   Ad / Banner widgets
   ========================================================================== */
.phim-ad-slot { display: flex; justify-content: center; align-items: center; overflow: hidden; }
.phim-ad-slot img { max-width: 100%; height: auto; border-radius: 6px; }
.widget--banner { text-align: center; }
.single-banner, .cast-banner { margin: 20px 0; }

/* ==========================================================================
   Trang Cast - tràn ngang, không sidebar
   ========================================================================== */
.site-content-wrap--full { display: block; grid-template-columns: none; }
.site-main--full { width: 100%; }
.cast-page-title { margin-bottom: 20px; }

/* ==========================================================================
   Custom HLS player controls
   ========================================================================== */
.phim-player { position: relative; background: #000; }
.phim-player .phim-video { width: 100%; height: 100%; display: block; background: #000; }

.phim-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 8px 12px;
    background: linear-gradient(to top, rgba(0,0,0,.85), rgba(0,0,0,0));
    color: #fff;
}
.pc-btn {
    background: transparent;
    border: 0;
    color: #fff;
    width: 28px;
    height: 28px;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}
.pc-btn svg { width: 100%; height: 100%; }
.pc-time { font-size: 12px; min-width: 38px; text-align: center; flex-shrink: 0; }

.pc-progress {
    position: relative;
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,.25);
    border-radius: 3px;
    overflow: hidden;
}
.pc-progress-buffered {
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 0%; background: rgba(255,255,255,.35);
}
.pc-progress-played {
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 0%; background: #ff4757;
}
.pc-seek {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    opacity: 0; cursor: pointer; margin: 0;
}

.pc-volume {
    width: 70px;
    accent-color: #ff4757;
    cursor: pointer;
}
.pc-quality {
    background: rgba(255,255,255,.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 4px;
    font-size: 12px;
    padding: 3px 6px;
    flex-shrink: 0;
}
.pc-quality option { color: #000; }

/* Responsive / mobile cho player + trang */
@media (max-width: 780px) {
    .site-content-wrap { grid-template-columns: 1fr; }
    .movie-hero { grid-template-columns: 1fr; }
    .phim-controls { gap: 6px; padding: 6px 8px; }
    .pc-volume { width: 40px; }
    .pc-time { font-size: 11px; min-width: 30px; }
    .movie-grid,
    .movie-grid--full { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
