/* TV-RF HOME — DARK PURPLE DESIGN */

body:has(.tvrf-home-catalog) {
    background: #0b1224 !important;
    color: #f4f3ff !important;
}

.tvrf-popular,
#category,
.tvrf-home-catalog {
    max-width: 1180px !important;
    width: calc(100% - 40px) !important;
    margin: 24px auto !important;
    padding: 22px !important;
    box-sizing: border-box !important;
    background: #141e36 !important;
    border: 1px solid #293653 !important;
    border-radius: 18px !important;
    box-shadow: 0 8px 28px rgba(0,0,0,.2) !important;
}

.tvrf-countries {
    display: none !important;
}

.tvrf-popular h2,
#category .tvrf-category-heading,
.tvrf-home-heading h1 {
    color: #fff !important;
    font-size: 25px !important;
    font-weight: 750 !important;
    margin: 0 0 20px !important;
}

/* Популярные каналы */
.tvrf-popular-track .tvrf-channel-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 14px !important;
    overflow-x: auto !important;
    padding: 4px 2px 14px !important;
}

.tvrf-popular-track .tvrf-channel-card {
    flex: 0 0 205px !important;
    width: 205px !important;
    background: linear-gradient(145deg,#202e4d,#111b32) !important;
    border: 1px solid #344365 !important;
    border-radius: 13px !important;
    color: #fff !important;
}

/* Категории */
#category {
    display: block !important;
}

#tvrf-category-section {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

#tvrf-category-section .tvrf-category-tile {
    background: linear-gradient(145deg,#26365b,#17233f) !important;
    border: 1px solid #3b4c72 !important;
    border-radius: 13px !important;
    color: #fff !important;
    box-shadow: 0 5px 15px rgba(0,0,0,.2) !important;
}

#tvrf-category-section a {
    color: #fff !important;
}

/* Каталог каналов */
.tvrf-home-heading {
    margin-bottom: 24px !important;
}

.tvrf-home-heading h1 {
    color: #fff !important;
}

.tvrf-home-heading p {
    color: #aab6d0 !important;
}

.tvrf-home-catalog .tvrf-channel-card {
    background: linear-gradient(145deg,#202e4d,#111b32) !important;
    border: 1px solid #344365 !important;
    border-radius: 14px !important;
    color: #fff !important;
}

/* Фиолетовые кнопки */
.tvrf-popular .tvrf-show-more,
.tvrf-popular .tvrf-popular-more,
#category .tvrf-category-more {
    background: linear-gradient(135deg,#8547f5,#6231c7) !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 9px !important;
}

/* Мобильная версия контента — меню не затрагивается */
@media(max-width:700px) {
    .tvrf-popular,
    #category,
    .tvrf-home-catalog {
        width: calc(100% - 24px) !important;
        margin: 14px auto !important;
        padding: 15px !important;
        border-radius: 15px !important;
    }

    .tvrf-popular h2,
    #category .tvrf-category-heading,
    .tvrf-home-heading h1 {
        font-size: 21px !important;
    }

    .tvrf-popular-track .tvrf-channel-card {
        flex-basis: 190px !important;
        width: 190px !important;
    }
}

/* ==========================================
   HOME V2 — popular channels + categories
   ========================================== */

/* 5 популярных каналов в ряд */
.tvrf-popular-track .tvrf-popular-list {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 12px !important;
    padding: 8px 0 12px !important;
    overflow: visible !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
}

/* Показываем карточки 4 и 5, остальные не удаляем */
.tvrf-popular-track .tvrf-popular-list .tvrf-popular-extra {
    display: flex !important;
}

.tvrf-popular-track .tvrf-popular-list .tvrf-popular-card:nth-child(n+6) {
    display: none !important;
}

/* Карточка канала в стиле макета */
.tvrf-popular-track .tvrf-popular-card {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 9px !important;
    min-width: 0 !important;
    width: 100% !important;
    min-height: 126px !important;
    padding: 12px 8px !important;
    box-sizing: border-box !important;
    background: linear-gradient(145deg, #202e4d, #121d34) !important;
    border: 1px solid #344565 !important;
    border-radius: 13px !important;
    box-shadow: 0 5px 16px rgba(0,0,0,.2) !important;
    transition: transform .2s, border-color .2s, box-shadow .2s !important;
}

.tvrf-popular-track .tvrf-popular-card:hover {
    transform: translateY(-3px) !important;
    border-color: #9865ff !important;
    box-shadow: 0 8px 22px rgba(100,55,200,.2) !important;
}

.tvrf-popular-track .tvrf-popular-logo {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 70px !important;
    flex: 0 0 70px !important;
    background: transparent !important;
    border-radius: 8px !important;
}

.tvrf-popular-track .tvrf-popular-logo img {
    max-width: 100% !important;
    max-height: 68px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
}

.tvrf-popular-track .tvrf-popular-logo span {
    color: #fff !important;
    font-size: 25px !important;
}

.tvrf-popular-track .tvrf-popular-name {
    display: block !important;
    width: 100% !important;
    flex: 0 0 auto !important;
    color: #f5f3ff !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    text-align: center !important;
    line-height: 1.25 !important;
}

.tvrf-popular-track .tvrf-popular-watch {
    display: none !important;
}

/* Кнопка "Все" */
.tvrf-popular .tvrf-popular-more {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 110px !important;
    min-height: 36px !important;
    margin: 4px 0 0 !important;
    padding: 0 20px !important;
    border: 0 !important;
    border-radius: 9px !important;
    background: linear-gradient(135deg, #8547f5, #6231c7) !important;
    color: #fff !important;
    font-weight: 700 !important;
}

/* Категории — прозрачная внутренняя область */
#tvrf-category-section {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

#tvrf-category-section .tvrf-category-grid {
    display: grid !important;
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: 10px !important;
}

#tvrf-category-section .tvrf-category-tile {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 9px !important;
    min-width: 0 !important;
    min-height: 88px !important;
    padding: 10px 5px !important;
    background: linear-gradient(145deg, #202e4d, #121d34) !important;
    border: 1px solid #344565 !important;
    border-radius: 12px !important;
    color: #fff !important;
    box-shadow: 0 5px 14px rgba(0,0,0,.18) !important;
    text-align: center !important;
    text-decoration: none !important;
}

#tvrf-category-section .tvrf-category-tile:hover,
#tvrf-category-section .tvrf-category-tile.selected {
    background: linear-gradient(145deg, #6635c9, #382078) !important;
    border-color: #9865ff !important;
}

#tvrf-category-section .tvrf-category-icon {
    color: #c8a5ff !important;
    font-size: 25px !important;
    line-height: 1 !important;
}

#tvrf-category-section .tvrf-category-name {
    color: #fff !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    text-align: center !important;
}

.tvrf-category-heading {
    color: #fff !important;
}

/* Планшеты */
@media (max-width: 900px) {
    .tvrf-popular-track .tvrf-popular-list {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }

    #tvrf-category-section .tvrf-category-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}

/* Телефоны */
@media (max-width: 600px) {
    .tvrf-popular-track .tvrf-popular-list {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 9px !important;
    }

    .tvrf-popular-track .tvrf-popular-card {
        min-height: 116px !important;
    }

    #tvrf-category-section .tvrf-category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    #tvrf-category-section .tvrf-category-tile {
        min-height: 76px !important;
    }
}

/* Показываем все категории сразу */
#tvrf-category-section .tvrf-category-grid .tvrf-category-extra {
    display: flex !important;
}

#tvrf-category-section .tvrf-category-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: 10px !important;
}

#tvrf-category-section .tvrf-category-more {
    display: none !important;
}

/* Увеличиваем логотипы популярных каналов */
.tvrf-popular-track .tvrf-popular-card {
    min-height: 145px !important;
    padding: 12px 8px !important;
}

.tvrf-popular-track .tvrf-popular-logo {
    height: 88px !important;
    flex-basis: 88px !important;
}

.tvrf-popular-track .tvrf-popular-logo img {
    max-height: 84px !important;
    max-width: 100% !important;
    object-fit: contain !important;
}

.tvrf-popular-track .tvrf-popular-name {
    font-size: 13px !important;
}

@media (max-width: 900px) {
    #tvrf-category-section .tvrf-category-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 600px) {
    #tvrf-category-section .tvrf-category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

/* HEADER: вертикальное выравнивание только на десктопе */
@media (min-width: 601px) {
    #head #main_menu {
        margin-top: 0 !important;
        position: relative !important;
        top: -5px !important;
    }
}

/* Кнопки действий справа от заголовков */
.tvrf-popular,
#category {
    position: relative !important;
}

.tvrf-popular h2,
#category .tvrf-category-heading {
    padding-right: 150px !important;
}

.tvrf-popular .tvrf-popular-more {
    position: absolute !important;
    top: 17px !important;
    right: 22px !important;
    margin: 0 !important;
    min-width: 0 !important;
    min-height: 30px !important;
    padding: 0 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0 !important;
    text-decoration: none !important;
    background: linear-gradient(135deg,#8547f5,#6231c7) !important;
    border-radius: 8px !important;
}

.tvrf-popular .tvrf-popular-more::after {
    content: "Все популярные";
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

#category .tvrf-category-more {
    position: absolute !important;
    top: 14px !important;
    right: 22px !important;
    margin: 0 !important;
    min-height: 30px !important;
    padding: 0 12px !important;
    background: linear-gradient(135deg,#8547f5,#6231c7) !important;
    border: 0 !important;
    border-radius: 8px !important;
    color: #fff !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
}

/* Показываем первые 7 категорий; остальные — по кнопке */
#tvrf-category-section .tvrf-category-grid .tvrf-category-extra {
    display: none !important;
}

#tvrf-category-section .tvrf-category-grid .tvrf-category-extra:nth-child(4),
#tvrf-category-section .tvrf-category-grid .tvrf-category-extra:nth-child(5),
#tvrf-category-section .tvrf-category-grid .tvrf-category-extra:nth-child(6),
#tvrf-category-section .tvrf-category-grid .tvrf-category-extra:nth-child(7) {
    display: flex !important;
}

#tvrf-category-section .tvrf-category-grid.show-all .tvrf-category-extra {
    display: flex !important;
}

@media (max-width: 600px) {
    .tvrf-popular h2,
    #category .tvrf-category-heading {
        padding-right: 0 !important;
    }

    .tvrf-popular .tvrf-popular-more,
    #category .tvrf-category-more {
        position: static !important;
        margin: 10px 0 0 !important;
    }
}

/* FINAL POLISH */

/* Рекомендуемый блок — той же ширины, что остальные секции */
.tvrf-hero {
    width: calc(100% - 40px) !important;
    max-width: 1180px !important;
    margin: 24px auto 28px !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

.tvrf-hero-content {
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Логотип и навигация на одной вертикальной оси.
   Только десктоп, мобильное меню не затрагиваем. */
@media (min-width: 601px) {
    #head {
        display: flex !important;
        align-items: center !important;
    }

    #head #logo.tvrf-header-brand {
        align-self: center !important;
        height: 100% !important;
        margin-top: 0 !important;
        transform: none !important;
    }

    #head #main_menu {
        align-self: center !important;
        margin-top: 0 !important;
        top: 0 !important;
        transform: none !important;
    }
}

/* Ссылки действий — текстовые, как в референсе */
.tvrf-popular .tvrf-popular-more,
#category .tvrf-category-more {
    min-height: 30px !important;
    padding: 0 2px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #c49aff !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    cursor: pointer !important;
    transition: color .2s, opacity .2s !important;
}

.tvrf-popular .tvrf-popular-more:hover,
#category .tvrf-category-more:hover {
    color: #fff !important;
    opacity: .9 !important;
}

/* Популярные: текст ссылки справа от заголовка */
.tvrf-popular .tvrf-popular-more {
    font-size: 0 !important;
}

.tvrf-popular .tvrf-popular-more::after {
    content: "Все популярные →";
    color: #c49aff;
    font-size: 12px;
    font-weight: 700;
}

/* Категории: сохраняем рабочую кнопку раскрытия */
#category .tvrf-category-more {
    font-size: 0 !important;
}

#category .tvrf-category-more::after {
    content: "Все категории →";
    color: #c49aff;
    font-size: 12px;
    font-weight: 700;
}

#category .tvrf-category-more:hover::after,
.tvrf-popular .tvrf-popular-more:hover::after {
    color: #fff;
}

@media (max-width: 600px) {
    .tvrf-hero {
        width: calc(100% - 24px) !important;
        margin: 18px auto 20px !important;
    }
}


/* HEADER ALIGNMENT AND POPULAR LOGOS V2 */
@media (min-width: 601px) {
    #head {
        display: flex !important;
        align-items: center !important;
    }

    #head #logo.tvrf-header-brand {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        height: 80px !important;
        align-self: center !important;
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1 !important;
    }

    #head #logo .tvrf-header-logo {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 8px !important;
        height: auto !important;
        line-height: 1 !important;
        text-decoration: none !important;
    }

    #head #logo .tvrf-header-mark {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex: 0 0 34px !important;
        width: 34px !important;
        height: 34px !important;
        line-height: 1 !important;
    }

    #head #logo .tvrf-header-name {
        display: inline-block !important;
        line-height: 1.1 !important;
    }

    #head #main_menu {
        display: flex !important;
        align-items: center !important;
        align-self: center !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #head #main_menu .tvrf-main-nav {
        display: flex !important;
        align-items: center !important;
        height: 80px !important;
        min-height: 80px !important;
    }
}

/* Увеличенные логотипы популярных телеканалов */
.tvrf-popular-track .tvrf-channel-card {
    min-height: 155px !important;
}

.tvrf-popular-track .tvrf-channel-preview {
    min-height: 115px !important;
    padding: 8px !important;
}

.tvrf-popular-track .tvrf-channel-preview img {
    width: 145px !important;
    height: 105px !important;
    max-width: 100% !important;
    object-fit: contain !important;
}

@media (max-width: 600px) {
    .tvrf-popular-track .tvrf-channel-preview img {
        width: 105px !important;
        height: 82px !important;
    }
}

/* Popular channels — larger logos, reference layout */
@media (min-width: 601px) {
    #head #logo.tvrf-header-brand {
        position: relative !important;
        top: -6px !important;
    }

    .tvrf-popular-card {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        min-height: 145px !important;
        gap: 8px !important;
        padding: 10px !important;
    }

    .tvrf-popular-logo {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: 92px !important;
        flex: 0 0 92px !important;
        background: transparent !important;
    }

    .tvrf-popular-logo img {
        display: block !important;
        width: auto !important;
        height: auto !important;
        max-width: 100px !important;
        max-height: 90px !important;
        object-fit: contain !important;
    }

    .tvrf-popular-name {
        flex: 0 0 auto !important;
        text-align: center !important;
        color: #fff !important;
    }

    .tvrf-popular-watch {
        display: none !important;
    }
}

/* DESKTOP: убрать светлую полосу между шапкой и hero */
@media (min-width: 601px) {
    body:has(.tvrf-home-catalog) #content_box {
        background: #0b1224 !important;
    }

    body:has(.tvrf-home-catalog) .tvrf-hero {
        margin-top: 10px !important;
    }
}

/* DESKTOP HOME: убрать пустую светлую панель фильтров под шапкой */
@media (min-width: 601px) {
    body:has(.tvrf-home-catalog) #cams_filter_box {
        display: none !important;
    }
}
