/* ── Lo que se rescató del CSS de la radio anterior ──────────────────────
 *
 * Esta página heredó su cabecera y su fondo de una hoja de estilos de 13 KB
 * que vino con el código del que salió este proyecto. De sus 82 clases, /tv
 * usaba DIEZ: la cabecera, la marca y los tres orbes del fondo. Las otras
 * setenta y dos eran widgets de aquel sitio —el tiempo, el santoral, los
 * planes, el cajón de historial, el temporizador de apagado— que aquí no
 * existen ni van a existir.
 *
 * Así que se trajeron las diez a mano y el archivo se borró. Traerlas no era
 * opcional: `tv.css` consumía siete variables (--aurora-*, --glass, --text,
 * --font) que sólo estaban allí, y sin ellas esta página se quedaba sin
 * colores y sin tipografía.
 *
 * «Aurora» es la aurora boreal: el nombre del fondo de manchas de color, y se
 * conserva porque describe lo que hace. Los dos primeros colores resultan ser
 * los del logo de EstudioLive, así que el fondo ya estaba en la marca sin
 * saberlo.
 */

:root {
    --aurora-1:     #4a00e0;
    --aurora-2:     #8e2de2;
    --aurora-3:     #00f260;
    --text:         #ffffff;
    --glass:        rgba(255, 255, 255, .05);
    --glass-border: rgba(255, 255, 255, .1);
    --font:         'Space Grotesk', sans-serif;

    /* ── Movimiento ──────────────────────────────────────────────────────
       Los mismos cuatro tiempos y las mismas cuatro curvas de Switch
       Control. Se copian en vez de compartirse: esta hoja no toma ni una
       variable de cabina.css —las paletas divergen a propósito— y un tercer
       archivo bloquearía el primer pintado justo aquí, que es la página que
       se abre en televisores y en teléfonos con mala conexión.
       Si allá cambian, aquí también. */
    --tv-mov-1: 130ms;   /* un color, un borde, un punto */
    --tv-mov-2: 190ms;   /* un botón, una pastilla */
    --tv-mov-3: 300ms;   /* un bloque que entra o se retira */
    --tv-mov-4: 320ms;   /* la escena entera */

    --tv-sal:     cubic-bezier(.33, 1, .68, 1);      /* llega y frena */
    --tv-amb:     cubic-bezier(.4, 0, .2, 1);        /* ida y vuelta */
    --tv-firme:   cubic-bezier(.16, 1, .3, 1);       /* mucho recorrido */
    --tv-resorte: cubic-bezier(.34, 1.48, .58, 1);   /* pasa de largo y vuelve */

    /* El mismo compás del aire que el panel: si el operador y el público
       miran dos pantallas a la vez, los dos rojos tienen que ir juntos. */
    --tv-latido: 1.7s;

    /* La misma escalera de esquinas del panel. Un cliente que pasa de su
       Switch Control a su /tv veía las mismas cajas con radios distintos. */
    --tv-r1: 6px; --tv-r2: 9px; --tv-r3: 11px; --tv-r4: 14px; --tv-r5: 18px;
    --tv-rp: 999px;

    /* En un televisor no hay puntero: el mando mueve el foco y el anillo es
       la única forma de saber dónde está. Esta hoja no tenía ni uno. */
    --tv-foco:   #818cf8;
    --tv-anillo: 0 0 0 3px rgba(99, 102, 241, .32);
}

/* El fondo: tres manchas enormes y desenfocadas que se mueven despacio.
   `tv.css` ya lo reposiciona más abajo (fixed y opacidad .18). */
.aurora-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; opacity: .6; }

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    animation: float 20s ease-in-out forwards;
}
.orb-1 { width: 60vw; height: 60vw; background: var(--aurora-1); top: -10%;    left: -10%;  animation-duration: 25s; }
.orb-2 { width: 50vw; height: 50vw; background: var(--aurora-2); bottom: -10%; right: -10%; animation-duration: 20s; }
.orb-3 { width: 30vw; height: 30vw; background: var(--aurora-3); top: 40%;     left: 40%;   animation-duration: 30s; }

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(30px, -30px); }
}

/* Tres manchas de 60vw desenfocadas moviéndose sin parar es justo lo que
   molesta a quien pide menos movimiento. */
@media (prefers-reduced-motion: reduce) {
    .orb { animation: none; }
}

/* La cabecera. */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    position: relative;
    z-index: 20;
}
.brand          { display: flex; align-items: center; gap: .8rem; }
.logo           { width: 60px; height: 60px; filter: drop-shadow(0 0 10px rgba(74, 0, 224, .4)); }
.header-actions { display: flex; align-items: center; gap: .5rem; }

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    cursor: pointer;
    opacity: .8;
    transition: all .2s;
}
.icon-btn:hover { opacity: 1; background: rgba(255, 255, 255, .1); }

@media (max-width: 768px) {
    .header         { padding: .5rem 0; min-height: 60px; }
    .logo           { height: 65px; width: auto; max-width: 140px; object-fit: contain; }
    .header-actions { gap: 5px; }
}
@media (max-width: 480px) {
    .logo { width: 130px; height: auto; }
}

/**
 * Modo TV — vista de pantalla fija.
 *
 * La pagina cabe entera en el viewport y no se corre hacia abajo: en
 * computador el video ocupa la columna principal y el chat en vivo va al
 * costado con su propio scroll; en celular el video queda arriba y el chat
 * ocupa el resto del alto.
 *
 * Todos los selectores llevan prefijo "tv-" salvo las anulaciones bajo
 * body.tv-page, que corrigen las reglas heredadas de arriba. tv.css solo se
 * carga en tv.php, asi que nada de esto alcanza al resto del sitio.
 */

/* ── Anulaciones de lo heredado ─────────────────────────────────────────
   Las reglas que vinieron con la cabecera dejaban el body en height:100vh con
   overflow:hidden y el .app-container topado en 500px, medidas pensadas para
   la capsula de un reproductor. Aqui se necesita el ancho completo y control
   propio del alto. */

body.tv-page {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    display: block;
}

body.tv-page .aurora-bg {
    position: fixed;
    opacity: 0.18;
}

body.tv-page .app-container {
    max-width: 1500px;
    height: 100dvh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Fallback para navegadores sin dvh (barra de direcciones del movil). */
@supports not (height: 100dvh) {
    body.tv-page,
    body.tv-page .app-container {
        height: 100vh;
        min-height: 100vh;
    }
}

/* ── Marca en el header ─────────────────────────────────────────────── */

.tv-brand-link {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
    color: var(--text);
}

.tv-brand-name {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    opacity: 0.85;
}

/* ── Escenario: video + chat ────────────────────────────────────── */

.tv-stage {
    flex: 1;
    min-height: 0;            /* sin esto, un hijo con scroll desborda el flex */
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 1.5rem;
    padding-bottom: 1rem;
    overflow: hidden;
}

.tv-video-col {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

/* ── Encabezado de la señal ─────────────────────────────────────────── */

.tv-signal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    flex: 0 0 auto;
}

.tv-signal-title {
    font-size: clamp(1.1rem, 2.2vw, 1.6rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    /* Un nombre largo no debe empujar el video fuera de la pantalla. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* El atributo hidden debe ganar siempre: .tv-pill y .tv-placeholder traen
   display por clase, que tiene más especificidad que el hidden del
   navegador, y sin esto el aviso de "sin transmisión" se quedaría encima del
   reproductor al empezar la señal. */
[hidden] { display: none !important; }

.tv-pill {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    color: var(--text);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    flex: 0 0 auto;
}

.tv-pill-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--aurora-3);
    flex: 0 0 auto;
}

.tv-pill-live {
    background: rgba(255, 0, 0, 0.12);
    border-color: rgba(255, 59, 48, 0.35);
    color: #ff5b52;
}

.tv-pill-live .tv-pill-dot {
    background: #ff3b30;
    animation: tv-pulse var(--tv-latido) var(--tv-amb) infinite;
}

@keyframes tv-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
    .tv-pill-live .tv-pill-dot {
        animation: none;
    }
}

/* ── Marco del video ────────────────────────────────────────────────────
   Ocupa el alto que sobra y mantiene 16:9 sin desbordar: por eso el ancho
   se limita con aspect-ratio en vez de fijar la altura. */

.tv-frame {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: calc((100dvh - 260px) * 16 / 9);
    aspect-ratio: 16 / 9;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    background: #050505;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

@supports not (aspect-ratio: 16 / 9) {
    .tv-frame {
        max-width: none;
    }
}

.tv-frame iframe,
.tv-frame .tv-senal,
.tv-frame .tv-placeholder {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* La señal propia puede no venir en 16:9 (un móvil de pie, por ejemplo):
   se muestra entera sobre negro en vez de recortarla. */
.tv-frame .tv-senal {
    object-fit: contain;
    background: #000;
}

/* ── Estado sin señal ───────────────────────────────────────────────── */

.tv-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.6rem;
    padding: 2rem 1.5rem;
    background:
        radial-gradient(circle at 50% 40%, rgba(74, 0, 224, 0.18), transparent 60%),
        #050505;
}

.tv-placeholder-icon {
    opacity: 0.35;
    margin-bottom: 0.4rem;
}

.tv-placeholder-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.tv-placeholder-text {
    font-size: 0.92rem;
    opacity: 0.6;
    max-width: 34ch;
    line-height: 1.5;
}

/* ── Acciones ───────────────────────────────────────────────────────── */

.tv-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    flex: 0 0 auto;
}

.tv-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    border-radius: 14px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.tv-action:hover  { background: rgba(255, 255, 255, 0.11); }
.tv-action:active { transform: scale(0.97); }

.tv-action-primary {
    background: linear-gradient(135deg, var(--aurora-1), var(--aurora-2));
    border-color: transparent;
}

.tv-action-primary:hover {
    background: linear-gradient(135deg, var(--aurora-2), var(--aurora-1));
}


/* ── Chat en vivo ───────────────────────────────────────────────────── */

.tv-chat-col {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.tv-chat-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    flex: 0 0 auto;
}

.tv-chat-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    opacity: 0.5;
}

.tv-chat-status {
    font-size: 0.7rem;
    opacity: 0.45;
    white-space: nowrap;
}

/* El scroll vive aqui dentro, no en la pagina: tv.php es de pantalla fija. */
.tv-chat-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    list-style: none;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    overscroll-behavior: contain;   /* no arrastrar la pagina al llegar al tope */
}

.tv-chat-list::-webkit-scrollbar       { width: 6px; }
.tv-chat-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border-radius: 3px; }
.tv-chat-list::-webkit-scrollbar-track { background: transparent; }

.tv-chat-msg {
    flex: 0 0 auto;
    padding: 0.5rem 0.7rem;
    border-radius: 12px;
    background: rgba(14, 14, 20, 0.72);
    border: 1px solid var(--glass-border);
}

/* Los mensajes del equipo se distinguen. El distintivo lo otorga el
   servidor solo con sesion de admin abierta: nadie puede pintarse asi
   eligiendo un nombre. */
.tv-chat-msg-staff {
    background: rgba(74, 0, 224, 0.18);
    border-color: rgba(142, 45, 226, 0.5);
}

.tv-chat-msg-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
}

/* Etiqueta de la plataforma de origen: web, TikTok, YouTube… */
.tv-chat-tag {
    font-size: 0.56rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    padding: 2px 6px;
    border-radius: 5px;
    white-space: nowrap;
    flex: 0 0 auto;
}

.tv-chat-author {
    font-size: 0.74rem;
    font-weight: 700;
    opacity: 0.9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 45%;
}

.tv-chat-staff {
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--aurora-3);
    border: 1px solid rgba(0, 242, 96, 0.4);
    border-radius: 4px;
    padding: 1px 4px;
}

.tv-chat-time {
    font-size: 0.65rem;
    opacity: 0.4;
    margin-left: auto;
    flex: 0 0 auto;
}

.tv-chat-text {
    font-size: 0.85rem;
    line-height: 1.4;
    /* Un pegote sin espacios no debe estirar la columna. */
    overflow-wrap: anywhere;
    word-break: break-word;
}

.tv-chat-empty {
    font-size: 0.82rem;
    opacity: 0.45;
    padding: 0.5rem 0.2rem;
    list-style: none;
}

/* ── Formulario ─────────────────────────────────────────────────────── */

.tv-chat-form {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.tv-chat-row {
    display: flex;
    gap: 0.4rem;
}

.tv-chat-name,
.tv-chat-input {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    border-radius: 11px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    padding: 0.55rem 0.75rem;
    width: 100%;
    min-width: 0;
    /* 16px evita que iOS haga zoom al enfocar y descuadre la pantalla fija. */
    font-size: max(0.85rem, 16px);
}

.tv-chat-input { flex: 1; }

.tv-chat-name::placeholder,
.tv-chat-input::placeholder { color: rgba(255, 255, 255, 0.35); }

.tv-chat-name:focus,
.tv-chat-input:focus {
    outline: none;
    border-color: var(--aurora-2);
    background: rgba(255, 255, 255, 0.09);
}

.tv-chat-send {
    flex: 0 0 auto;
    width: 42px;
    border: none;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--aurora-1), var(--aurora-2));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.15s;
}

.tv-chat-send:hover:not(:disabled) { opacity: 0.88; }
.tv-chat-send:active:not(:disabled) { transform: scale(0.94); }
.tv-chat-send:disabled { opacity: 0.45; cursor: default; }

.tv-chat-note {
    font-size: 0.7rem;
    opacity: 0.55;
    min-height: 1em;
}

.tv-chat-note-error {
    color: #ff6b6b;
    opacity: 1;
}

.tv-chat-closed {
    font-size: 0.82rem;
    opacity: 0.5;
    padding: 0.6rem 0;
}
/* ── Celular y pantallas angostas ───────────────────────────────────────
   El video pasa arriba y el chat ocupa el alto restante. */

@media (max-width: 900px) {
    .tv-brand-name { display: none; }

    .tv-stage {
        grid-template-columns: minmax(0, 1fr);
        /* El video ocupa lo que necesita y el chat se queda con el resto del
           alto. Asi no sobra hueco y la conversacion aprovecha la pantalla. */
        grid-template-rows: auto minmax(0, 1fr);
        gap: 0.9rem;
    }

    .tv-frame {
        max-width: none;
        flex: 0 0 auto;
    }

    .tv-signal-title { font-size: 1.05rem; }

    .tv-actions .tv-action {
        flex: 1 1 0;
        justify-content: center;
        min-width: 0;
    }

    /* El chat toma todo el alto que queda bajo el video y scrollea dentro.
       No se convierte en tira horizontal como eran las noticias: una
       conversacion se lee en vertical, y ademas necesita sitio para el
       formulario de envio. */
    .tv-chat-col {
        min-height: 0;
        gap: 0.5rem;
    }

    .tv-chat-msg { padding: 0.45rem 0.6rem; }
    .tv-chat-text { font-size: 0.82rem; }
}

/* Pantallas muy bajas (celular apaisado, ventanas chicas): ahi no hay forma
   de que entre todo, y es preferible devolver el scroll de la pagina antes
   que recortar el contenido. */
@media (max-height: 560px) {
    body.tv-page,
    body.tv-page .app-container {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    body.tv-page { overflow-y: auto; }

    .tv-stage { overflow: visible; }

    .tv-chat-list {
        overflow-y: auto;
        max-height: 45vh;
    }
}

/* ── En un teléfono ──────────────────────────────────────────────────────
   La señal pública se ve casi siempre desde el móvil: el titular del chat
   y su estado estaban por debajo de 12 px. */
@media (max-width: 480px) {
    .tv-chat-title { font-size: 13px; }
    #chatStatus    { font-size: 12px; }
}
