:root {
    --sidebar-bg: #1e1e24;
    --sidebar-text: #e0e0e0;
    --main-bg: #121212;
    --accent: #3a86ff;
    --accent-hover: #2667cc;
    --item-hover: #2b2b36;
    --text-muted: #a0a0a0;
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--main-bg);
    color: #fff;
    /* На десктопе скрываем скролл страницы, так как скроллят блоки внутри */
    height: 100vh;
    overflow: hidden; 
}

/* --- ОБЩАЯ СТРУКТУРА --- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Утилита скрытия */
.hidden { display: none !important; }

/* --- САЙДБАР (ЛЕВАЯ КОЛОНКА) --- */
.sidebar {
    width: 320px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Прижимает футер к низу */
    border-right: 1px solid #333;
    flex-shrink: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 15px;
    background-color: rgba(30, 30, 36, 0.95);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 2;
    /* Липкая шапка на десктопе */
    position: sticky;
    top: 0;
}

/* Логотип */
.brand {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: #fff;
    letter-spacing: 0.5px;
}
#brand-link { text-decoration: none; display: block; }

/* Поиск и фильтры */
.search-box input {
    width: 100%;
    padding: 10px;
    background: #2b2b36;
    border: 1px solid #444;
    border-radius: 6px;
    color: #fff;
    box-sizing: border-box;
    outline: none;
}
.search-box input:focus { border-color: var(--accent); }

.filters-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.btn-icon {
    background: none;
    border: 1px solid #444;
    color: var(--text-muted);
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.fav-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}
.fav-label input { margin: 0; }

.category-dropdown {
    margin-top: 10px;
    background: #2b2b36;
    border-radius: 6px;
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    max-height: 200px;
    overflow-y: auto;
}
.category-dropdown.hidden { display: none; }
.cat-item { font-size: 0.8rem; color: #ccc; cursor: pointer; }

/* СПИСОК КАНАЛОВ (Скролл внутри области) */
.channels-scroll-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    min-height: 0; /* Важно для Firefox/Flex */
}
/* Скроллбар */
.channels-scroll-area::-webkit-scrollbar { width: 6px; }
.channels-scroll-area::-webkit-scrollbar-track { background: var(--sidebar-bg); }
.channels-scroll-area::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* Карточка канала */
.channel-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 5px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;

    /* --- ВАЖНЫЕ ИСПРАВЛЕНИЯ ДЛЯ ССЫЛКИ (<A>) --- */
    text-decoration: none;      /* Убираем подчеркивание */
    color: inherit;             /* Убираем синий цвет ссылки, наследуем от родителя */
    width: 100%;                /* Растягиваем ссылку на всю ширину (важно для тега A) */
    box-sizing: border-box;     /* Чтобы padding не ломал ширину */
    position: relative;         /* Для позиционирования внутренних элементов */
}

.channel-item:hover {
    background-color: var(--item-hover);
    text-decoration: none;      /* Гарантируем отсутствие подчеркивания при наведении */
}

.channel-item.active {
    background-color: rgba(58, 134, 255, 0.15);
    border-color: var(--accent);
}

.channel-item img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: contain;
    background: #fff;
    padding: 2px;
    flex-shrink: 0; /* Запрещаем логотипу сжиматься */
}

.channel-info {
    flex-grow: 1;
    overflow: hidden;
    /* Убедимся, что тексты внутри выравниваются правильно */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Явно задаем цвета для текстов, чтобы ссылка их не перекрашивала */
.channel-name {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    color: #fff !important; /* !important перебьет любой стиль браузера для ссылок */
    line-height: 1.2;
}

.current-program {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
    line-height: 1.2;
}

/* Кнопка "Избранное" */
.fav-toggle {
    padding: 8px; /* Чуть увеличим область клика */
    color: #444;
    transition: color 0.2s;
    z-index: 5;
    position: relative; /* Чтобы кнопка была выше ссылки */
}
.fav-toggle:hover {
    color: #fff;
}
.fav-toggle.is-favorite {
    color: #ffd700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

/* ФУТЕР САЙДБАРА */
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #333;
    background: #1e1e24;
    text-align: center;
    flex-shrink: 0; /* Не сжимать */
}
.sidebar-footer a {
    color: #777; text-decoration: none; font-size: 0.85rem;
}
.sidebar-footer a:hover { color: var(--accent); }

/* --- ОСНОВНОЙ КОНТЕНТ (ПРАВАЯ КОЛОНКА) --- */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: #0f0f13;
}

.player-container {
    width: 100%;
    background: #000;
    max-height: 80vh; 
    flex-shrink: 0;
}
#tv-player { width: 100%; height: auto; max-height: 80vh; display: block; margin: 0 auto; object-fit: contain; background-color: #000;}

/* Индикатор загрузки на плеере */
#tv-player.is-loading {
    opacity: 0.5; /* Затемняем */
    pointer-events: none;
}

/* Контейнер плеера должен быть relative, чтобы разместить спиннер */
.player-container {
    position: relative;
    background: #000; /* Черный фон, когда видео выключено */
}

/* Рисуем крутилку (спиннер) через псевдоэлемент, когда есть класс .is-loading */
#tv-player.is-loading + .loading-spinner, /* Если вы добавите отдельный div */
#tv-player.is-loading::after { /* Этот вариант может не работать на самом теге video в некоторых браузерах, лучше добавить спиннер отдельно */
    content: '';
}

/* Лучший способ: добавить этот CSS для спиннера поверх видео */
.player-container::after {
    content: '';
    display: none; /* Скрыт по умолчанию */
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin-top: -25px;
    margin-left: -25px;
    border: 5px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    z-index: 10;
}

/* Показываем спиннер, когда у видео есть класс loading */
#tv-player.is-loading ~ .player-overlay-spinner {
   /* Это требует изменения HTML, сделаем проще через JS класс на контейнере */
}

/* ПРОСТОЙ ВАРИАНТ БЕЗ ИЗМЕНЕНИЯ HTML ПЛЕЕРА: */
/* Добавьте это в CSS */
.player-container.loading::before {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px; /* Точное центрирование */
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--accent); /* Цвет будет как у твоего сайта */
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 20;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Скрываем стандартный спиннер загрузки плеера */
video::-webkit-media-controls-panel {
    display: flex !important;
}
video::-webkit-media-controls-loading-indicator {
    display: none !important;
}

.program-details { padding: 25px; max-width: 900px; margin: 0 auto; width: 100%; box-sizing: border-box; }
.channel-meta { display: flex; align-items: center; gap: 15px; margin-bottom: 10px; }
#info-channel-name { margin: 0; font-size: 1.8rem; color: #fff; }
.live-badge {
    background: #e63946; color: white; font-size: 0.7rem;
    padding: 2px 6px; border-radius: 3px; font-weight: bold; display: none;
}
#info-program-title { margin: 0 0 20px 0; font-size: 1.2rem; color: var(--text-muted); font-weight: 400; }
#info-program-desc { line-height: 1.6; color: #ccc; font-size: 1rem; }
.program-desc-block { margin-top: 20px; padding-top: 20px; border-top: 1px solid #333; }

/* SEO Блок */
.seo-container { padding: 40px; max-width: 800px; margin: 0 auto; color: #e0e0e0; animation: fadeIn 0.5s ease; }
.seo-container h1 { font-size: 2.5rem; margin-bottom: 20px; color: #fff; }
.seo-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 40px; }
.feature-card { background: #1e1e24; padding: 20px; border-radius: 8px; border: 1px solid #333; }
.feature-card h3 { color: var(--accent); margin-top: 0; } /* Цвет заголовка фичи */
.feature-card p { font-size: 0.9rem; color: #aaa; margin: 0; }
.seo-cta { font-size: 1.2rem; color: #fff; font-weight: bold; text-align: center; margin-top: 30px; }

/* --- СТИЛИ ДЛЯ SEO ССЫЛКИ --- */
.seo-cta a {
    display: inline-block;
    color: #fff; 
    background-color: var(--accent); 
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 700;
    transition: background-color 0.2s, transform 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
.seo-cta a:hover {
    background-color: var(--accent-hover); 
    transform: translateY(-2px); 
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Имитируем стиль h1 для названия канала */
.channel-title-style {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

/* Имитируем стиль h2 для названия программы */
.program-title-style {
    margin: 0 0 20px 0;
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* =========================================
   MOBILE / RESPONSIVE (СТРОГО В КОНЦЕ!)
   ========================================= */
@media (max-width: 900px) {
    /* Разрешаем скроллить саму страницу */
    body {
        height: auto;
        overflow-y: auto; /* Включаем нативный скролл браузера */
    }

    .app-container {
        flex-direction: column;
        height: auto; /* Контейнер растягивается контентом */
        overflow: visible;
    }

    /* Адаптация шапки сайдбара */
    .sidebar-header {
        position: relative; /* Убираем sticky на мобилке */
        padding-bottom: 15px; 
    }

    /* 1. БЛОК С ПЛЕЕРОМ (Сверху) */
    .main-content {
        order: 1;
        height: auto;
        flex-grow: 0;
        overflow: visible;
    }
    
    .player-container {
        position: sticky;
        top: 0;
        z-index: 100;
        max-height: 50vh;
    }

    /* 2. СПИСОК КАНАЛОВ (Снизу) */
    .sidebar {
        order: 2;
        width: 100%;
        border-right: none;
        height: auto;      
        max-height: none;  
        overflow: visible; 
    }

    .channels-scroll-area {
        height: auto;
        overflow: visible;
        max-height: none;
        padding-bottom: 5px;
    }

    .sidebar-footer {
        position: relative;
        z-index: 5;
        padding-bottom: 30px; 
    }

    .seo-container { padding: 20px; }
    .seo-container h1 { font-size: 1.8rem; }
    
    .program-details { padding: 15px; }
    #info-channel-name { font-size: 1.5rem; }
    #info-program-title { font-size: 1.1rem; }

    .channel-title-style { font-size: 1.5rem; }
    .program-title-style { font-size: 1.1rem; }
	
}