/* =========================================
   PHIM STREAM - Main Stylesheet
   ========================================= */

/* CSS Variables */
:root {
    --primary-color: #e50914;
    --primary-hover: #f40612;
    --secondary-color: #141414;
    --background-dark: #0a0a0a;
    --background-card: #1a1a1a;
    --background-hover: #252525;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #808080;
    --border-color: #333;
    --success-color: #46d369;
    --warning-color: #f5a623;
    --danger-color: #e50914;
    --gradient-overlay: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.3) 50%, rgba(0,0,0,0.9) 100%);
    --transition: all 0.3s ease;
    --border-radius: 4px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* First Visit Preloader */
.site-preloader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #181d32 0%, #0a0b11 72%);
    opacity: 1;
    transition: opacity 0.42s ease;
}

.site-preloader.is-visible {
    display: flex;
}

.site-preloader.is-hiding {
    opacity: 0;
}

.site-preloader-inner {
    text-align: center;
    padding: 20px;
}

.site-preloader-logo {
    width: clamp(140px, 20vw, 220px);
    height: auto;
    margin: 0 auto 12px;
    display: block;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.35));
}

.site-preloader-spinner {
    width: 44px;
    height: 44px;
    margin: 0 auto 10px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #e50914;
    animation: preloaderSpin 0.8s linear infinite;
}

.site-preloader-text {
    font-size: 0.9rem;
    color: #c6cde9;
    letter-spacing: 0.02em;
}

@keyframes preloaderSpin {
    to {
        transform: rotate(360deg);
    }
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-color);
}

ul, ol {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
}

/* =========================================
   HEADER STYLES
   ========================================= */
.header {
    background: var(--secondary-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.header-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    gap: 20px;
}

/* Mobile menu toggle (drawer) */
.nav-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.nav-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
}

.nav-overlay {
    display: none;
}

/* Only show inside drawer breakpoint */
.mobile-nav-brand {
    display: none;
}

.logo img {
    display: block;
}

/* Search Box */
.search-box {
    flex: 1;
    max-width: 500px;
    position: relative;
}

.search-box form {
    display: flex;
    background: var(--background-card);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.search-box input {
    flex: 1;
    padding: 10px 15px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
}

.search-box button {
    padding: 10px 20px;
    background: var(--primary-color);
    border: none;
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.search-box button:hover {
    background: var(--primary-hover);
}

/* Main Navigation */
.main-nav ul {
    display: flex;
    gap: 25px;
}

.main-nav a {
    font-weight: 500;
    padding: 8px 0;
    position: relative;
}

.main-nav a:hover {
    color: var(--primary-color);
}

.main-nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: var(--transition);
}

.main-nav a:hover::after {
    width: 100%;
}

/* User Actions */
.user-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: white;
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--background-card);
}

/* User Dropdown */
.user-dropdown {
    position: relative;
}

.user-avatar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 20px;
    background: var(--background-card);
    transition: var(--transition);
}

.user-avatar:hover {
    background: var(--background-hover);
}

.user-avatar img {
    border-radius: 50%;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: var(--background-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition);
    z-index: 100;
}

.user-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    color: var(--text-secondary);
}

.dropdown-menu a:hover {
    background: var(--background-hover);
    color: var(--text-primary);
}

.dropdown-menu a i {
    width: 16px;
    text-align: center;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 5px 0;
}

/* =========================================
   ADS BANNER
   ========================================= */
.ads-banner {
    text-align: center;
    padding: 10px;
    background: var(--background-card);
    border-bottom: 1px solid var(--border-color);
}

.ads-banner img,
.ads-banner iframe {
    max-width: 100%;
    margin: 0 auto;
    display: inline-block;
}

/* =========================================
   MAIN CONTENT
   ========================================= */
.main-content {
    min-height: calc(100vh - 60px);
    padding: 20px 0;
}

/* =========================================
   SECTION COMMON
   ========================================= */
.section {
    margin-bottom: 40px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title i {
    color: var(--primary-color);
}

.section-link {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.section-link:hover {
    color: var(--primary-color);
}

/* =========================================
   FILM CARDS GRID
   ========================================= */
.film-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.film-card {
    background: var(--background-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}

.film-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.film-card-poster {
    position: relative;
    aspect-ratio: 2/3;
    overflow: hidden;
}

.film-card-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.film-card:hover .film-card-poster img {
    transform: scale(1.05);
}

.film-card-quality {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 2px;
}

.film-card-rating {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--warning-color);
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 2px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.film-card-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
    transform: translateY(100%);
    transition: var(--transition);
}

.film-card:hover .film-card-actions {
    transform: translateY(0);
}

.film-card-actions .btn {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.film-card-info {
    padding: 12px;
}

.film-card-title {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.film-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.film-card-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.film-card-category {
    padding: 2px 6px;
    background: var(--background-hover);
    color: var(--text-muted);
    font-size: 0.7rem;
    border-radius: 2px;
}

/* =========================================
   FILM DETAIL PAGE
   ========================================= */
.film-detail {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
}

.film-poster {
    background: var(--background-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    position: sticky;
    top: 80px;
}

.film-poster img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
}

.film-poster .quality-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 5px 10px;
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    border-radius: 4px;
}

.film-info {
    background: var(--background-card);
    border-radius: var(--border-radius);
    padding: 20px;
}

.film-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.film-original-title {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 15px;
}

.film-meta-list {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.film-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.film-meta-item i {
    color: var(--primary-color);
}

.film-description {
    margin-bottom: 25px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.film-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
}

.film-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 12px 20px;
    font-size: 1rem;
}

.btn-watch {
    background: var(--primary-color);
    color: white;
}

.btn-watch:hover {
    background: var(--primary-hover);
    color: white;
}

.btn-favorite {
    background: var(--background-hover);
    color: var(--text-primary);
}

.btn-favorite.active {
    background: var(--danger-color);
    color: white;
}

.film-cast-list {
    margin-bottom: 20px;
}

.film-cast-list h4 {
    margin-bottom: 10px;
    font-size: 1rem;
}

.film-cast-list p {
    color: var(--text-secondary);
    line-height: 1.8;
}

/* =========================================
   EPISODE LIST
   ========================================= */
.episode-section {
    background: var(--background-card);
    border-radius: var(--border-radius);
    padding: 20px;
}

.episode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.episode-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
}

.episode-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: var(--background-hover);
    border-radius: 4px;
    font-size: 0.9rem;
    transition: var(--transition);
    cursor: pointer;
}

.episode-item:hover {
    background: var(--primary-color);
    color: white;
}

.episode-item.active {
    background: var(--primary-color);
    color: white;
}

/* =========================================
   PLAYER SECTION
   ========================================= */
.player-section {
    background: var(--background-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 30px;
}

.player-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    background: #000;
}

.player-container iframe,
.player-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.player-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    background: var(--secondary-color);
}

.player-controls select {
    padding: 8px 15px;
    background: var(--background-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--border-radius);
    cursor: pointer;
}

/* =========================================
   SERVER TABS
   ========================================= */
.server-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.server-tab {
    padding: 8px 16px;
    background: var(--background-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.server-tab:hover {
    background: var(--background-hover);
}

.server-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* =========================================
   CATEGORY PAGE
   ========================================= */
.category-header {
    background: var(--background-card);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 30px;
    text-align: center;
}

.category-title {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.category-description {
    color: var(--text-secondary);
}

.film-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

/* =========================================
   PAGINATION
   ========================================= */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-top: 30px;
}

.pagination a,
.pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    background: var(--background-card);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.pagination a:hover {
    background: var(--background-hover);
}

.pagination .active {
    background: var(--primary-color);
    color: white;
}

.pagination .disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =========================================
   LOGIN/REGISTER FORM
   ========================================= */
.auth-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    background: var(--background-card);
    border-radius: var(--border-radius);
}

.auth-title {
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.5rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    background: var(--background-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.form-error {
    color: var(--danger-color);
    font-size: 0.85rem;
    margin-top: 5px;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px;
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--primary-color);
}

/* =========================================
   ADMIN STYLES
   ========================================= */
.admin-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.admin-sidebar {
    background: var(--secondary-color);
    padding: 20px 0;
}

.admin-sidebar .logo {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.admin-nav ul {
    display: flex;
    flex-direction: column;
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.admin-nav a:hover,
.admin-nav a.active {
    background: var(--background-card);
    color: var(--primary-color);
}

.admin-nav a i {
    width: 20px;
    text-align: center;
}

.admin-content {
    padding: 20px;
    background: var(--background-dark);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.admin-title {
    font-size: 1.5rem;
}

.admin-card {
    background: var(--background-card);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    background: var(--background-hover);
    font-weight: 600;
    color: var(--text-secondary);
}

.admin-table tr:hover {
    background: var(--background-hover);
}

.admin-table .actions {
    display: flex;
    gap: 8px;
}

.admin-table .btn-sm {
    padding: 5px 10px;
    font-size: 0.85rem;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-active {
    background: rgba(70, 211, 105, 0.2);
    color: var(--success-color);
}

.status-inactive {
    background: rgba(189, 195, 199, 0.2);
    color: var(--text-muted);
}

.status-banned {
    background: rgba(229, 9, 20, 0.2);
    color: var(--danger-color);
}

/* =========================================
   FORMS
   ========================================= */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

/* =========================================
   ALERTS
   ========================================= */
.alert {
    padding: 12px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: rgba(70, 211, 105, 0.2);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.alert-error {
    background: rgba(229, 9, 20, 0.2);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

.alert-warning {
    background: rgba(245, 166, 35, 0.2);
    border: 1px solid var(--warning-color);
    color: var(--warning-color);
}

.alert-info {
    background: rgba(52, 152, 219, 0.2);
    border: 1px solid #3498db;
    color: #3498db;
}

/* =========================================
   STATS CARDS
   ========================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--background-card);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    border-radius: 10px;
    font-size: 1.5rem;
    color: white;
}

.stat-info h3 {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* =========================================
   MODAL
   ========================================= */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--background-card);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
}

/* =========================================
   RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 1024px) {
    .film-detail {
        grid-template-columns: 1fr;
    }
    
    .film-poster {
        position: relative;
        top: 0;
        max-width: 300px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .header-wrap {
        position: relative;
        flex-wrap: wrap;
        height: auto;
        padding: 10px 0;
    }
    
    .logo {
        position: absolute;
        left: 50%;
        top: 14px;
        transform: translateX(-50%);
        z-index: 2;
    }
    
    .logo img {
        height: 22px;
        width: auto;
    }
    
    .search-box {
        order: 3;
        max-width: 100%;
        width: 100%;
        margin-top: 10px;
    }
    
    .main-nav {
        order: 2;
        width: 100%;
    }
    
    .main-nav ul {
        justify-content: center;
        gap: 15px;
    }
    
    .user-actions {
        order: 1;
        margin-left: auto;
    }
    
    .film-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
    }
    
    .admin-layout {
        grid-template-columns: 1fr;
    }
    
    .admin-sidebar {
        position: sticky;
        top: 60px;
        z-index: 100;
    }
    
    .admin-nav ul {
        flex-direction: row;
        overflow-x: auto;
        gap: 5px;
    }
    
    .admin-nav a {
        white-space: nowrap;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .film-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .film-card-info {
        padding: 8px;
    }
    
    .film-card-title {
        font-size: 0.8rem;
    }
    
    .episode-list {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}


/* Sửa lỗi ảnh bị lặp và căn chỉnh Banner */
.hero-section {
    position: relative;
    width: 100%;
    height: 450px; /* Độ cao lý tưởng cho banner phim */
    background: #000;
    overflow: hidden;
}

.hero-slider {
    width: 100%;
    height: 100%;
}

.hero-slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    /* Ép ảnh phủ kín và không lặp lại */
    background-size: cover !important;
    background-position: center top !important;
    background-repeat: no-repeat !important;
    display: none; 
    align-items: center;
}

.hero-slide.active {
    display: flex; /* Chỉ hiện slide đang kích hoạt */
    z-index: 1;
}

/* Lớp phủ tối để đọc chữ dễ hơn */
.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    padding-left: 5%;
    max-width: 600px;
}

/* Fix vị trí các nút điều hướng < > */
.hero-controls {
    position: absolute;
    bottom: 20px;
    left: 5%;
    z-index: 10;
    display: flex;
    gap: 10px;
}
.hero-content h2 {
    font-size: 3rem;
    margin: 15px 0;
    color: var(--text-primary);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.hero-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.hero-meta span i {
    color: var(--warning-color);
}

.hero-actions {
    display: flex;
    gap: 15px;
}

.btn-lg {
    padding: 12px 30px;
    font-size: 1.1rem;
} 

/* Category Navigation Bar */
.category-nav {
    background: var(--background-card);
    padding: 15px 0;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
}

.category-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 5px;
}

/* Ẩn thanh scrollbar nhưng vẫn cho cuộn */
.category-scroll::-webkit-scrollbar {
    height: 0px;
}

.category-nav-item {
    padding: 6px 18px;
    background: var(--background-hover);
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.category-nav-item:hover, .category-nav-item.active {
    background: var(--primary-color);
    color: white;
}

/* Tối ưu Grid Phim */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--primary-color); /* Tạo điểm nhấn bên trái tiêu đề */
    padding-left: 15px;
    border-bottom: none; /* Bỏ border bottom cũ nếu muốn giống bản gốc */
}

.film-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* Ép hiển thị 5 cột trên PC */
    gap: 20px;
}

/* Responsive cho điện thoại */
@media (max-width: 768px) {
    .film-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .hero-content h2 {
        font-size: 1.8rem;
    }
}


/* --- FIX TRIỆT ĐỂ HERO SLIDER --- */
.hero-section {
    position: relative;
    width: 100%;
    height: 70vh; /* Chiều cao cố định banner */
    background: #000;
    overflow: hidden;
}

.hero-slider {
    width: 100%;
    height: 100%;
    position: relative;
}

.hero-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* FIX LỖI ẢNH LẶP TẠI ĐÂY */
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    display: none; /* Ẩn hết các slide */
    align-items: center;
    transition: opacity 0.5s ease-in-out;
}

.hero-slide.active {
    display: flex !important; /* Chỉ hiện slide có class active */
}

.hero-overlay {
    position: absolute;
    inset: 0;
    /* Đổ bóng tối bên trái để nổi bật chữ */
    background: linear-gradient(90deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.5) 50%, transparent 100%);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    padding-left: 50px;
    max-width: 800px;
}

/* Nút điều hướng < > */
.hero-controls {
    position: absolute;
    bottom: 30px;
    left: 50px;
    z-index: 10;
    display: flex;
    gap: 15px;
}

.hero-controls button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}

.hero-controls button:hover {
    background: #e50914; /* Màu đỏ primary */
    border-color: #e50914;
}

/* --- FIX FILM CARD UI --- */
.film-card {
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    border: 1px solid #333;
}

.film-card:hover {
    transform: translateY(-5px);
    border-color: #e50914;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

.film-card-poster {
    position: relative;
    display: block;
    aspect-ratio: 2/3;
    overflow: hidden;
}

.film-card-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.film-card:hover .film-card-poster img {
    transform: scale(1.1);
}

/* Badge Chất lượng (Góc trên trái) */
.film-card-quality {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 3px 8px;
    background: #e50914;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    border-radius: 4px;
    z-index: 2;
}

/* Badge Lượt xem/Rating (Góc dưới trái) */
.film-card-views {
    position: absolute;
    bottom: 10px;
    left: 10px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 11px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 2;
}

.film-card-views i {
    color: #ffad1f;
}

/* Phần thông tin chữ bên dưới */
.film-card-info {
    padding: 12px;
    background: #1a1a1a;
}

.film-card-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.film-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #b3b3b3;
}


/* --- FIX FOOTER UI --- */
.footer {
    background-color: var(--secondary-color);
    padding: 40px 0;
    margin-top: 50px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center; /* Căn giữa toàn bộ nội dung */
    text-align: center;
    gap: 15px;
}

.footer-logo img {
    height: 40px;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 5px rgba(0,0,0,0.5));
}

.footer-info p {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.footer-links a {
    font-size: 14px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--primary-color);
}

.footer-copyright {
    margin-top: 20px;
    font-size: 12px;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 20px;
    width: 100%;
}

/* =========================================
   HOMEPAGE REFRESH (ROPHIM-LIKE)
   ========================================= */
body.home-page {
    background: #0a0b11;
    color: #f5f7ff;
}

body.home-page .header {
    background: rgba(9, 10, 17, 0.92);
    border-bottom: 1px solid #212438;
    backdrop-filter: blur(10px);
}

body.home-page .main-content {
    padding-top: 0;
}

body.home-page .container {
    max-width: 1320px;
}

body.home-page .hero-section {
    height: clamp(380px, 72vh, 680px);
    border-bottom: 1px solid #23273d;
}

body.home-page .hero-slide::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(9, 10, 17, 0.15) 0%, rgba(9, 10, 17, 0.88) 88%);
    z-index: 1;
}

body.home-page .hero-overlay {
    background: linear-gradient(90deg, rgba(9, 10, 17, 0.96) 0%, rgba(9, 10, 17, 0.66) 45%, rgba(9, 10, 17, 0.2) 78%, rgba(9, 10, 17, 0.08) 100%);
}

body.home-page .hero-content {
    max-width: 620px;
    padding-left: clamp(18px, 5vw, 70px);
    padding-right: 14px;
}

body.home-page .hero-quality {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    background: #ffd44d;
    color: #18120c;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

body.home-page .hero-content h2 {
    margin: 16px 0 10px;
    font-size: clamp(1.7rem, 4.5vw, 3.2rem);
    line-height: 1.1;
}

body.home-page .hero-meta {
    gap: 14px;
    flex-wrap: wrap;
    font-size: 0.93rem;
}

body.home-page .hero-content p {
    font-size: 0.95rem;
    color: #c5c9e2;
    margin-bottom: 20px;
}

body.home-page .hero-actions .btn {
    border-radius: 999px;
    padding: 11px 22px;
    font-size: 0.95rem;
    font-weight: 600;
}

body.home-page .hero-actions .btn-secondary {
    border-color: #3a415f;
    background: rgba(17, 20, 34, 0.85);
}

body.home-page .hero-controls {
    left: auto;
    right: 24px;
    bottom: 24px;
}

body.home-page .hero-controls button {
    width: 42px;
    height: 42px;
    background: rgba(12, 14, 25, 0.72);
    border: 1px solid #3a3f5d;
}

body.home-page .hero-dots {
    position: absolute;
    left: 28px;
    bottom: 30px;
    display: flex;
    gap: 8px;
    z-index: 12;
}

body.home-page .hero-dot {
    width: 24px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.25);
    transition: all 0.25s ease;
    cursor: pointer;
}

body.home-page .hero-dot.active {
    width: 32px;
    background: #f2c94c;
}

body.home-page .category-nav {
    background: #0e101b;
    border-bottom: 1px solid #20243a;
    margin-bottom: 24px;
}

body.home-page .category-nav-item {
    border-radius: 999px;
    background: #171a2b;
    color: #d0d4ea;
    border: 1px solid transparent;
}

body.home-page .category-nav-item:hover,
body.home-page .category-nav-item.active {
    background: #242945;
    border-color: #4a527f;
    color: #fff;
}

body.home-page .section {
    margin-bottom: 36px;
}

body.home-page .section-header {
    border: 0;
    border-left: 0;
    padding: 0;
    margin-bottom: 16px;
}

body.home-page .section-title {
    font-size: 1.26rem;
    font-weight: 700;
}

body.home-page .section-link {
    color: #9ea5c7;
}

body.home-page .film-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}

body.home-page .film-card {
    border: 1px solid #262b44;
    border-radius: 10px;
    background: #101423;
}

body.home-page .film-card-poster::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 42%;
    background: linear-gradient(180deg, transparent 0%, rgba(6, 8, 16, 0.8) 100%);
}

body.home-page .film-card-quality,
body.home-page .film-card-rating,
body.home-page .film-card-views {
    z-index: 2;
    border-radius: 999px;
    font-weight: 600;
}

body.home-page .film-card-views {
    bottom: 10px;
    left: 10px;
    padding: 3px 9px;
    font-size: 0.72rem;
    background: rgba(7, 9, 19, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

body.home-page .film-card-info {
    padding: 10px 11px 12px;
}

body.home-page .film-card-title {
    margin-bottom: 3px;
    font-size: 0.89rem;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    line-height: 1.35;
}

body.home-page .film-card-meta {
    font-size: 0.76rem;
    color: #8f96b8;
}

body.home-page .film-card-original-title {
    margin-bottom: 6px;
    color: #99a1c8;
    font-size: 0.76rem;
    line-height: 1.35;
    white-space: normal;
    word-break: break-word;
}

body.home-page .category-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

body.home-page .category-card {
    background: #111529;
    border: 1px solid #282f4f;
    border-radius: 10px;
    padding: 16px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

body.home-page .category-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(229, 9, 20, 0.13);
    color: #f64955;
}

body.home-page .category-card h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

@media (max-width: 1180px) {
    body.home-page .film-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 991px) {
    body.home-page .header-wrap {
        gap: 12px;
    }

    body.home-page .main-nav ul {
        gap: 12px;
    }

    body.home-page .hero-section {
        height: 56vh;
        min-height: 420px;
    }

    body.home-page .hero-content p {
        max-width: 92%;
    }

    body.home-page .film-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 14px;
    }

    body.home-page .category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    body.home-page .hero-section {
        height: 66vh;
        min-height: 450px;
    }

    body.home-page .hero-content {
        padding-left: 16px;
        padding-right: 16px;
        margin-top: 28px;
    }

    body.home-page .hero-content p {
        margin-bottom: 16px;
        font-size: 0.88rem;
        line-clamp: 3;
        -webkit-line-clamp: 3;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    body.home-page .hero-actions {
        gap: 8px;
    }

    body.home-page .hero-actions .btn {
        padding: 10px 14px;
        font-size: 0.86rem;
    }

    body.home-page .hero-controls {
        right: 12px;
        bottom: 14px;
        gap: 8px;
    }

    body.home-page .hero-controls button {
        width: 34px;
        height: 34px;
        font-size: 0.86rem;
    }

    body.home-page .hero-dots {
        left: 14px;
        bottom: 20px;
    }

    body.home-page .section-title {
        font-size: 1.06rem;
    }

    body.home-page .section-link {
        font-size: 0.8rem;
    }

    body.home-page .film-grid,
    body.home-page .category-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 11px;
    }
}

@media (max-width: 480px) {
    body.home-page .hero-section {
        min-height: 390px;
    }

    body.home-page .hero-quality {
        font-size: 0.64rem;
        padding: 4px 8px;
    }

    body.home-page .hero-meta {
        gap: 10px;
        font-size: 0.8rem;
    }

    body.home-page .film-card-title {
        font-size: 0.8rem;
    }

    body.home-page .film-card-meta {
        font-size: 0.7rem;
    }

    body.home-page .film-card-original-title {
        font-size: 0.7rem;
    }
}

/* =========================================
   DETAIL + WATCH PAGES REFRESH
   ========================================= */
body.detail-page,
body.watch-page {
    background: #0b0d15;
}

body.detail-page .main-content,
body.watch-page .main-content {
    padding-top: 24px;
}

body.detail-page .film-detail {
    grid-template-columns: minmax(220px, 300px) 1fr;
    align-items: start;
    gap: 22px;
    margin-bottom: 24px;
}

body.detail-page .film-poster,
body.detail-page .film-info,
body.detail-page .episode-section,
body.watch-page .watch-player-shell,
body.watch-page .watch-film-info,
body.watch-page .watch-episodes,
body.watch-page .watch-description {
    background: #111422;
    border: 1px solid #252c45;
    border-radius: 12px;
}

body.detail-page .film-poster {
    padding: 0 0 14px;
}

body.detail-page .film-poster img {
    border-radius: 12px 12px 0 0;
}

body.detail-page .quality-badge {
    border-radius: 999px;
    left: 12px;
    top: 12px;
}

.film-poster-actions {
    position: static;
    transform: none;
    background: none;
    padding: 12px 12px 0;
    margin-top: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.film-poster-actions .btn {
    justify-content: center;
    border-radius: 10px;
}

.film-poster-actions .btn-favorite {
    min-width: 44px;
}

body.detail-page .film-info {
    padding: 18px;
}

body.detail-page .film-title {
    font-size: clamp(1.45rem, 2.6vw, 2.1rem);
}

body.detail-page .detail-categories {
    margin-bottom: 20px;
}

body.detail-page .film-description h4,
body.detail-page .film-cast-list h4 {
    margin-bottom: 8px;
    color: #e5e9fb;
}

body.detail-page .film-description p,
body.detail-page .film-cast-list p {
    color: #bbc2df;
    line-height: 1.75;
}

body.detail-page .episode-section {
    padding: 16px;
}

/* Watch page */
body.watch-page .watch-player-shell,
body.watch-page .watch-film-info,
body.watch-page .watch-episodes,
body.watch-page .watch-description {
    padding: 16px;
    margin-bottom: 18px;
}

body.watch-page .watch-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

body.watch-page .watch-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #c7cdeb;
}

body.watch-page .watch-meta-inline {
    display: flex;
    gap: 14px;
    color: #9ea7ce;
    font-size: 0.88rem;
}

body.watch-page .watch-meta-inline i {
    color: #f0c14a;
}

body.watch-page .player-section {
    border: 1px solid #2d3553;
}

body.watch-page .player-empty {
    width: 100%;
    height: 100%;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #bac2e3;
    padding: 20px;
}

body.watch-page .watch-server-tabs {
    margin-top: 12px;
    margin-bottom: 0;
}

body.watch-page .watch-server-tabs .server-tab {
    text-decoration: none;
}

body.watch-page .watch-film-info .film-title {
    margin-bottom: 8px;
}

body.watch-page .watch-episode-count {
    color: #9ca5cc;
    font-size: 0.9rem;
}

body.watch-page .watch-description h3 {
    margin-bottom: 10px;
    font-size: 1.08rem;
}

body.watch-page .watch-description p {
    color: #b8bfdd;
    line-height: 1.75;
}

@media (max-width: 1024px) {
    body.detail-page .film-detail {
        grid-template-columns: 260px 1fr;
    }
}

@media (max-width: 860px) {
    body.detail-page .film-detail {
        grid-template-columns: 1fr;
    }

    body.detail-page .film-poster {
        max-width: 300px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    body.detail-page .main-content,
    body.watch-page .main-content {
        padding-top: 16px;
    }

    body.watch-page .watch-topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    body.watch-page .watch-meta-inline {
        flex-wrap: wrap;
        gap: 10px;
        font-size: 0.82rem;
    }

    body.watch-page .watch-player-shell,
    body.watch-page .watch-film-info,
    body.watch-page .watch-episodes,
    body.watch-page .watch-description,
    body.detail-page .film-info,
    body.detail-page .episode-section {
        padding: 12px;
    }

    .film-poster-actions {
        padding: 10px 10px 0;
    }
}

/* =========================================
   LISTING PAGES (SEARCH/COUNTRY/YEAR)
   ========================================= */
body.listing-page {
    background: #0b0d16;
}

body.listing-page .main-content {
    padding-top: 22px;
}

body.listing-page .listing-header {
    background: #121525;
    border: 1px solid #27304b;
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 14px;
}

body.listing-page .listing-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: clamp(1.2rem, 2.6vw, 1.75rem);
}

body.listing-page .listing-title i {
    color: #f0c14a;
}

body.listing-page .listing-subtitle {
    margin-top: 8px;
    color: #aeb6d7;
    font-size: 0.93rem;
}

body.listing-page .listing-subtitle strong {
    color: #fff;
}

body.listing-page .filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-bottom: 16px;
}

body.listing-page .filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 13px;
    border-radius: 999px;
    border: 1px solid #313b5c;
    background: #151a2d;
    color: #c6cdee;
    font-size: 0.85rem;
}

body.listing-page .filter-chip span {
    color: #8d97c4;
}

body.listing-page .filter-chip:hover,
body.listing-page .filter-chip.active {
    border-color: #4f5f97;
    background: #232b47;
    color: #fff;
}

body.listing-page .listing-section-header {
    border: 0;
    padding: 0;
    margin-bottom: 14px;
}

body.listing-page .film-grid,
body.listing-page .film-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}

body.listing-page .pagination {
    margin-top: 20px;
}

@media (max-width: 1180px) {
    body.listing-page .film-grid,
    body.listing-page .film-list {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 992px) {
    body.listing-page .film-grid,
    body.listing-page .film-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }
}

@media (max-width: 768px) {
    body.listing-page .main-content {
        padding-top: 14px;
    }

    body.listing-page .listing-header {
        padding: 12px;
    }

    body.listing-page .listing-subtitle {
        font-size: 0.84rem;
    }

    body.listing-page .filter-chips {
        gap: 7px;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }

    body.listing-page .filter-chips::-webkit-scrollbar {
        height: 0;
    }

    body.listing-page .filter-chip {
        white-space: nowrap;
        padding: 6px 11px;
        font-size: 0.8rem;
    }

    body.listing-page .film-grid,
    body.listing-page .film-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
}

/* =========================================
   ADMIN LAYOUT/UI
   ========================================= */
:root {
    --admin-sidebar-width: 260px;
    --admin-header-height: 60px;
}

body.admin-layout {
    display: flex;
    min-height: 100vh;
    background: #0f0f23;
}

body.admin-layout .admin-sidebar {
    width: var(--admin-sidebar-width);
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    border-right: 1px solid rgba(255,255,255,0.08);
}

body.admin-layout .sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

body.admin-layout .sidebar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

body.admin-layout .sidebar-nav {
    padding: 18px 0;
}

body.admin-layout .nav-section {
    padding: 10px 20px 6px;
    color: rgba(255,255,255,0.45);
    font-size: 0.75rem;
    text-transform: uppercase;
}

body.admin-layout .nav-item {
    display: block;
    padding: 11px 20px;
    color: rgba(255,255,255,0.75);
    border-left: 3px solid transparent;
}

body.admin-layout .nav-item:hover,
body.admin-layout .nav-item.active {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

body.admin-layout .nav-item.active {
    border-left-color: var(--primary-color);
}

body.admin-layout .nav-item i {
    width: 22px;
    margin-right: 8px;
}

body.admin-layout .admin-main {
    margin-left: var(--admin-sidebar-width);
    flex: 1;
}

body.admin-layout .admin-topbar {
    height: var(--admin-header-height);
    background: #151a2c;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 50;
}

body.admin-layout .toggle-sidebar {
    background: none;
    border: none;
    color: rgba(255,255,255,0.75);
    font-size: 1.1rem;
    cursor: pointer;
}

body.admin-layout .user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

body.admin-layout .user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
}

body.admin-layout .user-info {
    color: #d3d8f0;
}

body.admin-layout .user-info .username {
    display: block;
    font-weight: 600;
    font-size: 0.86rem;
}

body.admin-layout .user-info .role {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
}

body.admin-layout .logout-btn {
    background: rgba(255,255,255,0.1);
    color: #fff;
    padding: 7px 12px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

body.admin-layout .admin-content-area {
    padding: 22px;
}

body.admin-layout .page-header {
    margin-bottom: 18px;
}

body.admin-layout .page-title {
    font-size: 1.45rem;
    color: #fff;
}

body.admin-layout .page-description {
    margin-top: 4px;
    color: rgba(255,255,255,0.64);
}

body.admin-layout .admin-card {
    background: #161c31;
    border: 1px solid #2a3352;
    border-radius: 12px;
}

body.admin-layout .admin-table th,
body.admin-layout .admin-table td {
    border-bottom-color: rgba(255,255,255,0.08);
}

body.admin-layout .sidebar-overlay {
    display: none;
}

@media (max-width: 768px) {
    body.admin-layout .admin-sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
    }

    body.admin-layout .admin-sidebar.open {
        transform: translateX(0);
    }

    body.admin-layout .admin-main {
        margin-left: 0;
    }

    body.admin-layout .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 99;
    }

    body.admin-layout .sidebar-overlay.active {
        display: block;
    }

    body.admin-layout .user-info {
        display: none;
    }

    body.admin-layout .admin-content-area {
        padding: 14px;
    }
}

/* =========================================
   RESPONSIVE POLISH (GLOBAL)
   ========================================= */
@media (max-width: 768px) {
    .header-wrap {
        /* reserve space for centered absolute logo */
        padding-top: 44px;
    }

    .main-nav ul {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 6px 4px 2px;
        gap: 14px;
    }

    .main-nav ul::-webkit-scrollbar {
        height: 0;
    }

    .main-nav a {
        white-space: nowrap;
    }

    .search-box {
        margin-top: 12px;
    }
}

@media (max-width: 480px) {
    .header-wrap {
        padding-top: 46px;
    }

    .search-box form {
        border-radius: 16px;
    }

    .search-box button {
        padding: 10px 16px;
    }
}

/* film grids: keep consistent across pages */
@media (max-width: 1180px) {
    .film-grid {
        gap: 16px;
    }
}

@media (max-width: 992px) {
    .film-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 14px;
    }
}

@media (max-width: 768px) {
    .film-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
}

@media (max-width: 360px) {
    .film-grid {
        gap: 10px;
    }
}

/* watch/detail: episode list touch-friendly on mobile */
@media (max-width: 768px) {
    .episode-list {
        grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
        gap: 8px;
    }

    .episode-item {
        padding: 10px 8px;
    }
}

@media (max-width: 480px) {
    .player-container {
        padding-bottom: 56.25%;
    }

    .watch-meta-inline {
        gap: 10px;
    }
}

/* Mobile/iPad/medium drawer nav (global) */
@media (max-width: 1280px) {
    .nav-toggle {
        display: inline-flex;
        order: 1;
    }

    .header-wrap {
        flex-wrap: nowrap;
        height: 60px;
        padding: 0;
        gap: 10px;
        justify-content: flex-start;
    }

    .logo { display: none; }

    /* search sits on same row with burger */
    .search-box {
        order: 2;
        flex: 1 1 auto;
        max-width: 460px;
        width: 100%;
        margin-top: 0;
    }

    .search-box form {
        border-radius: 14px;
        height: 40px;
    }

    .search-box input {
        padding: 9px 12px;
        font-size: var(--fs-sm);
        min-width: 0;
    }

    .search-box button {
        padding: 9px 14px;
        width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-overlay.is-visible {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 1200;
    }

    body.nav-open {
        overflow: hidden;
    }

    .main-nav {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: min(86vw, 320px);
        background: #0e101b;
        border-right: 1px solid #232a44;
        z-index: 1201;
        transform: translateX(-102%);
        transition: transform 0.22s ease;
        padding: 16px 14px;
        order: 2;
    }

    .main-nav.is-open {
        transform: translateX(0);
    }

    .main-nav ul {
        flex-direction: column;
        gap: 6px;
        padding: 10px 0;
        overflow: auto;
        max-height: calc(100vh - 24px);
        justify-content: flex-start;
    }

    .main-nav a {
        display: flex;
        padding: 12px 12px;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.03);
    }

    .main-nav a::after {
        display: none;
    }

    .mobile-nav-brand {
        display: block;
        padding: 6px 2px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        margin-bottom: 10px;
    }

    .mobile-nav-brand-link {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 10px;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.03);
    }

    .mobile-nav-brand-logo {
        width: 34px;
        height: 34px;
        object-fit: contain;
    }

    .mobile-nav-brand-name {
        font-weight: 700;
        color: #fff;
        font-size: 1rem;
        letter-spacing: 0.01em;
    }
}

/* Popup Shopee Styles */
#popupShopee {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 350px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #333;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#popupShopee[hidden] {
    display: none !important;
}

@keyframes popIn {
    from { opacity: 0; transform: translate(-50%, -60%) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.popup-header {
    background: #f43f5e;
    color: #fff;
    padding: 15px;
    text-align: center;
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
}

.popup-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: #fff;
}

.popup-body img {
    border-radius: 12px;
    margin-bottom: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.popup-body h5 {
    font-weight: 600;
    color: #666;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

.popup-close {
    width: 100%;
    padding: 18px;
    background: #f8f8f8;
    border: none;
    color: #f43f5e;
    font-weight: 900;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
    border-top: 1px solid #eee;
}

.popup-close:hover {
    background: #f43f5e;
    color: #fff;
}

#popupOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1999;
    backdrop-filter: blur(8px);
    animation: fadeInOverlay 0.3s ease;
}

#popupOverlay[hidden] {
    display: none !important;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 420px) {
    .search-box {
        max-width: none;
        flex: 1 1 auto;
    }
}

/* =========================================
   PREMIUM FLUID TYPOGRAPHY + SPACING
   ========================================= */
:root {
    --fs-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.85rem);
    --fs-sm: clamp(0.85rem, 0.82rem + 0.2vw, 0.98rem);
    --fs-md: clamp(0.95rem, 0.92rem + 0.25vw, 1.12rem);
    --fs-lg: clamp(1.1rem, 1.02rem + 0.55vw, 1.55rem);
    --fs-xl: clamp(1.35rem, 1.2rem + 1.1vw, 2.1rem);

    --space-2: clamp(6px, 0.6vw, 10px);
    --space-3: clamp(10px, 0.9vw, 14px);
    --space-4: clamp(14px, 1.2vw, 18px);
    --space-5: clamp(18px, 1.6vw, 24px);
}

body {
    font-size: var(--fs-md);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.section-title {
    font-size: var(--fs-lg);
}

.btn {
    font-size: var(--fs-sm);
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }
}

/* =========================================
   GRID CONSISTENCY (cards align like rophim)
   ========================================= */
.film-card-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.film-card-title a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    white-space: normal;
    line-height: 1.32;
    min-height: calc(1.32em * 2);
}

.film-card-original-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-clamp: 1;
    -webkit-line-clamp: 1;
    white-space: normal;
    line-height: 1.25;
    min-height: 1.25em;
}

.film-card-meta {
    margin-top: auto;
    gap: 10px;
}

.film-card {
    will-change: transform;
}

body.home-page .film-card-title a,
body.listing-page .film-card-title a {
    font-size: var(--fs-sm);
}

body.home-page .film-card-original-title,
body.listing-page .film-card-original-title {
    font-size: var(--fs-xs);
}

@media (max-width: 768px) {
    .film-card:hover,
    body.home-page .film-card:hover {
        transform: none;
        box-shadow: none;
    }
}