/* =========================================================
   1. КАТАЛОГ, КАРТОЧКИ ФИЛЬМОВ И ФИЛЬТРЫ
   ========================================================= */

main {
    display: block;
}
.section-title {
    margin-bottom: 20px;
    font-size: 20px;
    border-left: 4px solid #3b82f6;
    padding-left: 10px;
}

/* --- Быстрые переключатели типов (Чипсы) --- */
.type-pills-container {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 14px;
    scrollbar-width: none;
}

.type-pills-container::-webkit-scrollbar {
    display: none;
}

.type-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #1e293b;
    color: #94a3b8;
    border: 1px solid #334155;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.type-pill:hover {
    background: #334155;
    color: #f8fafc;
}

.type-pill.active {
    background: #38bdf8;
    color: #0f172a;
    border-color: #38bdf8;
    font-weight: 600;
}

.pill-icon {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    flex-shrink: 0;
}

/* --- Мобильная кнопка раскрытия фильтра --- */
.filter-wrapper {
    margin-bottom: 20px;
}

.mobile-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid #334155;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mobile-filter-toggle:hover {
    background: #334155;
    border-color: #475569;
}

.filter-badge {
    background: #e11d48;
    color: #ffffff;
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
}

/* --- Форма фильтров --- */
.catalog-filter {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 16px 20px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.label-icon {
    width: 13px;
    height: 13px;
    stroke: #38bdf8;
    flex-shrink: 0;
}

/* --- Стилизованный выпадающий список (select) --- */
.filter-select {
    width: 100%;
    background-color: #0f172a;
    color: #f8fafc;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 8px 30px 8px 10px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.2s;
}

.filter-select:focus,
.filter-select.has-value {
    border-color: #38bdf8;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2338bdf8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

/* --- Кнопка сброса --- */
.btn-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    background: #334155;
    color: #f8fafc;
    border: 1px solid #475569;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-reset:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
}

.btn-reset .label-icon {
    stroke: currentColor;
}

/* --- Сетка карточек фильмов --- */
.movies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

.movie-card {
    background: #1e293b;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #334155;
    transition: transform 0.2s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.movie-card:hover {
    transform: translateY(-5px);
}

.movie-card img {
    width: 100%;
    height: 260px;
    object-fit: cover;
}

.movie-info {
    padding: 12px;
    min-width: 0;
}

.movie-title {
    font-size: 15px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.movie-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 12px;
    color: #f1f2f4;
    min-width: 0;
    gap: 4px;
}

.rating {
    color: #f59e0b;
    font-weight: bold;
    flex-shrink: 0;
}

.badge-quality {
    display: inline-block;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.history-card-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
}

.remove-item-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 10;
    background: rgba(15, 23, 42, 0.85);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.4);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.remove-item-btn:hover {
    background: #ef4444;
    color: #ffffff;
    transform: scale(1.1);
}

/* =========================================================
   2. СТИЛИ ДЛЯ ИСПРАВЛЕНИЯ БЕЛОЙ ПОЛОСЫ ПРОКРУТКИ СЛАЙДЕРА
   ========================================================= */

/* Тонкий красивый скроллбар для Firefox */
.featured-slider {
    scrollbar-width: thin;
    scrollbar-color: #334155 #0f172a;
    -webkit-overflow-scrolling: touch;
}

/* Красивая темная полоса прокрутки для Chrome / Safari / Edge */
.featured-slider::-webkit-scrollbar {
    height: 6px;
}

.featured-slider::-webkit-scrollbar-track {
    background: #0f172a;
    border-radius: 10px;
}

.featured-slider::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 10px;
}

.featured-slider::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Эффект курсора-руки для перетаскивания мышкой на ПК */
.featured-slider.active {
    cursor: grabbing;
    cursor: -webkit-grabbing;
    user-select: none;
}

/* =========================================================
   3. СТИЛИ КНОПКИ "ПОКАЗАТЬ ЕЩЁ"
   ========================================================= */
.btn-load-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #1e293b;
    color: #38bdf8;
    border: 1px solid #3b82f6;
    padding: 12px 32px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-load-more:hover {
    background: #3b82f6;
    color: #ffffff;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    transform: translateY(-2px);
}

.btn-load-more:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Крутящийся спиннер загрузки */
.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =========================================================
   4. ИСПРАВЛЕНИЕ АДАПТИВА КАРТОЧЕК НА МОБИЛЬНЫХ (до 768px)
   ========================================================= */
.movie-card {
    min-width: 0; /* Обязательно для срабатывания text-overflow: ellipsis в CSS Grid */
}

.movie-card img {
    width: 100%;
    aspect-ratio: 2 / 3; /* Автоматические правильные пропорции постеров */
    height: auto !important;
    object-fit: cover;
}

.movie-info {
    min-width: 0;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.movie-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.movie-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    min-width: 0;
    width: 100%;
}

.movie-meta > span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Ограничиваем длинные теги качества (WEB-DLRip, WEBRip и т.д.) */
.movie-meta > * {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================================================
   5. АДАПТИВНОСТЬ ДЛЯ ГЛАВНОЙ СТРАНИЦЫ (MEDIA QUERIES)
   ========================================================= */

/* SMART TV И БОЛЬШИЕ ЭКРАНЫ (от 1600px) */
@media (min-width: 1600px) {
    .movies-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 25px;
    }

    .movie-card img {
        height: 320px;
    }
}

/* ДЕСКТОП И ПК (от 769px) */
@media (min-width: 769px) {
    .mobile-filter-toggle {
        display: none;
    }

    .catalog-filter.filter-collapsed {
        display: block !important;
    }
}

/* ПЛАНШЕТЫ И НОУТБУКИ (до 1024px) */
@media (max-width: 1024px) {
    .movies-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
}

/* СМАРТФОНЫ И МОБИЛЬНЫЕ УСТРОЙСТВА (до 768px) */
@media (max-width: 768px) {
    .mobile-filter-toggle {
        display: inline-flex;
    }

    .catalog-filter.filter-collapsed {
        display: none;
    }

    .filter-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .filter-actions {
        grid-column: span 2;
    }

    .movies-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .movie-card img {
        height: 220px;
    }
}

/* КОМПАКТНЫЕ СМАРТФОНЫ (до 480px) */
@media (max-width: 480px) {
    .movies-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        width: 100% !important;
    }

    .movie-card img {
        height: 190px;
    }

    .movie-title {
        font-size: 12px;
    }

    .movie-meta {
        font-size: 10px;
    }

    .badge-quality {
        max-width: 50px;
    }
}

/* =========================================================
   КНОПКАИЗБРАННОГО (СЕРДЕЧКО) НА КАРТОЧКАХ ФИЛЬМОВ
   ========================================================= */

/* Делаем позиционирование относительным для всей карточки */
.movie-card {
    position: relative !important;
}

/* Кнопка сердечка поверх постера */
.btn-bookmark {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.btn-bookmark:hover {
    background: rgba(15, 23, 42, 0.95);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.5);
    transform: scale(1.12);
}

.btn-bookmark:active {
    transform: scale(0.95);
}

/* SVG иконка */
.btn-bookmark-icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    transition: all 0.2s ease;
}

/* Состояние "В избранном" (Активное красное сердечко) */
.btn-bookmark.active {
    color: #ef4444;
    background: rgba(15, 23, 42, 0.9);
    border-color: rgba(239, 68, 68, 0.6);
}

.btn-bookmark.active .btn-bookmark-icon {
    fill: #ef4444;
    stroke: #ef4444;
}

/* Адаптив для маленьких экранов */
@media (max-width: 480px) {
    .btn-bookmark {
        width: 30px;
        height: 30px;
        top: 6px;
        right: 6px;
    }
    
    .btn-bookmark-icon {
        width: 16px;
        height: 16px;
    }
}
/* =========================================================
   6. ОПТИМИЗАЦИЯ СДВИГОВ МАКЕТА (FIX CLS < 0.1)
   ========================================================= */

/* 1. Зарезервированное место под рекламу (чтобы баннеры не сдвигали контент) */
.ad-block {
    min-height: 90px;
    background: rgba(30, 41, 59, 0.25);
    border-radius: 8px;
    contain: layout style;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 2. Запрет сдвига страницы при загрузке сетки фильмов */
.movies-grid {
    min-height: 800px; /* Занимает место заранее, пока идет AJAX-запрос */
}

/* 3. Фиксированные пропорции постеров до момента их полной загрузки */
.movie-card img {
    width: 100%;
    aspect-ratio: 2 / 3 !important;
    height: auto !important;
    object-fit: cover;
    background-color: #0f172a; /* Темный фон-заглушка */
}

/* 4. Зарезервированное место под слайдер рекомендаций */
#featuredSliderContainer {
    min-height: 260px;
    contain: layout;
}

/* 5. Предотвращение сдвига текста при загрузке системных и веб-шрифтов */
html, body {
    font-display: swap;
}


