/* ==========================================================================
   TVBR EPG – Estilos do Guia de Programação
   Versão: 2.2.0 — Performance Optimized + Sanitização Inteligente
   ========================================================================== */

/* ───── Fontes locais – Inter (com unicode-range) ───── */

@font-face {
    font-family: 'Inter';
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    src: url('../fonts/Inter-Regular.woff2') format('woff2');
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,
                   U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,
                   U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,
                   U+FEFF,U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-weight: 600;
    font-style: normal;
    font-display: swap;
    src: url('../fonts/Inter-SemiBold.woff2') format('woff2');
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,
                   U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,
                   U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,
                   U+FEFF,U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    src: url('../fonts/Inter-Bold.woff2') format('woff2');
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,
                   U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,
                   U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,
                   U+FEFF,U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-weight: 800;
    font-style: normal;
    font-display: swap;
    src: url('../fonts/Inter-ExtraBold.woff2') format('woff2');
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,
                   U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,
                   U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,
                   U+FEFF,U+FFFD;
}

/* ───── Variáveis & Base ───── */

#tvbr_epg_root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --accent-gradient: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --live-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --warning-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --app-background: linear-gradient(180deg, #fff 0%, #fff 14%, #f8fafc 32%, #eef2ff 58%, #eaf0ff 100%);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-white: #ffffff;
    --surface-primary: #ffffff;
    --surface-secondary: #f8fafc;
    --surface-accent: #f1f5f9;
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,.05);
    --shadow-md: 0 6px 16px rgba(18,32,57,.08);
    --shadow-lg: 0 18px 32px rgba(18,32,57,.12);
    --shadow-xl: 0 28px 44px rgba(18,32,57,.14);

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    background: var(--app-background);
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    isolation: isolate;
    position: relative;
    overflow: hidden;
}

#tvbr_epg_root *,
#tvbr_epg_root *::before,
#tvbr_epg_root *::after {
    box-sizing: border-box !important;
}

/* ───── Tipografia ───── */

#tvbr_epg_root h1,
#tvbr_epg_root h2,
#tvbr_epg_root h3,
#tvbr_epg_root h4,
#tvbr_epg_root h5,
#tvbr_epg_root h6,
#tvbr_epg_root p,
#tvbr_epg_root small,
#tvbr_epg_root button {
    font-family: inherit !important;
    font-weight: inherit !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 1.4 !important;
    margin: 0 !important;
    color: inherit !important;
}

/* ───── Containers ───── */

#tvbr_epg_root .main-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    border: none;
}

#tvbr_epg_root .program-list-container {
    padding: 0;
    contain: style;
}

/* ───── Títulos de Seção ───── */

#tvbr_epg_root .section-title {
    font-size: 20px;
    margin: 32px 0 20px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    border-left: 4px solid;
    border-image: var(--accent-gradient) 1;
    padding-left: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ───── Elementos ocultos (consolidado) ───── */

#tvbr_epg_root .ao-vivo-badge,
#tvbr_epg_root .botao-lateral-direito,
#tvbr_epg_root #programas-passados,
#tvbr_epg_root .secao-atual-header {
    display: none !important;
}

/* ───── Cartão de programa ───── */

#tvbr_epg_root .program-card {
    display: flex;
    gap: 24px;
    padding: 24px;
    margin-bottom: 16px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(248,250,252,.95) 100%),
        var(--surface-secondary);
    border: none;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 100%;
    transform: none;
    transition: none;
    animation: none;
    contain: style;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* REMOVIDO: .program-card::before (opacity:0 permanente — pseudo-elemento invisível) */

/* ── Programa atual ── */

#tvbr_epg_root .program-card.current {
    background: linear-gradient(135deg, #fffbea 0%, #fffef5 100%);
    border: none;
    border-left: 6px solid #fde68a;
    box-shadow: var(--shadow-lg);
}

#tvbr_epg_root .program-card.current::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, rgba(245,158,11,.08) 0%, transparent 100%);
    pointer-events: none;
}

/* ── Futuro / Passado ── */

#tvbr_epg_root .program-card.future,
#tvbr_epg_root .program-card.past {
    border: none;
}

/* ───── Coluna de horário ───── */

#tvbr_epg_root .program-time {
    flex: 0 0 130px;
    min-width: 130px;
    max-width: 130px;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    letter-spacing: .5px;
    white-space: nowrap;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    font-size: 17px;
}

#tvbr_epg_root .program-card.future .program-time {
    justify-content: flex-start;
    text-align: left;
    flex: 0 0 auto;
    min-width: auto;
    max-width: none;
    white-space: normal;
}

#tvbr_epg_root .program-card.current .program-time {
    justify-content: center;
    text-align: center;
}

/* ───── Conteúdo do programa ───── */

#tvbr_epg_root .program-details-content {
    flex: 1 1 auto;
    min-width: 0;
    position: relative;
    z-index: 1;
}

#tvbr_epg_root .program-details-content h3 {
    font-size: 20px !important;
    font-weight: 800 !important;
    margin-bottom: 8px !important;
    color: var(--text-primary) !important;
    word-wrap: break-word;
    line-height: 1.3 !important;
}

#tvbr_epg_root .program-details-content h3 small {
    font-size: 80% !important;
    font-weight: 600 !important;
}

#tvbr_epg_root .program-details-content p {
    font-size: 15px !important;
    color: var(--text-secondary) !important;
    margin-bottom: 6px !important;
    word-wrap: break-word;
}

#tvbr_epg_root .program-details-content strong {
    color: var(--text-primary) !important;
    font-weight: 700 !important;
}

#tvbr_epg_root .program-details-content p.descricao {
    font-weight: 600 !important;
    color: var(--text-primary) !important;
    font-size: 16px !important;
    line-height: 1.7 !important;
}

#tvbr_epg_root .program-details-content p.descricao strong {
    font-weight: 600 !important;
}

/* ───── Tempo restante ───── */

#tvbr_epg_root .tempo-restante {
    font-size: 14px !important;
    color: #dc2626 !important;
    font-weight: 800 !important;
    margin-top: 8px !important;
    padding: 6px 12px !important;
    background: rgba(220,38,38,.1) !important;
    border-radius: 8px !important;
    display: inline-block !important;
    letter-spacing: .3px !important;
}

/* ───── Barra de progresso ───── */

#tvbr_epg_root .progress-bar {
    position: absolute;
    bottom: 0; left: 0;
    height: 5px;
    background: linear-gradient(90deg, #ef4444 0%, #f97316 50%, #f59e0b 100%);
    border-radius: 0;
    transition: width .5s ease;
    box-shadow: 0 0 12px rgba(239,68,68,.3);
    width: 0%;
    will-change: width;
}

/* ───── Botão principal ───── */

#tvbr_epg_root .show-button {
    background: var(--secondary-gradient) !important;
    color: var(--text-white) !important;
    border: none !important;
    padding: 14px 28px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    border-radius: 12px !important;
    margin: 32px 0 16px !important;
    cursor: pointer !important;
    width: 100% !important;
    box-shadow: var(--shadow-md) !important;
    text-transform: uppercase !important;
    letter-spacing: .5px !important;
    transform: none;
    transition: none;
    animation: none;
}

/* ───── Header "A seguir" ───── */

#tvbr_epg_root .program-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 24px 0 16px;
    width: 100%;
    padding: 20px;
    background: radial-gradient(120% 80% at 50% 0%, rgba(240,249,255,.9) 0%, rgba(224,242,254,.8) 100%);
    border-radius: 16px;
    border: none;
    box-shadow: var(--shadow-md);
    transform: none;
    transition: none;
    animation: none;
}

#tvbr_epg_root .program-title {
    font-size: 18px !important;
    font-weight: 800 !important;
    margin: 0 !important;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(90deg, #0ea5e9 0%, #7c3aed 50%, #f59e0b 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: .2px;
    white-space: nowrap;
}

#tvbr_epg_root .program-title::before {
    content: '▶️';
    font-size: 16px;
}

/* ───── Botão Mostrar mais/menos ───── */

#tvbr_epg_root .toggle-button {
    background: transparent !important;
    color: #0ea5e9 !important;
    border: none !important;
    padding: 10px 20px !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    text-transform: uppercase !important;
    letter-spacing: .6px !important;
    transform: none;
    transition: none;
    animation: none;
}

/* ───── Duração ───── */

#tvbr_epg_root .program-duration {
    font-size: 14px !important;
    color: var(--text-muted) !important;
    margin-top: 4px !important;
    font-weight: 600 !important;
}

#tvbr_epg_root .program-duration strong {
    font-weight: 700 !important;
}

/* ───── Loading / Erro ───── */

#tvbr_epg_root .loading,
#tvbr_epg_root .error {
    text-align: center;
    padding: 40px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 12px;
    margin: 20px 0;
    border: none;
}

#tvbr_epg_root .loading {
    background: linear-gradient(180deg, rgba(241,245,249,.6), rgba(241,245,249,.9));
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

#tvbr_epg_root .error {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: #dc2626;
    box-shadow: var(--shadow-sm);
    font-weight: 700;
}

/* ───── Clearfix ───── */

#tvbr_epg_root .clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* ───── Badge de horário ───── */

#tvbr_epg_root .program-time .time-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #fff;
    color: #0ea5e9;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    box-shadow: 0 2px 10px rgba(14,165,233,.1);
    -webkit-text-fill-color: initial;
    background-clip: border-box;
    font-weight: 800;
    line-height: 1;
}

#tvbr_epg_root .program-time .time-badge::before {
    content: "🕒";
    font-size: 14px;
    opacity: .9;
}

#tvbr_epg_root .program-card.current .program-time .time-badge {
    border-color: #fde68a;
    box-shadow: 0 2px 12px rgba(245,158,11,.18);
    color: #b45309;
}

/* ───── Badge de duração ───── */

#tvbr_epg_root .program-duration .duration-label {
    color: var(--text-muted);
    margin-right: 6px;
}

#tvbr_epg_root .program-duration .duration-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #fff;
    color: #0f172a;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    font-weight: 800;
    line-height: 1.1;
}

#tvbr_epg_root .program-duration .duration-badge::before {
    content: "⏱️";
    font-size: 14px;
    opacity: .9;
}

/* ───── Separador "Amanhã" ───── */

#tvbr_epg_root .separador-amanha {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 32px 0 24px;
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(139,92,246,.08) 0%, rgba(59,130,246,.08) 100%);
    border-radius: 16px;
    border: 1px dashed rgba(139,92,246,.3);
    position: relative;
    transform: none;
    transition: none;
    animation: none;
}

#tvbr_epg_root .separador-amanha::before,
#tvbr_epg_root .separador-amanha::after {
    content: '';
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(139,92,246,.3) 50%, transparent 100%);
}

#tvbr_epg_root .separador-amanha-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

#tvbr_epg_root .separador-amanha-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

#tvbr_epg_root .separador-amanha-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #8b5cf6;
}

#tvbr_epg_root .separador-amanha-data {
    font-size: 18px;
    font-weight: 800;
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

/* ───── Botão "Recolher tudo" ───── */

#tvbr_epg_root .tvbr_collapse_all_button {
    background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%) !important;
    color: var(--text-white) !important;
    border: none !important;
    padding: 14px 28px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    border-radius: 12px !important;
    margin: 24px 0 16px !important;
    cursor: pointer !important;
    transition: transform .24s ease, box-shadow .24s ease, background .24s ease !important;
    width: 100% !important;
    box-shadow: 0 6px 20px rgba(6,182,212,.25) !important;
    text-transform: uppercase !important;
    letter-spacing: .5px !important;
    display: none;
    font-family: inherit !important;
}

#tvbr_epg_root .tvbr_collapse_all_button:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(59,130,246,.35) !important;
    background: linear-gradient(135deg, #0891b2 0%, #2563eb 100%) !important;
}

#tvbr_epg_root .tvbr_collapse_all_button:active {
    transform: translateY(0) !important;
}

/* ==========================================================================
   ACESSIBILIDADE — Reduzir movimento
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    #tvbr_epg_root .progress-bar {
        transition: none;
        will-change: auto;
    }
    #tvbr_epg_root .tvbr_collapse_all_button {
        transition: none !important;
    }
}

/* ==========================================================================
   TEMA ESCURO AUTOMÁTICO
   ========================================================================== */

#tvbr_epg_root.tvbr_on_dark {
    --app-background: linear-gradient(180deg, #1e293b 0%, #1e293b 14%, #0f172a 32%, #1e1b4b 58%, #1e1b4b 100%);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --surface-primary: #1e293b;
    --surface-secondary: #334155;
    --surface-accent: #475569;
    --border-light: #475569;
    --border-medium: #64748b;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,.2);
    --shadow-md: 0 6px 16px rgba(0,0,0,.25);
    --shadow-lg: 0 18px 32px rgba(0,0,0,.3);
    --shadow-xl: 0 28px 44px rgba(0,0,0,.35);
    background: var(--app-background);
}

#tvbr_epg_root.tvbr_on_dark .program-card {
    background: linear-gradient(180deg, rgba(255,255,255,.08) 0%, rgba(255,255,255,.06) 100%);
    box-shadow: var(--shadow-md);
}

#tvbr_epg_root.tvbr_on_dark .program-card.current {
    background: linear-gradient(135deg, rgba(253,230,138,.16), rgba(253,230,138,.08));
    border-left: 6px solid rgba(253,230,138,.8);
    box-shadow: var(--shadow-lg);
}

#tvbr_epg_root.tvbr_on_dark .program-header {
    background: linear-gradient(135deg, rgba(14,165,233,.12), rgba(59,130,246,.1));
    box-shadow: var(--shadow-md);
}

#tvbr_epg_root.tvbr_on_dark .toggle-button {
    color: #7dd3fc !important;
    border-color: transparent !important;
}

#tvbr_epg_root.tvbr_on_dark .time-badge {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.2);
    color: #7dd3fc;
}

#tvbr_epg_root.tvbr_on_dark .duration-badge {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.2);
    color: var(--text-primary);
}

#tvbr_epg_root.tvbr_on_dark .tempo-restante {
    background: rgba(220,38,38,.2) !important;
    color: #fca5a5 !important;
}

#tvbr_epg_root.tvbr_on_dark .loading {
    background: rgba(255,255,255,.05);
    color: var(--text-secondary);
}

#tvbr_epg_root.tvbr_on_dark .error {
    background: rgba(220,38,38,.15);
    color: #fca5a5;
}

#tvbr_epg_root.tvbr_on_dark .separador-amanha {
    background: linear-gradient(135deg, rgba(139,92,246,.15) 0%, rgba(59,130,246,.15) 100%);
    border-color: rgba(139,92,246,.4);
}

#tvbr_epg_root.tvbr_on_dark .separador-amanha::before,
#tvbr_epg_root.tvbr_on_dark .separador-amanha::after {
    background: linear-gradient(90deg, transparent 0%, rgba(139,92,246,.5) 50%, transparent 100%);
}

#tvbr_epg_root.tvbr_on_dark .separador-amanha-label {
    color: #a78bfa;
}

#tvbr_epg_root.tvbr_on_dark .tvbr_collapse_all_button {
    background: linear-gradient(135deg, #0e7490 0%, #0284c7 100%) !important;
    box-shadow: 0 6px 20px rgba(6,182,212,.3) !important;
}

#tvbr_epg_root.tvbr_on_dark .tvbr_collapse_all_button:hover {
    background: linear-gradient(135deg, #0891b2 0%, #0ea5e9 100%) !important;
    box-shadow: 0 8px 25px rgba(6,182,212,.4) !important;
}

/* ==========================================================================
   RESPONSIVO – 768 px
   ========================================================================== */

@media (max-width: 768px) {
    #tvbr_epg_root {
        font-size: clamp(15px, 2.2vw, 16px);
    }
    #tvbr_epg_root .main-container {
        margin: 0; border-radius: 0;
    }
    #tvbr_epg_root .program-list-container { padding: 0; }

    #tvbr_epg_root .program-card {
        flex-direction: column;
        gap: 16px;
        padding: 18px;
        border-radius: 14px;
    }
    #tvbr_epg_root .program-time {
        width: 100%; text-align: left; margin-bottom: 8px;
        min-width: auto; max-width: none;
        justify-content: flex-start;
        font-size: 16px; white-space: normal; flex: 0 0 auto;
    }
    #tvbr_epg_root .program-card.current .program-time {
        text-align: center; justify-content: center;
    }
    #tvbr_epg_root .program-header {
        flex-direction: column; gap: 12px;
        align-items: stretch; padding: 16px; border-radius: 14px;
    }
    #tvbr_epg_root .program-title {
        text-align: center; justify-content: center;
        white-space: normal; font-size: 17px !important;
    }
    #tvbr_epg_root .toggle-button {
        width: 100%; padding: 12px;
        font-size: 14px; border-radius: 12px !important;
    }
    #tvbr_epg_root .section-title {
        font-size: 18px; margin: 24px 0 16px;
    }
    #tvbr_epg_root .progress-bar { height: 6px; }
}

/* ==========================================================================
   RESPONSIVO – 480 px
   ========================================================================== */

@media (max-width: 480px) {
    #tvbr_epg_root {
        font-size: clamp(14px, 3.5vw, 16px);
    }
    #tvbr_epg_root .program-list-container { padding: 0; }
    #tvbr_epg_root .section-title { font-size: 16px; margin: 20px 0 16px; }

    #tvbr_epg_root .program-details-content h3 { font-size: 18px !important; }

    #tvbr_epg_root .program-details-content p,
    #tvbr_epg_root .program-duration,
    #tvbr_epg_root .tempo-restante { font-size: 14px !important; }

    #tvbr_epg_root .program-time { font-size: 15px; }
    #tvbr_epg_root .program-card.current .program-time {
        text-align: center; justify-content: center;
    }
    #tvbr_epg_root .program-card {
        padding: 16px; margin-bottom: 12px; border-radius: 12px;
    }
    #tvbr_epg_root .program-header {
        padding: 14px; border-radius: 12px;
    }
    #tvbr_epg_root .toggle-button {
        padding: 12px; font-size: 13.5px;
    }
    #tvbr_epg_root .program-time .time-badge { padding: 6px 10px; }
    #tvbr_epg_root .program-duration .duration-badge { padding: 4px 8px; }

    #tvbr_epg_root .separador-amanha {
        padding: 16px 20px; margin: 24px 0 20px;
    }
    #tvbr_epg_root .separador-amanha-data { font-size: 16px; }
    #tvbr_epg_root .separador-amanha-icon { font-size: 20px; }
}