/* --- ТЕМЫ И ПЕРЕМЕННЫЕ --- */
:root {
    /* Фон и текст */
    --bg-from: #111827; /* gray-900 */
    --bg-to: #000000;
    --text-primary: #d1d5db; /* gray-300 */
    --text-strong: #ffffff;  /* белый */
    --text-muted: #9ca3af;   /* gray-400 */

    /* Стекло */
    --glass-bg: rgba(25, 28, 36, 0.5);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3), inset 0 1px 1px 0 rgba(255, 255, 255, 0.1);

    /* Панели/дропдауны */
    --panel-bg-1: rgba(25, 28, 36, 0.95);
    --panel-bg-2: rgba(40, 44, 52, 0.95);

    /* Хедер */
    --header-bg: rgba(17, 24, 39, 0.7); /* gray-900/70 */

    /* Акценты */
    --accent-1: #ec4899; /* pink-500 */
    --accent-2: #a855f7; /* violet-500 */

    /* Hover/выделения */
    --option-hover-bg: rgba(236, 72, 153, 0.2);
    --option-selected-gradient: linear-gradient(135deg, rgba(236, 72, 153, 0.3) 0%, rgba(168, 85, 247, 0.3) 100%);
}

body.theme-light {
    --bg-from: #f5f7fb;
    --bg-to: #eaeef6;
    --text-primary: #374151; /* gray-700 */
    --text-strong: #111827;  /* gray-900 */
    --text-muted: #6b7280;   /* gray-500 */

    --glass-bg: rgba(255, 255, 255, 0.55);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(31, 41, 55, 0.12), inset 0 1px 1px 0 rgba(255, 255, 255, 0.6);

    --panel-bg-1: rgba(255, 255, 255, 0.98);
    --panel-bg-2: rgba(255, 255, 255, 0.98);

    --header-bg: rgba(255, 255, 255, 0.65);

    --option-hover-bg: rgba(236, 72, 153, 0.12);
    --option-selected-gradient: linear-gradient(135deg, rgba(236, 72, 153, 0.22) 0%, rgba(168, 85, 247, 0.22) 100%);
}

/* Базовый фон и текст через переменные темы */
body {
    background-image: linear-gradient(to bottom, var(--bg-from), var(--bg-to)) !important;
    color: var(--text-primary);
}
header {
    background: var(--header-bg) !important;
}

/* Приведение основных текстовых классов под светлую тему */
.theme-light .text-white { color: var(--text-strong) !important; }
.theme-light .text-gray-300 { color: var(--text-primary) !important; }
.theme-light .text-gray-400 { color: var(--text-muted) !important; }
.theme-light .text-gray-500 { color: var(--text-muted) !important; }

/* --- ОБЩИЕ СТИЛИ --- */
* { transition: all 0.2s ease-in-out; }
.loader { width: 48px; height: 48px; border: 5px solid #FFF; border-bottom-color: var(--accent-1); border-radius: 50%; display: inline-block; box-sizing: border-box; animation: rotation 1s linear infinite; }
@keyframes rotation { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.movie-card:hover .poster-overlay { opacity: 1; }
.movie-card:hover img { transform: scale(1.05); }
#filters-modal.hidden { display: none; }

/* --- НОВЫЕ СТИЛИ GLASSMORPHISM --- */
.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: blur(8px) saturate(1.1);
    -webkit-backdrop-filter: blur(8px) saturate(1.1);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.glass-highlight {
    position: relative;
    overflow: hidden;
}

.glass-highlight::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    animation: shine-horizontal 4s infinite linear;
}

.glass-highlight::after {
    content: '';
    position: absolute;
    top: -100%;
    left: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    animation: shine-vertical 4s infinite linear;
    animation-delay: 2s;
}

@keyframes shine-horizontal { 0% { left: -100%; } 100% { left: 100%; } }
@keyframes shine-vertical { 0% { top: -100%; } 100% { top: 100%; } }

/* --- КАСТОМНЫЕ СЕЛЕКТЫ GLASSMORPHISM --- */
.custom-select {
    position: relative;
    cursor: pointer;
}

.custom-select-trigger {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.08) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow:
        0 8px 32px 0 rgba(0, 0, 0, 0.2),
        inset 0 2px 4px 0 rgba(255, 255, 255, 0.1),
        inset 0 -2px 4px 0 rgba(0, 0, 0, 0.2);
    padding: 12px 40px 12px 16px;
    border-radius: 12px;
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-select-trigger::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(236, 72, 153, 0.3), transparent);
    transition: left 0.5s ease;
}

.custom-select:hover .custom-select-trigger::before { left: 100%; }
.custom-select-trigger:hover {
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow:
        0 12px 48px 0 rgba(0, 0, 0, 0.3),
        inset 0 2px 4px 0 rgba(255, 255, 255, 0.15),
        0 0 20px rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}
.custom-select.active .custom-select-trigger {
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow:
        0 12px 48px 0 rgba(0, 0, 0, 0.35),
        inset 0 2px 4px 0 rgba(255, 255, 255, 0.2),
        0 0 30px rgba(255, 255, 255, 0.15);
}

.custom-select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s ease;
    color: rgba(255, 255, 255, 0.6);
}
.theme-light .custom-select-arrow { color: rgba(17, 24, 39, 0.6); }

.custom-select.active .custom-select-arrow { transform: translateY(-50%) rotate(180deg); }

.custom-select-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--panel-bg-1) 0%, var(--panel-bg-2) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    box-shadow:
        0 20px 60px 0 rgba(0, 0, 0, 0.5),
        inset 0 1px 1px 0 rgba(255, 255, 255, 0.1);
}

.custom-select.active .custom-select-options {
    max-height: 300px;
    opacity: 1;
    overflow-y: auto;
}

.custom-select-option {
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}
.theme-light .custom-select-option { color: rgba(17, 24, 39, 0.8); }

.custom-select-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(236, 72, 153, 0.2), transparent);
    transition: left 0.3s ease;
}

.custom-select-option:hover {
    background: var(--option-hover-bg);
    color: var(--text-strong);
    padding-left: 24px;
}

.custom-select-option:hover::before { left: 100%; }

.custom-select-option.selected {
    background: var(--option-selected-gradient);
    color: #fff;
    font-weight: 600;
    padding-left: 24px;
}
.theme-light .custom-select-option.selected { color: var(--text-strong); }

.custom-select-option.selected::after {
    content: '✓';
    position: absolute;
    left: 8px;
    color: var(--accent-1);
}

/* Скроллбар для опций */
.custom-select-options::-webkit-scrollbar { width: 6px; }
.custom-select-options::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 3px; }
.custom-select-options::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.5) 0%, rgba(168, 85, 247, 0.5) 100%);
    border-radius: 3px;
}
.custom-select-options::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.7) 0%, rgba(168, 85, 247, 0.7) 100%);
}

/* Анимация пульсации для заголовков */
.filter-title {
    font-weight: 600;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent-1) 0%, var(--accent-2) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(236, 72, 153, 0.5);
    animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow { 0%, 100% { opacity: 1; } 50% { opacity: 0.8; } }

/* --- СТИЛИ ДЛЯ АКТИВНЫХ/ОСНОВНЫХ КНОПОК --- */
.filter-btn.active, .translation-btn.active {
    background-color: rgba(236, 72, 153, 0.5);
    border-color: var(--accent-1);
    color: white;
}

.btn-primary {
    background-color: rgba(236, 72, 153, 0.6);
    border: 1px solid var(--accent-1);
}
.btn-primary:hover { background-color: rgba(236, 72, 153, 0.8); }

/* Скрываем нативные селекты */
.hidden-select {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.filter-btn-background {
    background: transparent;
    border: 1px solid var(--glass-border);
}
.filter-btn-background:hover { background: rgba(255, 255, 255, 0.1); }
.theme-light .filter-btn-background:hover { background: rgba(0,0,0,0.05); }

/* --- LIQUID GLASS ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ --- */
.glass-switch {
    width: 72px;
    height: 38px;
    border-radius: 9999px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    position: relative;
    cursor: pointer;
    box-shadow: var(--glass-shadow);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow .3s ease;
    overflow: hidden;
}
.glass-switch::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(120deg, transparent, rgba(255,255,255,0.35), transparent);
    transform: translateX(-100%);
    animation: switchShimmer 5s linear infinite;
    border-radius: inherit;
    pointer-events: none;
}
@keyframes switchShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
.glass-switch .knob {
    position: absolute;
    top: 4px; left: 4px;
    width: 30px; height: 30px;
    border-radius: 9999px;
    background:
        radial-gradient(120px 120px at 30% 30%, rgba(255,255,255,0.7), rgba(255,255,255,0.15)),
        rgba(255,255,255,0.35);
    border: 1px solid rgba(255,255,255,0.45);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -2px 4px rgba(0,0,0,0.15);
    backdrop-filter: blur(6px) saturate(1.2);
    -webkit-backdrop-filter: blur(6px) saturate(1.2);
    transition: left 0.35s cubic-bezier(.4,0,.2,1), background 0.3s ease;
}
.glass-switch .icon {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px;
    color: rgba(255,255,255,0.9);
    transition: opacity .25s ease, color .25s ease;
    pointer-events: none;
}
.glass-switch .icon.sun { left: 10px; }
.glass-switch .icon.moon { right: 10px; }
.glass-switch.active { box-shadow: 0 8px 32px rgba(236, 72, 153, 0.22), inset 0 1px 1px rgba(255, 255, 255, 0.4); }
.glass-switch.active .knob { left: calc(100% - 34px); }
.theme-light .glass-switch .icon { color: rgba(17, 24, 39, 0.9); }

/* Мелкие доработки контраста для светлой темы */
.theme-light .poster-overlay { background-color: rgba(0,0,0,0.35); }
.theme-light #pagination-controls button:hover { background: rgba(0,0,0,0.06); }