:root {
    --bg-primary: #0f0f11;
    --bg-secondary: #141418;
    --bg-card: #1a1a1f;
    --bg-card-hover: #1e1e24;
    --bg-surface: #22222a;
    --text-primary: #f1f1f3;
    --text-secondary: #a0a0a8;
    --text-muted: #6b6b75;
    --accent: #f0a500;
    --accent-glow: #ffbb33;
    --accent-dim: rgba(240, 165, 0, 0.15);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
}

/* ── Light Theme ──────────────────────────────────────────────── */
:root.light,
[data-bs-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f3f5;
    --bg-surface: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --accent: #e69500;
    --accent-glow: #f0a500;
    --accent-dim: rgba(240, 165, 0, 0.1);
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-medium: rgba(0, 0, 0, 0.12);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.1);
}

/* ── Accessibility: reduced motion ──────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Light override for specific elements that need special treatment */
:root.light .navbar,
[data-bs-theme="light"] .navbar {
    background: rgba(255, 255, 255, 0.94) !important;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

:root.light .navbar-brand,
[data-bs-theme="light"] .navbar-brand {
    color: var(--text-primary) !important;
}

:root.light footer,
[data-bs-theme="light"] footer {
    background: var(--bg-secondary) !important;
    border-top: 1px solid var(--border-subtle) !important;
}

:root.light .hero-banner,
[data-bs-theme="light"] .hero-banner {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 50%, #fff8e7 100%);
}

:root.light .hero-content h1,
[data-bs-theme="light"] .hero-content h1 {
    color: #212529;
}

:root.light .hero-content .hero-subtitle,
[data-bs-theme="light"] .hero-content .hero-subtitle {
    color: #6c757d;
}

:root.light .form-control,
[data-bs-theme="light"] .form-control {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.15);
    color: #212529;
}

:root.light .form-control:focus,
[data-bs-theme="light"] .form-control:focus {
    background: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(240, 165, 0, 0.25);
}

:root.light .form-select,
[data-bs-theme="light"] .form-select {
    background-color: #ffffff;
    border-color: rgba(0, 0, 0, 0.15);
    color: #212529;
}

:root.light .progress,
[data-bs-theme="light"] .progress {
    background: #e9ecef;
}

:root.light .table,
[data-bs-theme="light"] .table {
    --bs-table-striped-bg: rgba(0, 0, 0, 0.02);
}

:root.light .alert-success,
[data-bs-theme="light"] .alert-success {
    background: rgba(25, 135, 84, 0.08);
    border-color: rgba(25, 135, 84, 0.2);
    color: #0f5132;
}

:root.light .alert-warning,
[data-bs-theme="light"] .alert-warning {
    background: rgba(255, 193, 7, 0.08);
    border-color: rgba(255, 193, 7, 0.3);
    color: #664d03;
}

:root.light .alert-info,
[data-bs-theme="light"] .alert-info {
    background: rgba(13, 202, 240, 0.08);
    color: #055160;
}

:root.light .alert-danger,
[data-bs-theme="light"] .alert-danger {
    background: rgba(220, 53, 69, 0.08);
    color: #842029;
}

:root.light .btn-warning,
[data-bs-theme="light"] .btn-warning {
    --bs-btn-color: #000;
}

:root.light .btn-outline-dark,
[data-bs-theme="light"] .btn-outline-dark {
    --bs-btn-color: #495057;
    --bs-btn-border-color: #ced4da;
    --bs-btn-hover-bg: #e9ecef;
    --bs-btn-hover-border-color: #6c757d;
}

:root.light .list-group-item,
[data-bs-theme="light"] .list-group-item {
    color: #212529;
    border-color: rgba(0, 0, 0, 0.08);
}

:root.light .list-group-item-action:hover,
[data-bs-theme="light"] .list-group-item-action:hover {
    background: #f1f3f5 !important;
}

:root.light .episode-list-item.active,
[data-bs-theme="light"] .episode-list-item.active {
    background: rgba(240, 165, 0, 0.1) !important;
    border-left: 3px solid var(--accent) !important;
    color: var(--accent) !important;
}

:root.light .navbar .dropdown-menu,
[data-bs-theme="light"] .navbar .dropdown-menu {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

:root.light .navbar .dropdown-item,
[data-bs-theme="light"] .navbar .dropdown-item {
    color: #212529;
}

:root.light .navbar .dropdown-item:hover,
[data-bs-theme="light"] .navbar .dropdown-item:hover {
    background: #f1f3f5;
    color: var(--accent);
}

:root.light .navbar .dropdown-divider,
[data-bs-theme="light"] .navbar .dropdown-divider {
    border-color: rgba(0, 0, 0, 0.08);
}

:root.light .pagination .page-link,
[data-bs-theme="light"] .pagination .page-link {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.12);
    color: #212529;
}

:root.light .pagination .page-link:hover,
[data-bs-theme="light"] .pagination .page-link:hover {
    background: #f1f3f5;
}

/* ── Theme Toggle Button ─────────────────────────────────────── */
#themeToggle {
    background: transparent;
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    font-size: 1rem;
}

#themeToggle:hover {
    color: var(--accent);
    border-color: var(--accent);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ============================
   NAVBAR
   ============================ */
.navbar {
    background: rgba(15, 15, 17, 0.92) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
}

.navbar-brand {
    font-size: 1.4rem;
    letter-spacing: -0.5px;
    color: var(--text-primary) !important;
    font-weight: 800;
}

.navbar-brand i {
    color: var(--accent);
}

.navbar .nav-link {
    color: var(--text-secondary) !important;
    font-weight: 500;
    transition: color 0.15s ease;
    font-size: 0.9rem;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus {
    color: var(--accent) !important;
}

.navbar .nav-link.text-warning {
    color: var(--accent) !important;
}

.navbar .dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    box-shadow: var(--shadow-md);
}

.navbar .dropdown-item {
    color: var(--text-primary);
}

.navbar .dropdown-item:hover {
    background: var(--bg-surface);
    color: var(--accent);
}

.navbar .dropdown-divider {
    border-color: var(--border-subtle);
}

/* ============================
   CARDS
   ============================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-medium);
}

.card-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.card-body {
    color: var(--text-primary);
}

.card-title {
    color: var(--text-primary);
}

.text-muted {
    color: var(--text-secondary) !important;
}

/* ============================
   SKELETON / SHIMMER
   ============================ */
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.shimmer-bg {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-surface) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}
:root.light .shimmer-bg,
[data-bs-theme="light"] .shimmer-bg {
    background: linear-gradient(90deg, #e9ecef 25%, #f1f3f5 50%, #e9ecef 75%);
    background-size: 200% 100%;
}

/* ============================
   SERIES COVERS
   ============================ */
.series-cover {
    display: block;
    width: 100%;
    aspect-ratio: 9/16;
    object-fit: cover;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: transform 0.3s ease;
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-surface) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}
.series-cover[src] { animation: none; }

.card:hover .series-cover {
    transform: scale(1.03);
}

.series-cover-placeholder {
    display: block;
    width: 100%;
    aspect-ratio: 9/16;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: 2.5rem;
    position: relative;
    overflow: hidden;
}

.series-cover-placeholder::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(240, 165, 0, 0.15));
}

/* ============================
   BUTTONS
   ============================ */
.btn-warning {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-color: #0f0f11;
    --bs-btn-hover-bg: var(--accent-glow);
    --bs-btn-hover-border-color: var(--accent-glow);
    --bs-btn-hover-color: #0f0f11;
    --bs-btn-active-bg: var(--accent-glow);
    --bs-btn-active-border-color: var(--accent-glow);
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.btn-warning:hover {
    box-shadow: 0 4px 16px rgba(240, 165, 0, 0.3);
}

.btn-outline-dark {
    --bs-btn-color: var(--text-primary);
    --bs-btn-border-color: var(--border-medium);
    --bs-btn-hover-bg: var(--bg-surface);
    --bs-btn-hover-border-color: var(--text-secondary);
    --bs-btn-active-bg: var(--bg-surface);
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.btn-outline-warning {
    --bs-btn-color: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent);
    --bs-btn-hover-border-color: var(--accent);
    --bs-btn-hover-color: #0f0f11;
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.btn-outline-secondary {
    --bs-btn-color: var(--text-secondary);
    --bs-btn-border-color: var(--border-medium);
    --bs-btn-hover-bg: var(--bg-surface);
    --bs-btn-hover-border-color: var(--text-secondary);
    --bs-btn-hover-color: var(--text-primary);
}

.btn-outline-danger {
    --bs-btn-color: #dc3545;
    --bs-btn-border-color: rgba(220, 53, 69, 0.4);
    --bs-btn-hover-bg: #dc3545;
    --bs-btn-hover-border-color: #dc3545;
    --bs-btn-hover-color: #fff;
}

/* ============================
   HERO BANNER
   ============================ */
.hero-banner {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: linear-gradient(135deg, #1a1a2e 0%, #0f0f23 50%, #1a1020 100%);
    min-height: 380px;
    display: flex;
    align-items: center;
    margin-bottom: 2.5rem;
}

.hero-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 70%;
    height: 200%;
    background: radial-gradient(ellipse, rgba(240, 165, 0, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    padding: 3rem;
    max-width: 550px;
}

.hero-content h1 {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.1;
    margin-bottom: 1rem;
}

.hero-content .hero-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

/* ============================
   SERIES ROW (horizontal scroll)
   ============================ */
.series-row-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.series-row-title i {
    color: var(--accent);
}

/* ============================
   EPISODE LIST
   ============================ */
.episode-list-item {
    transition: all 0.15s ease;
    border-radius: var(--radius-sm);
    border: none !important;
    background: transparent !important;
    color: var(--text-primary);
}

.episode-list-item:hover {
    background: var(--bg-surface) !important;
}

.episode-list-item.active {
    background: var(--accent-dim) !important;
    border-left: 3px solid var(--accent) !important;
    color: var(--accent) !important;
}

.episode-list-item .text-muted {
    color: var(--text-muted) !important;
}

/* ============================
   VIDEO PLAYER
   ============================ */
.video-player-wrapper {
    background: #000000;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

/* Theater mode */
body.theater-mode {
    background: #000000 !important;
}

body.theater-mode .navbar,
body.theater-mode footer,
body.theater-mode .breadcrumb {
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

body.theater-mode .navbar:hover,
body.theater-mode footer:hover {
    opacity: 1;
}

body.theater-mode .video-player-wrapper {
    border-radius: 0;
    box-shadow: none;
    max-width: 100vw;
}

/* ============================
   PLAYBACK SPEED BUTTONS
   ============================ */
.speed-group .speed-btn {
    background: transparent;
    border-color: var(--border-medium);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
}

.speed-group .speed-btn:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.speed-group .speed-btn.active {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #0f0f11;
    font-weight: 600;
}

/* ============================
   KEYBOARD HINT
   ============================ */
kbd {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 0.7rem;
    font-family: inherit;
    color: var(--text-secondary);
}

/* ============================
   TABLES
   ============================ */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-border-color: var(--border-subtle);
    margin-bottom: 0;
}

.table thead th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-medium);
}

/* ============================
   BREADCRUMB
   ============================ */
.breadcrumb {
    --bs-breadcrumb-divider-color: var(--text-muted);
}

.breadcrumb-item a {
    color: var(--text-secondary);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--accent);
}

.breadcrumb-item.active {
    color: var(--text-primary);
}

/* ============================
   FOOTER
   ============================ */
footer {
    background: var(--bg-secondary) !important;
    color: var(--text-muted) !important;
    border-top: 1px solid var(--border-subtle) !important;
}

/* ============================
   BADGES
   ============================ */
.badge.bg-warning {
    background: var(--accent) !important;
    color: #0f0f11;
    font-weight: 600;
}

.badge.bg-success {
    background: #198754 !important;
}

.badge.bg-secondary {
    background: var(--bg-surface) !important;
    color: var(--text-secondary);
}

.badge.fs-6 {
    font-size: 0.85rem !important;
    padding: 0.35rem 0.65rem;
}

/* ============================
   ALERTS
   ============================ */
.alert {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.alert-success {
    background: rgba(25, 135, 84, 0.15);
    border-color: rgba(25, 135, 84, 0.3);
    color: #75b798;
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    border-color: rgba(255, 193, 7, 0.2);
    color: #ffda6a;
}

.alert-info {
    background: rgba(13, 202, 240, 0.1);
    border-color: rgba(13, 202, 240, 0.2);
    color: #6edff6;
}

.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    border-color: rgba(220, 53, 69, 0.2);
    color: #ea868f;
}

/* ============================
   FORMS
   ============================ */
.form-control {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}

.form-control:focus {
    background: var(--bg-surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(240, 165, 0, 0.2);
    color: var(--text-primary);
}

/* ============================
   KEYBOARD FOCUS VISIBILITY
   ============================ */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}
.card a:focus-visible {
    outline-offset: -2px;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-select {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}

.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(240, 165, 0, 0.2);
}

.form-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
}

textarea.form-control {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ============================
   LIST GROUP
   ============================ */
.list-group-item {
    background: transparent;
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

.list-group-item-action:hover {
    background: var(--bg-surface) !important;
}

/* ============================
   PROGRESS
   ============================ */
.progress {
    background: var(--bg-surface);
    border-radius: 1rem;
}

.progress-bar {
    background: var(--accent);
    border-radius: 1rem;
}

/* ============================
   TOAST
   ============================ */
.toast-container {
    z-index: 1080;
}

.toast {
    animation: toast-slide-in 0.3s ease-out;
    border-radius: var(--radius-sm);
}

.text-bg-success { background-color: #198754 !important; }
.text-bg-error, .text-bg-danger { background-color: #dc3545 !important; }
.text-bg-warning { background-color: #e6a100 !important; }
.text-bg-info { background-color: #0d6efd !important; }

@keyframes toast-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-slide-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast.hiding {
    animation: toast-slide-out 0.3s ease forwards;
}

/* ============================
   PAGINATION
   ============================ */
.pagination .page-link {
    background: var(--bg-card);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

.pagination .page-link:hover {
    background: var(--bg-surface);
    border-color: var(--accent);
    color: var(--accent);
}

.pagination .active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #0f0f11;
}

/* ============================
   MOBILE
   ============================ */
@media (max-width: 767.98px) {
    .series-cover,
    .series-cover-placeholder {
        aspect-ratio: 9/16;
    }
    .navbar-brand {
        font-size: 1.1rem;
    }
    .hero-banner {
        min-height: 280px;
    }
    .hero-content {
        padding: 1.5rem;
    }
    .hero-content h1 {
        font-size: 1.8rem;
    }
}

/* ============================
   MOBILE BOTTOM NAVIGATION
   ============================ */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-subtle);
    padding: 0.4rem 0 env(safe-area-inset-bottom, 0.4rem);
    z-index: 1030;
    height: 56px;
}
.bottom-nav-item {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    transition: color 0.2s ease;
}
.bottom-nav-item i {
    font-size: 1.2rem;
}
.bottom-nav-item.active,
.bottom-nav-item:hover {
    color: var(--accent);
}
/* Push content up so bottom nav doesn't overlap */
body.has-bottom-nav {
    padding-bottom: 60px;
}
