/* ========== TV MODE STYLES & REMOTE CONTROL NAVIGATION ========== */

.tv-focus-indicator {
    position: absolute;
    pointer-events: none;
    border: 4px solid #ff8c00;
    border-radius: 12px;
    box-shadow: 
        0 0 0 4px rgba(255, 140, 0, 0.3),
        0 0 20px rgba(255, 140, 0, 0.6),
        inset 0 0 20px rgba(255, 140, 0, 0.2);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
    opacity: 0;
    animation: tvPulse 2s ease-in-out infinite;
}

@keyframes tvPulse {
    0%, 100% {
        box-shadow: 
            0 0 0 4px rgba(255, 140, 0, 0.3),
            0 0 20px rgba(255, 140, 0, 0.6),
            inset 0 0 20px rgba(255, 140, 0, 0.2);
    }
    50% {
        box-shadow: 
            0 0 0 6px rgba(255, 140, 0, 0.4),
            0 0 30px rgba(255, 140, 0, 0.8),
            inset 0 0 30px rgba(255, 140, 0, 0.3);
    }
}

.tv-focused {
    outline: none !important;
    transform: scale(1.05);
    z-index: 100;
    position: relative;
}

body.tv-mode {
    /* cursor: none; */ /* Deshabilitado para mantener cursor visible en TV */
}

body.tv-mode * {
    /* cursor: none !important; */ /* Deshabilitado para mantener cursor visible en TV */
}

body.tv-mode :focus {
    outline: none;
}

/* ========== TV RESPONSIVE DESIGN - 1920px+ (Full HD TV) ========== */

@media (min-width: 1920px) {
    body {
        font-size: 20px;
        overflow-x: hidden;
    }
    
    .app-container,
    .container,
    .main-container {
        max-width: 1600px;
        margin: 0 auto;
        padding: 40px 60px;
    }
    
    h1 {
        font-size: 56px;
        margin-bottom: 30px;
    }
    
    h2 {
        font-size: 44px;
        margin-bottom: 25px;
    }
    
    h3 {
        font-size: 36px;
        margin-bottom: 20px;
    }
    
    h4 {
        font-size: 28px;
        margin-bottom: 18px;
    }
    
    p, span, div {
        font-size: 22px;
        line-height: 1.8;
    }
    
    button,
    .btn,
    a.button {
        min-height: 70px;
        min-width: 200px;
        padding: 20px 40px;
        font-size: 24px;
        border-radius: 20px;
        cursor: pointer;
    }
    
    input,
    textarea,
    select {
        min-height: 70px;
        padding: 20px 30px;
        font-size: 24px;
        border-radius: 15px;
    }
    
    .app-header,
    header {
        padding: 30px 60px;
        min-height: 100px;
    }
    
    .app-logo,
    .logo,
    .logo img {
        height: 80px;
        width: auto;
    }
    
    .icon-btn,
    .nav-btn {
        width: 70px;
        height: 70px;
        font-size: 32px;
    }
    
    .featured-carousel {
        height: 700px;
        margin: 40px;
        border-radius: 30px;
    }
    
    .team-logo {
        width: 120px;
        height: 120px;
        padding: 15px;
    }
    
    .score {
        font-size: 64px;
    }
    
    .match-title {
        font-size: 40px;
    }
    
    .tabs-container {
        padding: 40px 60px 30px;
    }
    
    .tab {
        padding: 25px 45px;
        font-size: 24px;
        border-radius: 20px;
    }
    
    .matches-grid,
    .news-grid,
    .channels-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 30px;
        padding: 30px 0;
    }
    
    .match-card,
    .news-card,
    .channel-card {
        border-radius: 25px;
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    
    .match-card:hover,
    .news-card:hover,
    .channel-card:hover,
    .tv-focused.match-card,
    .tv-focused.news-card,
    .tv-focused.channel-card {
        transform: scale(1.1);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
        z-index: 10;
    }
    
    .match-card-bg {
        height: 180px;
    }
    
    .match-card-content {
        padding: 25px;
    }
    
    .team-badge {
        width: 50px;
        height: 50px;
    }
    
    .team span {
        font-size: 18px;
    }
    
    .watch-btn {
        padding: 20px;
        font-size: 20px;
        border-radius: 18px;
        min-height: 65px;
    }
    
    .league-icon {
        width: 100px;
        height: 100px;
        font-size: 48px;
    }
    
    .league-btn span {
        font-size: 20px;
    }
    
    .news-card img {
        height: 250px;
    }
    
    .news-content {
        padding: 25px;
    }
    
    .news-content h4 {
        font-size: 24px;
    }
    
    .news-content p {
        font-size: 18px;
    }
    
    .channel-card-mini {
        padding: 40px;
    }
    
    .channel-icon-mini {
        width: 100px;
        height: 100px;
        font-size: 48px;
    }
    
    .standings-table {
        border-radius: 25px;
        font-size: 22px;
    }
    
    .standings-row {
        grid-template-columns: 80px 3fr 100px 100px 100px 120px;
        padding: 25px 40px;
        font-size: 22px;
        min-height: 80px;
    }
    
    .standings-team-logo {
        width: 45px;
        height: 45px;
    }
    
    .standings-team-name {
        font-size: 24px;
    }
    
    .bottom-nav {
        padding: 25px 60px;
        min-height: 120px;
    }
    
    .nav-btn {
        font-size: 36px;
        padding: 20px 35px;
    }
    
    .important-matches-btn {
        padding: 30px 40px;
        border-radius: 25px;
        min-height: 120px;
    }
    
    .btn-icon-wrapper {
        width: 80px;
        height: 80px;
    }
    
    .btn-icon-wrapper i {
        font-size: 36px;
    }
    
    .btn-title {
        font-size: 26px;
    }
    
    .btn-subtitle {
        font-size: 20px;
    }
    
    .modal-content {
        max-width: 1400px;
        border-radius: 30px;
        padding: 40px;
    }
    
    .modal-header {
        padding: 30px;
        font-size: 32px;
    }
    
    .modal-body {
        height: 800px;
        padding: 30px;
    }
    
    .close-modal,
    .modal-close {
        width: 70px;
        height: 70px;
        font-size: 32px;
    }
}

/* ========== 4K TV (3840px+) ========== */

@media (min-width: 3840px) {
    body {
        font-size: 28px;
    }
    
    .app-container,
    .container {
        max-width: 3200px;
        padding: 60px 100px;
    }
    
    h1 {
        font-size: 96px;
    }
    
    h2 {
        font-size: 72px;
    }
    
    h3 {
        font-size: 56px;
    }
    
    h4 {
        font-size: 44px;
    }
    
    button,
    .btn {
        min-height: 100px;
        min-width: 300px;
        padding: 30px 60px;
        font-size: 36px;
    }
    
    .featured-carousel {
        height: 1200px;
    }
    
    .team-logo {
        width: 200px;
        height: 200px;
    }
    
    .score {
        font-size: 120px;
    }
    
    .match-title {
        font-size: 64px;
    }
    
    .matches-grid,
    .news-grid,
    .channels-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 50px;
    }
}

/* ========== TV SPECIFIC INTERACTIONS ========== */

@media (hover: none) and (pointer: coarse) {
    body.tv-mode button:hover,
    body.tv-mode a:hover,
    body.tv-mode .btn:hover {
        background: inherit;
    }
    
    body.tv-mode .tv-focused {
        transform: scale(1.08);
    }
}

/* ========== SMART TV USER AGENT DETECTION ========== */

@supports (-webkit-overflow-scrolling: touch) {
    body.tv-mode {
        -webkit-overflow-scrolling: auto;
    }
}

/* ========== TV ACCESSIBILITY ========== */

body.tv-mode *:focus {
    outline: none;
}

body.tv-mode .tv-focused {
    animation: tvFocusPulse 1.5s ease-in-out infinite;
}

@keyframes tvFocusPulse {
    0%, 100% {
        transform: scale(1.05);
    }
    50% {
        transform: scale(1.08);
    }
}

/* ========== TV SCROLLBAR HIDDEN ========== */

body.tv-mode ::-webkit-scrollbar {
    display: none;
}

body.tv-mode {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ========== TV LOADING STATES ========== */

body.tv-mode .loading {
    font-size: 32px;
}

body.tv-mode .spinner {
    width: 80px;
    height: 80px;
    border-width: 8px;
}

/* ═══════════════════════════════════════════════════════
   MODO TV — Foco visible + Navegación control remoto
   ═══════════════════════════════════════════════════════ */

/* Anula el outline:none que ponía el archivo para tv-mode */
body.tv-mode *:focus { outline: revert; }

/* Anillo de foco naranja brillante — visible en cualquier fondo */
.server-node-card:focus,
.server-node-card:focus-visible {
    outline: none !important;
    background: rgba(255,107,53,0.16) !important;
    border-color: rgba(255,107,53,0.65) !important;
    box-shadow: 0 0 0 4px rgba(255,107,53,0.45),
                0 10px 36px rgba(0,0,0,0.55) !important;
    transform: scale(1.025) translateY(-2px) !important;
}
.server-node-card:focus .node-edge,
.server-node-card:focus-visible .node-edge {
    background: linear-gradient(180deg,#ff6b35,#ff4500) !important;
    box-shadow: 0 0 20px rgba(255,107,53,0.95) !important;
    width: 5px !important;
}
.server-node-card:focus .node-connect-btn,
.server-node-card:focus-visible .node-connect-btn {
    background: linear-gradient(135deg,#ff6b35,#ff4500) !important;
    transform: scale(1.18) !important;
}

/* Foco en tarjetas de partidos importantes */
.rim-card:focus,
.rim-card:focus-visible {
    outline: none !important;
    border: 2px solid rgba(255,107,53,0.75) !important;
    box-shadow: 0 0 0 3px rgba(255,107,53,0.38) !important;
    background: rgba(255,107,53,0.12) !important;
    transform: scale(1.015) !important;
}

/* Foco en tarjetas de búsqueda */
.smp-card:focus,
.smp-card:focus-visible {
    outline: none !important;
    border: 2px solid rgba(255,107,53,0.7) !important;
    box-shadow: 0 0 0 3px rgba(255,107,53,0.35) !important;
    background: rgba(255,107,53,0.08) !important;
}

/* Botones de modal - solo en modo TV, nunca en móvil */
body.tv-mode .back-modal-btn:focus-visible,
body.tv-mode .close-channel-selector:focus-visible,
body.tv-mode .close-important-modal:focus-visible,
body.tv-mode .close-search-modal:focus-visible,
body.tv-mode .nav-btn:focus-visible,
body.tv-mode .nav-reels-btn:focus-visible,
body.tv-mode .icon-btn:focus-visible,
body.tv-mode .lbar-btn:focus-visible {
    outline: 3px solid #ff6b35 !important;
    outline-offset: 3px !important;
}

/* ── Botón TV MODE en header ─────────────────────────── */
/* Oculto por defecto; solo visible cuando se detecta una TV real (clase tv-detected) */
.tv-toggle-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.14);
    color: var(--text, #eee);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: all .22s;
    flex-shrink: 0;
}
/* Solo aparece en TVs reales detectadas automáticamente */
body.tv-detected .tv-toggle-btn {
    display: flex;
}
.tv-toggle-btn:hover { background: rgba(255,107,53,0.2); border-color: rgba(255,107,53,.5); }
body.tv-mode .tv-toggle-btn:focus-visible { outline: 3px solid #ff6b35 !important; outline-offset: 3px !important; }
body.tv-mode .tv-toggle-btn {
    background: rgba(255,107,53,0.28);
    border-color: rgba(255,107,53,0.7);
    color: #ff6b35;
    box-shadow: 0 0 10px rgba(255,107,53,0.4);
}

/* ── Escalado automático canal selector en TV (≥960px) ── */
@media (min-width: 960px) {
    .channel-selector-content { max-width: 780px; max-height: 88vh; }
    .channel-selector-header h3 { font-size: 19px; }
    .server-node-card { padding: 18px 22px; min-height: 72px; }
    .node-name { font-size: 17px; }
    .node-provider-tag, .node-quality-tag { font-size: 12px; padding: 4px 10px; }
    .node-connect-btn { width: 46px; height: 46px; font-size: 18px; }
    .rim-card { padding: 16px 22px; min-height: 76px; }
    .rim-name { font-size: 15px; }
    .smp-card { padding: 16px 18px; min-height: 76px; }
    .smp-teams-row { font-size: 16px; }
}

/* ── body.tv-mode — tamaños XL para tele con cursor ─────── */
body.tv-mode .channel-selector-content { max-width: 900px; max-height: 92vh; }
body.tv-mode .channel-selector-header h3 { font-size: 22px; }
body.tv-mode .server-node-card { padding: 22px 28px; min-height: 88px; border-radius: 22px; }
body.tv-mode .node-name { font-size: 20px; font-weight: 700; }
body.tv-mode .node-provider-tag,
body.tv-mode .node-quality-tag { font-size: 14px; padding: 5px 12px; border-radius: 8px; }
body.tv-mode .node-connect-btn { width: 54px; height: 54px; font-size: 22px; }
body.tv-mode .node-latency { font-size: 13px; font-weight: 700; }
body.tv-mode .server-grid-creative { gap: 14px; }
body.tv-mode .back-modal-btn { padding: 12px 20px; font-size: 16px; font-weight: 700; }
body.tv-mode .close-channel-selector,
body.tv-mode .close-important-modal { width: 46px; height: 46px; font-size: 18px; }
body.tv-mode .rim-card { padding: 20px 26px; min-height: 88px; border-radius: 16px; }
body.tv-mode .rim-name { font-size: 18px; font-weight: 700; }
body.tv-mode .rim-vs { font-size: 15px; }
body.tv-mode .smp-card { padding: 20px 22px; min-height: 90px; }
body.tv-mode .smp-teams-row { font-size: 19px; }
body.tv-mode .server-count-badge { font-size: 13px; padding: 5px 12px; }
body.tv-mode .channel-selector-body::-webkit-scrollbar { width: 6px; }
body.tv-mode .channel-selector-body::-webkit-scrollbar-thumb { background: #ff6b35; border-radius: 3px; }

/* ═══════════════════════════════════════════════════════
   BARRA DE BOTONES DE COLOR — Control Remoto TV
   ═══════════════════════════════════════════════════════ */

/* Oculta por defecto — solo aparece en modo TV */
.tv-color-bar {
    display: none;
    position: fixed;
    bottom: 78px; /* justo encima del bottom-nav */
    left: 0;
    right: 0;
    z-index: 1400;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(180deg, transparent, rgba(0,0,0,0.82));
    pointer-events: none;
}

/* Solo aparece si el dispositivo es detectado como TV (auto) */
body.tv-detected .tv-color-bar {
    display: flex;
    pointer-events: all;
    animation: tvBarIn .35s ease both;
}

@keyframes tvBarIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tv-color-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    padding: 6px 14px 6px 8px;
    cursor: pointer;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    transition: transform .18s, box-shadow .18s, background .18s;
    backdrop-filter: blur(8px);
    white-space: nowrap;
}
.tv-color-btn:hover,
.tv-color-btn:focus-visible {
    transform: scale(1.08);
    background: rgba(0,0,0,0.75);
    outline: 2px solid rgba(255,255,255,0.4) !important;
    outline-offset: 2px !important;
}
.tv-color-btn:active { transform: scale(0.95); }

.tv-color-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Colores de cada botón */
.tv-red    .tv-color-dot { background: #e53935; box-shadow: 0 0 8px rgba(229,57,53,.7); }
.tv-green  .tv-color-dot { background: #43a047; box-shadow: 0 0 8px rgba(67,160,71,.7); }
.tv-yellow .tv-color-dot { background: #fdd835; box-shadow: 0 0 8px rgba(253,216,53,.7); }
.tv-blue   .tv-color-dot { background: #1e88e5; box-shadow: 0 0 8px rgba(30,136,229,.7); }

.tv-red:hover    { border-color: rgba(229,57,53,.5);   }
.tv-green:hover  { border-color: rgba(67,160,71,.5);   }
.tv-yellow:hover { border-color: rgba(253,216,53,.5);  }
.tv-blue:hover   { border-color: rgba(30,136,229,.5);  }

.tv-color-label { color: rgba(255,255,255,0.9); }

/* En pantallas grandes la barra sube un poco más */
@media (min-width: 960px) {
    .tv-color-bar { bottom: 90px; gap: 12px; }
    .tv-color-btn { padding: 8px 18px 8px 10px; font-size: 13px; }
    .tv-color-dot { width: 16px; height: 16px; }
}

body.tv-detected .tv-color-bar {
    bottom: 82px;
}
