/* ============================================================
   TV EN VIVO — estilo alineado con single-peliculas
   Todas las clases usan el prefijo único "sptv-" para no
   colisionar con el CSS de single-peliculas ni con otras
   plantillas del tema.
   ============================================================ */

:root {
    --sptv-bg: #141414;
    --sptv-sidebar-bg: #1a1a1a;
    --sptv-card-bg: #242424;
    --sptv-primary: #ff2c2c;
    --sptv-primary-hover: #d82323;
    --sptv-gold: #facc15;
    --sptv-text: #e6e6e6;
    --sptv-text-soft: #dbdbdb;
    --sptv-text-muted: #888;
    --sptv-border: #333;
    --sptv-hover: rgba(255, 255, 255, .06);
    --sptv-pill-bg: rgba(255, 255, 255, .1);
    --sptv-pill-bg-hover: rgba(255, 255, 255, .18);
    --sptv-radius-lg: 15px;
    --sptv-radius-md: 10px;
    --sptv-radius-sm: 6px;
}

.sptv-container {
    max-width: 100%;
}

.sptv-container ::-webkit-scrollbar,
.sptv-content-sidebar::-webkit-scrollbar {
    width: 5px;
}

.sptv-container ::-webkit-scrollbar-track {
    background: transparent;
}

.sptv-container ::-webkit-scrollbar-thumb {
    background: var(--sptv-primary);
    border-radius: 4px;
}

.sptv-container {
    scrollbar-width: thin;
    scrollbar-color: var(--sptv-primary) var(--sptv-sidebar-bg);
}

/* ===== CONTENEDOR PRINCIPAL ===== */
.sptv-tv-live-container {
    background: var(--sptv-bg);
    border-radius: var(--sptv-radius-lg);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
    border: 1px solid var(--sptv-border);
    position: relative;
    margin: 16px 0;
    display: flex;
    height: 82vh;
    min-height: 500px;
}

/* ===== REPRODUCTOR ===== */
.sptv-player-section {
    flex: 0 0 70%;
    max-width: 70%;
    display: none;
    padding: 1rem;
    border-right: 1px solid var(--sptv-border);
    position: relative;
}

.sptv-player-section.active {
    display: block;
}

.sptv-player-container {
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: var(--sptv-radius-md);
    overflow: hidden;
    border: 1px solid var(--sptv-border);
    position: relative;
}

.sptv-player-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
}

#tv-live-player {
    background: #000 !important;
    width: 100% !important;
    height: 100% !important;
    position: absolute;
    top: 0;
    left: 0;
}

.video-js .vjs-big-play-button {
    border: 3px solid #fff !important;
    background: rgba(0, 0, 0, .7) !important;
    border-radius: 50% !important;
    width: 80px !important;
    height: 80px !important;
    line-height: 80px !important;
    font-size: 40px !important;
    margin: 0 !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 100 !important;
}

.video-js.vjs-playing .vjs-big-play-button {
    opacity: 0 !important;
    pointer-events: none !important;
    display: none !important;
}

.video-js .vjs-big-play-button:hover {
    background: var(--sptv-primary) !important;
    border-color: var(--sptv-primary) !important;
    transform: translate(-50%, -50%) scale(1.1) !important;
}

.video-js .vjs-control-bar {
    background: rgba(0, 0, 0, .85) !important;
}

.video-js .vjs-play-progress,
.video-js .vjs-volume-level {
    background: var(--sptv-primary) !important;
}

.sptv-player-loading,
.sptv-player-error {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--sptv-text-muted);
    z-index: 5;
    text-align: center;
    padding: 2rem;
}

.sptv-player-loading { background: rgba(0, 0, 0, .9); }
.sptv-player-error { background: rgba(0, 0, 0, .95); }

.sptv-loader-icon {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid var(--sptv-border);
    border-top-color: var(--sptv-primary);
    border-radius: 50%;
    animation: sptv-spin .8s linear infinite;
}

@keyframes sptv-spin { to { transform: rotate(360deg); } }

.sptv-error-icon { font-size: 3rem; }

/* ===== BOTONES EN PASTILLA (mismo lenguaje que single-peliculas) ===== */
.sptv-retry-btn {
    background: var(--sptv-primary);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    transition: background .3s;
}

.sptv-retry-btn:hover { background: var(--sptv-primary-hover); }

.sptv-retry-btn-alt {
    background: var(--sptv-pill-bg);
    margin-top: 4px;
}

.sptv-retry-btn-alt:hover {
    background: var(--sptv-pill-bg-hover);
}

.sptv-mute-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, .75);
    color: #fff;
    padding: 10px 15px;
    border-radius: 999px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: .5rem;
    z-index: 6;
    cursor: pointer;
    transition: background .3s;
    backdrop-filter: blur(10px);
}

.sptv-mute-indicator:hover { background: rgba(0, 0, 0, .9); }

/* ===== SIDEBAR DE PAÍSES / CANALES ===== */
.sptv-content-sidebar {
    flex: 1;
    background: var(--sptv-sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: all .3s ease;
}

.sptv-tv-live-container:not(.has-player) .sptv-content-sidebar {
    flex: 0 0 100%;
    max-width: 100%;
}

.sptv-tv-live-container.has-player .sptv-content-sidebar {
    flex: 0 0 30%;
    max-width: 30%;
}

.sptv-sidebar-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility .3s ease;
}

.sptv-sidebar-view.active {
    opacity: 1;
    visibility: visible;
    position: relative;
}

.sptv-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--sptv-border);
    flex-shrink: 0;
}

.sptv-sidebar-header h3 {
    color: var(--sptv-text);
    margin: 0 0 14px 0;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.sptv-search-container {
    position: relative;
}

.sptv-search-input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border-radius: var(--sptv-radius-md);
    border: 1px solid var(--sptv-border);
    background: var(--sptv-sidebar-bg);
    color: var(--sptv-text);
    font-size: 13px;
    transition: all .3s ease;
    font-family: inherit;
    box-sizing: border-box;
}

.sptv-search-input:focus {
    outline: none;
    border-color: var(--sptv-primary);
    background: #202020;
}

.sptv-clear-search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--sptv-text-muted);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0;
    width: 24px;
    height: 24px;
    display: none;
    transition: color .3s ease;
}

.sptv-clear-search-btn:hover {
    color: var(--sptv-primary);
}

.sptv-search-input:not(:placeholder-shown) + .sptv-clear-search-btn {
    display: block;
}

.sptv-countries-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.sptv-no-countries {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--sptv-text-muted);
}

.sptv-country-item,
.sptv-channel-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: 8px;
    border-radius: var(--sptv-radius-md);
    cursor: pointer;
    transition: background .2s ease, transform .2s ease;
    background: var(--sptv-card-bg);
    border: 1px solid transparent;
    min-height: 50px;
}

.sptv-country-item:hover,
.sptv-channel-item:hover,
.sptv-channel-item.active {
    background: var(--sptv-hover);
    border-color: var(--sptv-border);
    transform: translateX(2px);
}

.sptv-country-item.selected,
.sptv-channel-item.active {
    background: var(--sptv-primary) !important;
    border-color: var(--sptv-primary) !important;
    color: #fff;
}

.sptv-country-flag,
.sptv-channel-country-flag {
    width: 32px;
    height: 24px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
    border: 1px solid var(--sptv-border);
    flex-shrink: 0;
}

.sptv-country-custom-image {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 50%;
    margin-right: 14px;
    border: 1px solid var(--sptv-border);
    flex-shrink: 0;
    background: var(--sptv-card-bg);
}

.sptv-country-info,
.sptv-channel-info {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    height: 100%;
    gap: 8px;
}

.sptv-country-name,
.sptv-channel-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--sptv-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

.sptv-country-item.selected .sptv-country-name,
.sptv-channel-item.active .sptv-channel-name {
    color: #fff;
}

.sptv-channels-header {
    padding: 16px;
    border-bottom: 1px solid var(--sptv-border);
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    background: var(--sptv-sidebar-bg);
    min-height: 60px;
}

.sptv-back-button {
    background: var(--sptv-pill-bg);
    color: var(--sptv-text);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .25s ease;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.sptv-back-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 1.2rem;
}

.sptv-back-button:hover {
    background: var(--sptv-primary);
    color: #fff;
    transform: scale(1.05);
}

.sptv-selected-country-info {
    flex: 1;
    margin: 0;
}

.sptv-selected-country-info h3 {
    color: var(--sptv-text);
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sptv-channels-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.sptv-channels-placeholder,
.sptv-no-channels {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--sptv-text-muted);
}

.sptv-channels-loading {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--sptv-text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.sptv-channel-language {
    display: inline-block;
    background: rgba(255, 44, 44, .12);
    color: var(--sptv-primary);
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid rgba(255, 44, 44, .25);
    margin-left: auto;
    flex-shrink: 0;
    white-space: nowrap;
}

.sptv-channel-item.active .sptv-channel-language {
    background: rgba(255, 255, 255, .2) !important;
    color: #fff !important;
    border-color: rgba(255, 255, 255, .3) !important;
}

@keyframes sptv-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.sptv-channel-item { animation: sptv-fadeIn .3s ease-out; }

/* ===== TOUCH / SMART TV ===== */
@media (hover: none) and (pointer: coarse) {
    .video-js .vjs-control-bar { height: 40px !important; }
    .video-js .vjs-control { width: 40px !important; height: 40px !important; }
    .video-js .vjs-big-play-button {
        width: 100px !important;
        height: 100px !important;
        line-height: 100px !important;
        font-size: 50px !important;
    }
    .sptv-country-item, .sptv-channel-item { padding: 1rem; min-height: 55px; }
    .sptv-back-button { width: 45px; height: 45px; }
}

@media (min-width: 1920px) {
    .video-js .vjs-control-bar { height: 50px !important; font-size: 18px !important; }
    .video-js .vjs-control { height: 50px !important; }
    .sptv-mute-indicator { font-size: 1rem; padding: 15px 20px; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
    .sptv-tv-live-container { height: 65vh; }
}

@media (max-width: 1024px) {
    /* ===== SE ELIMINA CUALQUIER PADDING/MARGEN HEREDADO DEL TEMA EN ESTA
       PLANTILLA (sptv-container y sptv-site-main son clases exclusivas de
       TV en Vivo, así que este reset no afecta a ninguna otra página) ===== */
    .sptv-container,
    .sptv-site-main {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* ===== CONTENEDOR A TODO EL ANCHO, ALTURA ACOTADA (edge-to-edge, como single) =====
       Igual que en escritorio, el widget completo tiene una altura fija:
       eso es lo que permite que el reproductor y los títulos queden fijos
       y que SOLO las listas (#countries-list / #channels-list) hagan
       scroll internamente. La página en sí no se mueve dentro del widget. */
    .sptv-tv-live-container {
        flex-direction: column;
        height: 85vh;
        min-height: 480px;
        margin: 0;
        width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
        overflow: hidden;
    }

    /* ===== REPRODUCTOR A TODO EL ANCHO, ARRIBA, TAMAÑO FIJO POR aspect-ratio ===== */
    .sptv-player-section {
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
        padding: 0;
        border-right: none;
        border-bottom: 1px solid var(--sptv-border);
        position: static;
        aspect-ratio: 16 / 9;
        height: auto;
        min-height: 0;
    }

    .sptv-player-container,
    .sptv-player-wrapper {
        border-radius: 0;
        border: none;
    }

    /* ===== SIDEBAR: OCUPA EL RESTO DE LA ALTURA =====
       (mismo selector con y sin .has-player para ganar en especificidad
       a las reglas de escritorio que reparten 70%/30%). min-height:0 es
       necesario para que el flex-child pueda encogerse y su lista interna
       (flex:1; overflow-y:auto) sea la que realmente haga scroll. */
    .sptv-content-sidebar,
    .sptv-tv-live-container.has-player .sptv-content-sidebar,
    .sptv-tv-live-container:not(.has-player) .sptv-content-sidebar {
        flex: 1 1 auto;
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 0;
    }

    .sptv-channels-header { padding: 12px; min-height: 50px; }
    .sptv-back-button { width: 35px; height: 35px; }
    .sptv-back-arrow { font-size: 1.1rem; }
    .sptv-selected-country-info h3 { font-size: 1rem; }
}

@media (max-width: 768px) {
    .sptv-tv-live-container { height: 82vh; min-height: 440px; }
    .sptv-player-section { padding: 0; }
    .sptv-country-item, .sptv-channel-item { padding: 10px 12px; min-height: 45px; }
    .sptv-country-flag, .sptv-channel-country-flag { width: 28px; height: 21px; margin-right: 10px; }
    .sptv-country-name, .sptv-channel-name { font-size: 13px; }
    .sptv-channel-language { font-size: 10px; padding: 2px 6px; }
    .sptv-mute-indicator { top: 15px; right: 15px; font-size: 12px; padding: 8px 12px; }
    .sptv-sidebar-header { padding: 16px; }
    .sptv-retry-btn { font-size: 13px; padding: 9px 16px; }
}

@media (max-width: 480px) {
    .sptv-tv-live-container { height: 80vh; min-height: 400px; }
    .sptv-sidebar-header { padding: 14px; }
    .sptv-sidebar-header h3 { font-size: 1rem; }
    .sptv-search-input { padding: 8px 34px 8px 12px; font-size: 12px; }
    .sptv-channels-header { padding: 10px; min-height: 45px; }
    .sptv-back-button { width: 30px; height: 30px; }
    .sptv-selected-country-info h3 { font-size: .9rem; }
    .sptv-country-item, .sptv-channel-item { padding: 8px 10px; min-height: 40px; }
    .sptv-country-flag, .sptv-channel-country-flag { width: 24px; height: 18px; margin-right: 8px; }
    .sptv-country-name, .sptv-channel-name { font-size: 12px; }
    .sptv-mute-indicator { top: 10px; right: 10px; font-size: 11px; padding: 6px 10px; }
    .sptv-retry-btn { font-size: 12px; padding: 8px 14px; }
    .sptv-error-icon { font-size: 2.2rem; }
}