/* =========================================================
   BELLO ORIENTE TV - Sidebar de canales + transicion swipe
   Archivo aditivo: no modifica css/tv-channels.css existente.
   ========================================================= */

/* ===== Modal / player mas grande, tipo "reproductor completo" ===== */
.bo-tv-modal-dialog {
    max-width: 960px;
    width: 92vw;
    max-height: 90vh;
    margin: 5vh auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    position: relative;
}

/* El X que cierra TODO el modal se mueve a la izquierda para que nunca
   quede pegado/encimado con el X que solo cierra la lista de canales
   (ese esta en la esquina derecha del sidebar). */
#bo-tv-modal .uk-modal-close-default {
    top: 10px;
    left: 10px;
    right: auto;
}

.bo-tv-player-wrap {
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 62vh;
    background: #000;
    flex-shrink: 0;
}

/* Forzar que el video y el iframe de YouTube llenen siempre el recuadro,
   sin importar reglas previas de css/tv-channels.css. */
.bo-tv-player-wrap .bo-tv-video,
.bo-tv-player-wrap #bo-tv-youtube-wrap,
.bo-tv-player-wrap #bo-tv-youtube-wrap iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    border: none;
}

/* ===== Boton "Canales" en los controles del reproductor ===== */
.bo-tv-controls .bo-tv-btn#bo-tv-channels-btn {
    margin-left: auto;
}

/* Auto-ocultado de controles por inactividad (6s, ver tv-channels.js) */
.bo-tv-controls {
    transition: opacity 0.35s ease;
}

.bo-tv-controls.bo-tv-controls-hidden {
    opacity: 0;
    pointer-events: none;
}

/* ===== SIDEBAR DE CANALES (dentro del reproductor, desliza desde la derecha) ===== */
.bo-tv-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    min-width: 220px;
    max-width: 80%;
    height: 100%;
    background: rgba(10, 10, 10, 0.94);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 30;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
}

.bo-tv-sidebar.open {
    transform: translateX(0);
}

.bo-tv-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    color: #fff;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.bo-tv-sidebar-header span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bo-tv-sidebar-close {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.25s ease;
}

.bo-tv-sidebar-close:hover {
    background: #c35332;
    transform: rotate(90deg);
}

.bo-tv-channels-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

.bo-tv-channels-grid::-webkit-scrollbar { width: 5px; }
.bo-tv-channels-grid::-webkit-scrollbar-track { background: transparent; }
.bo-tv-channels-grid::-webkit-scrollbar-thumb { background: rgba(195, 83, 50, 0.4); border-radius: 3px; }

/* Item individual del sidebar */
.bo-tv-sb-item {
    position: relative;
    background: #111;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    text-align: center;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    padding: 0;
    transition: all 0.25s ease;
    color: #ccc;
}

.bo-tv-sb-item:hover {
    border-color: rgba(195, 83, 50, 0.6);
    transform: translateY(-2px);
}

.bo-tv-sb-item.is-active {
    border-color: #c35332;
    box-shadow: 0 0 0 1px #c35332 inset;
}

.bo-tv-sb-item.is-disabled {
    opacity: 0.4;
    filter: grayscale(80%);
    cursor: not-allowed;
}

.bo-tv-sb-img-box {
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0a0a;
    flex-shrink: 0;
}

.bo-tv-sb-img-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.bo-tv-sb-name {
    font-size: 0.68rem;
    color: #bbb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 6px 4px 8px;
}

.bo-tv-sb-disabled-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
}

/* ===== OVERLAY DE TRANSICION DESLIZANTE (SWIPE ENTRE CANALES) ===== */
.bo-tv-transition-overlay {
    position: absolute;
    inset: 0;
    z-index: 15;
    overflow: hidden;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.bo-tv-transition-overlay.active {
    opacity: 1;
}

.bo-tv-transition-frame {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-color: #000;
    display: none;
}

.bo-tv-transition-next {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: #000;
}

.bo-tv-transition-next img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    animation: boTvTransitionPulse 1.3s ease-in-out infinite;
    filter: drop-shadow(0 0 16px rgba(195, 83, 50, 0.4));
}

.bo-tv-transition-next span {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #fff;
    text-transform: uppercase;
    text-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
}

@keyframes boTvTransitionPulse {
    0%, 100% { opacity: 0.6; transform: scale(0.96); }
    50%      { opacity: 1;   transform: scale(1.03); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    /* En mobile el modal pasa a ser pantalla completa: nada de modal
       flotando a media altura, es un reproductor inmersivo. */
    .bo-tv-modal-dialog {
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        border-radius: 0;
    }

    /* El video ya no tiene una proporcion fija: crece para llenar todo
       el alto disponible (arriba/abajo del titulo). Las barras negras,
       si las hay, dependen del stream, no del contenedor. */
    .bo-tv-player-wrap {
        aspect-ratio: auto;
        max-height: none;
        flex: 1 1 auto;
        min-height: 0;
    }

    #bo-tv-modal-title {
        flex-shrink: 0;
        font-size: 0.85rem;
        padding-top: 6px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* El panel de canales ya NO tapa toda la pantalla: sale solo lo
       suficiente para mostrar la lista comoda, dejando ver una franja
       del video/canal a un costado. */
    .bo-tv-sidebar {
        width: 85%;
        max-width: 340px;
        min-width: 260px;
    }

    .bo-tv-channels-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 10px;
    }
    .bo-tv-sb-img-box { height: 56px; }
    .bo-tv-sb-name { font-size: 0.68rem; }

    .bo-tv-transition-next img { width: 70px; height: 70px; }

    /* Botones con area de toque comoda para el dedo */
    .bo-tv-controls .bo-tv-btn,
    .bo-tv-sidebar-close,
    .uk-modal-close-default {
        min-width: 40px;
        min-height: 40px;
    }
}

@media (min-width: 641px) and (max-height: 700px) {
    .bo-tv-player-wrap {
        max-height: 50vh;
    }
}