/* ========================================
   LIVE TV — Layout 3 Colunas Premium
   Categorias | Canais | Preview
   ======================================== */

/* ---- Container Principal ---- */
.live-tv-container {
    display: flex;
    height: calc(100dvh - var(--navbar-height));
    width: 100%;
    max-width: 100%;
    background: #020202;
    overflow: hidden;
    box-sizing: border-box;
}

/* Scrollbars Universais Ultra Finas */
.live-categories-list::-webkit-scrollbar,
.live-channels-list::-webkit-scrollbar {
    width: 4px;
}

.live-categories-list::-webkit-scrollbar-thumb,
.live-channels-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
}

.live-categories-list:hover::-webkit-scrollbar-thumb,
.live-channels-list:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

/* ============================== */
/* COLUNA 1 — Categorias          */
/* ============================== */
.live-categories-panel {
    flex: 0 0 250px;
    min-width: 200px;
    max-width: 300px;
    background: #050505;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.live-categories-header {
    padding: 16px 16px 8px;
    font-family: var(--font-display);
    font-size: 16px;
    letter-spacing: 2px;
    color: var(--color-primary);
    text-transform: uppercase;
    flex-shrink: 0;
}

.live-categories-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.live-categories-list::-webkit-scrollbar {
    width: 4px;
}

.live-categories-list::-webkit-scrollbar-track {
    background: transparent;
}

.live-categories-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* ============================== */
/* COLUNA 2 — Lista de Canais     */
/* ============================== */
.live-channels-panel {
    flex: 0 0 320px;
    min-width: 280px;
    max-width: 380px;
    background: #080808;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.live-channels-header {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.2);
}

.live-channels-header-title {
    font-family: var(--font-display);
    font-size: 15px;
    letter-spacing: 1.5px;
    color: var(--color-text);
    text-transform: uppercase;
}

.live-channels-count {
    font-size: 11px;
    color: var(--color-text-muted);
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 8px;
    border-radius: 10px;
}

.live-channels-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.live-channels-list::-webkit-scrollbar {
    width: 4px;
}

.live-channels-list::-webkit-scrollbar-track {
    background: transparent;
}

.live-channels-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* ============================== */
/* ESTILO UNIFICADO DE LISTA PREMIUM */
/* ============================== */
.live-cat-item,
.live-channel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin: 4px 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.live-channel-item {
    text-transform: none;
    /* Canais mantém o nome original */
    letter-spacing: normal;
}

.cat-name-truncate {
    display: block;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-cat-item:hover,
.live-channel-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: translateX(4px);
}

.live-cat-item.active,
.live-channel-item.active {
    background: rgba(229, 9, 20, 0.15);
    border-color: rgba(229, 9, 20, 0.4);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(229, 9, 20, 0.2);
}

.live-cat-item.active::before,
.live-channel-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 3px;
    background: var(--color-primary);
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 10px var(--color-primary);
}

/* Específicos da Lista de Canais */
.channel-card-content {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.live-channel-num {
    font-family: 'Inter', monospace;
    font-size: 10px;
    color: var(--color-primary);
    opacity: 0.6;
    min-width: 25px;
    text-align: right;
}

.live-channel-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #111;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.live-channel-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.live-channel-icon .channel-icon-placeholder {
    font-size: 14px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
}

.live-channel-name {
    font-size: 13px;
    font-weight: 500;
    color: #d0d0d0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.live-channel-item.active .live-channel-name {
    color: #fff;
    font-weight: 600;
}

.live-channel-item.active .live-channel-num {
    color: var(--color-primary);
}

/* ============================== */
/* COLUNA 3 — Preview / Player    */
/* ============================== */
.live-preview-panel {
    flex: 1;
    min-width: 0;
    background: #0a0a0a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.live-preview-player {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
}

.live-preview-player video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.live-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--color-text-muted);
    text-align: center;
    padding: 20px;
}

.live-preview-placeholder .placeholder-icon {
    font-size: 48px;
    opacity: 0.3;
}

.live-preview-placeholder .placeholder-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.live-preview-placeholder .placeholder-sub {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Overlay do Player (nome do canal no topo) */
.live-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px 20px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 2;
}

.live-preview-player:hover .live-preview-overlay {
    opacity: 1;
}

.live-preview-channel-name {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.live-preview-live-badge {
    font-size: 10px;
    padding: 3px 8px;
    background: var(--color-primary);
    border-radius: 3px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Loading spinner no preview */
.live-preview-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    z-index: 3;
}

.live-preview-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---- Painel de Ações (abaixo do player) ---- */
.live-preview-actions {
    flex-shrink: 0;
    padding: 16px 20px;
    background: #0d0d0d;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.live-preview-now-playing {
    font-family: var(--font-display);
    font-size: 18px;
    letter-spacing: 1.5px;
    color: var(--color-text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    width: 100%;
    text-transform: uppercase;
}

.live-action-btn svg {
    flex-shrink: 0;
}

.live-action-btn.fullscreen-btn {
    background: var(--color-primary);
    color: #fff;
}

.live-action-btn.fullscreen-btn:hover {
    background: var(--color-secondary);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(229, 9, 20, 0.4);
}

.live-action-btn.fav-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.live-action-btn.fav-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.live-action-btn.fav-btn.active {
    background: rgba(255, 200, 0, 0.15);
    color: #ffc800;
    border-color: rgba(255, 200, 0, 0.4);
}

.live-action-btn.fav-btn.active:hover {
    background: rgba(255, 200, 0, 0.25);
}

.live-action-btn.search-btn {
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.live-action-btn.search-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text);
}

/* ---- Busca de canais inline ---- */
.live-channels-search {
    padding: 8px 12px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: none;
}

.live-channels-search.active {
    display: block;
}

.live-channels-search input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
}

.live-channels-search input:focus {
    border-color: var(--color-primary);
}

.live-channels-search input::placeholder {
    color: var(--color-text-muted);
}

/* ============================== */
/* Responsividade Tablet (1024px)  */
/* ============================== */
@media (max-width: 1024px) {
    .live-tv-container {
        height: calc(100dvh - var(--navbar-height, 64px));
    }

    .live-categories-panel {
        flex: 0 0 200px;
        min-width: 180px;
        max-width: 220px;
    }

    .live-channels-panel {
        flex: 0 0 260px;
        min-width: 220px;
    }
}

/* ============================== */
/* Mobile (768px) — Drawer Layout  */
/* Canais full-width + drawer cats */
/* ============================== */
@media (max-width: 768px) {

    /* Container: desconta navbar (52px) + bottom nav (60px) */
    .live-tv-container {
        flex-direction: row;
        height: calc(100dvh - var(--navbar-height, 52px) - var(--bottom-nav-height, 60px));
        min-height: 0;
        overflow: hidden;
        width: 100%;
        max-width: 100%;
        position: relative;
    }

    /* ---- Painel de Categorias: Drawer deslizante ---- */
    .live-categories-panel {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 240px;
        min-width: 240px;
        max-width: 240px;
        height: 100%;
        max-height: none;
        border-right: 1px solid rgba(255, 255, 255, 0.12);
        border-bottom: none;
        overflow: hidden;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 6px 0 24px rgba(0, 0, 0, 0.6);
    }

    .live-categories-panel.mobile-open {
        transform: translateX(0);
    }

    .live-categories-header {
        padding: 14px 14px 8px;
        font-size: 11px;
        letter-spacing: 1px;
        text-align: left;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }

    .live-categories-list {
        flex-direction: column;
        flex-wrap: nowrap;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 6px 0;
        gap: 0;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        align-items: stretch;
    }

    .live-cat-item {
        flex: none;
        padding: 13px 14px;
        margin: 0;
        border-radius: 0;
        white-space: normal;
        word-break: break-word;
        font-size: 13px;
        min-height: auto;
        line-height: 1.3;
        text-align: left;
        letter-spacing: 0;
        text-transform: none;
        border-left: 3px solid transparent;
        border-top: none;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.04);
        background: none;
        box-shadow: none;
    }

    .live-cat-item:active {
        background: rgba(229, 9, 20, 0.18);
    }

    .live-cat-item.active {
        background: rgba(229, 9, 20, 0.15);
        border-left-color: var(--color-primary);
        box-shadow: none;
    }

    .live-cat-item.active::before {
        display: none;
    }

    /* Overlay escuro quando drawer está aberto */
    .live-cat-overlay {
        display: none;
        position: absolute;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 49;
        cursor: pointer;
    }

    .live-cat-overlay.active {
        display: block;
    }

    /* ---- Painel de Canais: ocupa toda a largura ---- */
    .live-channels-panel {
        flex: 1;
        width: 100%;
        min-width: 0;
        height: 100%;
        max-height: none;
        min-height: 0;
        border-right: none;
        border-bottom: none;
    }

    .live-channels-header {
        padding: 10px 12px 8px;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .live-channels-header-title {
        font-size: 12px;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Botão "☰ Categorias" adicionado via JS */
    .live-mobile-cat-btn {
        display: flex;
        align-items: center;
        gap: 5px;
        padding: 6px 10px;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 6px;
        font-size: 11px;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.85);
        cursor: pointer;
        flex-shrink: 0;
        letter-spacing: 0.5px;
        text-transform: uppercase;
        transition: background 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .live-mobile-cat-btn:active {
        background: rgba(229, 9, 20, 0.2);
        border-color: rgba(229, 9, 20, 0.4);
    }

    .live-channel-item {
        padding: 10px 10px;
        margin: 2px 4px;
        min-height: 44px;
    }

    .live-channel-item:active {
        transform: scale(0.98);
        background: rgba(229, 9, 20, 0.15);
    }

    .live-channel-item.active::before {
        display: none;
    }

    .live-channel-name {
        font-size: 12px;
    }

    .live-channel-icon {
        width: 30px;
        height: 30px;
    }

    /* Busca: font 16px evita zoom automático no iOS */
    .live-channels-search input {
        font-size: 16px;
        padding: 10px 14px;
    }

    /* Preview oculto no mobile: toque no canal abre direto no player */
    .live-preview-panel {
        display: none;
    }
}

/* ======================================================
   MOBILE LANDSCAPE — Categorias sempre visíveis em coluna
   Sobrescreve o drawer do bloco 768px acima
   ====================================================== */
@media screen and (max-width: 1200px) and (max-height: 650px) and (orientation: landscape) {
    .live-tv-container {
        height: calc(100dvh - var(--navbar-height, 44px) - env(safe-area-inset-bottom, 0px));
    }

    /* ---- LAYOUT 50/50: Preview=50%, Categorias+Canais=50% ---- */

    /* Preview: exatamente 50% da tela */
    .live-preview-panel {
        display: flex !important;
        flex: 0 0 50% !important;
        width: 50% !important;
        min-width: 0 !important;
        order: 3;
    }

    /* Categorias: 25% da tela — espaço suficiente para mostrar os nomes */
    .live-categories-panel {
        position: relative !important;
        transform: translateX(0) !important;
        flex: 0 0 25% !important;
        width: 25% !important;
        min-width: 0 !important;
        max-width: none !important;
        height: 100% !important;
        max-height: none !important;
        box-shadow: none !important;
        border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-bottom: none !important;
        z-index: 1 !important;
        order: 1;
    }

    .live-categories-header {
        padding: 8px 8px 4px !important;
        font-size: 12px !important;
        letter-spacing: 1px !important;
    }

    .live-categories-list {
        padding: 4px 0 !important;
        gap: 0 !important;
    }

    /* Categoria: min-height 44px (padrão Apple HIG) — nomes quebram em 2 linhas */
    .live-cat-item {
        padding: 8px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        font-size: 13px !important;
        border-radius: 0 !important;
        white-space: normal !important;
        word-break: break-word !important;
        overflow: visible !important;
        line-height: 1.3 !important;
        text-align: left !important;
        border-left: 3px solid transparent !important;
        border-top: none !important;
        border-right: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
        margin: 0 !important;
    }

    .live-cat-item.active {
        border-left-color: var(--color-primary) !important;
        background: rgba(229, 9, 20, 0.15) !important;
    }

    /* Nome da categoria: sem truncar em landscape — mostra o nome completo */
    .cat-name-truncate {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
    }

    /* Overlay e botão do drawer: desnecessários em landscape */
    .live-cat-overlay { display: none !important; }
    .live-mobile-cat-btn { display: none !important; }

    /* Canais: 25% da tela — igual às categorias, equilibrado */
    .live-channels-panel {
        flex: 0 0 25% !important;
        width: 25% !important;
        min-width: 0 !important;
        max-width: none !important;
        order: 2;
    }

    .live-channels-header {
        padding: 8px 10px 6px !important;
    }

    .live-channels-header-title {
        font-size: 13px !important;
        letter-spacing: 0.5px !important;
    }

    .live-channels-list {
        padding: 4px 0 !important;
        gap: 0 !important;
    }

    /* Canal: min-height 44px (padrão Apple HIG / 48dp Material Design) */
    .live-channel-item {
        padding: 0 8px !important;
        min-height: 44px !important;
        margin: 0 4px !important;
        gap: 8px !important;
        font-size: 12px !important;
        border-radius: 6px !important;
    }

    .live-channel-icon {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        flex-shrink: 0 !important;
    }

    .live-channel-name {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        font-size: 13px !important;
    }

    /* Ações do preview: compactas em landscape */
    .live-preview-actions {
        padding: 8px 12px !important;
        gap: 6px !important;
    }

    .live-action-btn {
        padding: 9px 12px !important;
        font-size: 12px !important;
        min-height: 44px !important;
    }

    .live-preview-now-playing {
        font-size: 14px !important;
        margin-bottom: 2px !important;
    }
}