/* ===================================
   CANALES EN VIVO - ESTILOS
   =================================== */

:root {
    --live-accent: #ef4444;
    --live-accent-dim: rgba(239, 68, 68, 0.15);
}

.canales-page {
    min-height: 100vh;
    background: #0a0a0a;
}

/* ===== PULSE DOT (compartido) ===== */
.pulse-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--live-accent);
    animation: pulse-live 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.7); }
}

/* ===== BADGE EN VIVO (compartido) ===== */
.badge-en-vivo {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    background: var(--live-accent-dim);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--live-accent);
    letter-spacing: 0.06em;
    white-space: nowrap;
}

/* ===== PLAYER HERO - CENTRADO ===== */
.canal-hero {
    background: #0a0a0a;
    padding: 1rem 1.5rem 0.75rem;
    border-bottom: 1px solid #151515;
}

.canal-player-wrapper {
    position: relative;
    background: #000;
    aspect-ratio: 16 / 9;
    max-height: 52vh;
    max-width: 960px;
    width: 100%;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.6),
        0 24px 64px rgba(0, 0, 0, 0.7),
        0 4px 16px rgba(0, 0, 0, 0.5);
}

.canal-player-wrapper video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
    border-radius: 16px;
}

/* Loading — aparece inmediato, solo tiene fade al ocultarse */
.player-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.92);
    color: #fff;
    gap: 1rem;
    z-index: 5;
    opacity: 1;
    transition: none;
}

.player-loading.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--live-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.player-loading p {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
}

/* Error */
.player-error {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    gap: 0.75rem;
    z-index: 5;
    text-align: center;
    padding: 2rem;
}

.player-error.show { display: flex; }
.player-error svg  { color: var(--live-accent); opacity: 0.6; }
.player-error h3   { margin: 0; font-size: 1.1rem; }
.player-error p    { margin: 0; font-size: 0.85rem; color: rgba(255, 255, 255, 0.45); }

/* ===== LAYOUT HERO CON BOTONES LATERALES ===== */
.canal-hero-layout {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 1120px;
    margin: 0 auto;
}

/* ===== BOTONES NAV CANAL (< >) ===== */
.tv-nav-btn {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    transition: background 0.2s ease, border-color 0.2s ease,
                box-shadow 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.tv-nav-btn:hover {
    background: var(--live-accent);
    border-color: var(--live-accent);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.45);
}

.tv-nav-btn:active { transform: scale(0.88); }

/* Deshabilitado: primer o último canal */
.tv-nav-btn.disabled {
    opacity: 0.15;
    pointer-events: none;
}

/* ===== OSD - ON SCREEN DISPLAY ===== */
.tv-osd {
    position: absolute;
    bottom: 72px;
    left: 20px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1.25rem 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 340px;
}

.tv-osd.visible {
    opacity: 1;
    transform: translateY(0);
}

.tv-osd-number {
    font-size: 1rem;
    font-weight: 800;
    color: var(--live-accent);
    letter-spacing: 0.04em;
    flex-shrink: 0;
    min-width: 44px;
}

.tv-osd-logo {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tv-osd-logo svg { color: rgba(255, 255, 255, 0.25); }

.tv-osd-details {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
    min-width: 0;
}

.tv-osd-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tv-osd-cat {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.45);
}

/* ===== INFO BAR ===== */
.canal-info-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.625rem 1.5rem;
    background: #0f0f0f;
    border-bottom: 1px solid #1a1a1a;
    max-width: 100%;
}

.cib-logo {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    overflow: hidden;
    background: #1a1a1a;
    border: 1px solid #252525;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cib-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cib-logo svg { color: #333; }

.cib-details {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.cib-details h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cib-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

#canalCatActiva {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 20px;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
}

#canalDescActiva {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.35);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

.cib-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    margin-left: auto;
}

.btn-canal-action {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.875rem;
    border-radius: 8px;
    font-size: 0.78rem;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-canal-edit {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

.btn-canal-edit:hover { background: rgba(99, 102, 241, 0.2); }

/* ===== TV CHANNEL GUIDE ===== */
.tv-guide {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem 1.25rem 2rem;
}

.tv-guide-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.canales-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.canales-section-title svg { color: var(--live-accent); }

/* Filtros de categoría */
.cat-filters {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.cat-btn {
    padding: 0.35rem 0.875rem;
    border-radius: 20px;
    border: 1px solid #252525;
    background: #141414;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
}

.cat-btn:hover {
    border-color: var(--live-accent);
    color: var(--live-accent);
}

.cat-btn.active {
    background: var(--live-accent-dim);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--live-accent);
    font-weight: 600;
}

/* Strip wrapper con botones */
.tv-guide-strip-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Botones de scroll */
.tv-strip-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid #252525;
    background: #141414;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.tv-strip-btn:hover {
    background: var(--live-accent-dim);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--live-accent);
}

/* Channel strip - scroll horizontal */
.tv-channel-strip {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    padding: 0.5rem 0.25rem 1rem;
    flex: 1;
}

.tv-channel-strip::-webkit-scrollbar { display: none; }

/* ===== CANAL CARD ===== */
.tv-ch-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    padding: 1rem 0.875rem 0.875rem;
    background: #141414;
    border: 1px solid #202020;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    width: 118px;
    text-align: center;
    position: relative;
    user-select: none;
}

.tv-ch-card:hover {
    background: #1c1c1c;
    border-color: #333;
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.tv-ch-card.active {
    background: var(--live-accent-dim);
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2), 0 8px 24px rgba(239, 68, 68, 0.12);
    transform: translateY(-2px);
}

/* Número de canal */
.tv-ch-number {
    font-size: 0.6rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.25);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    align-self: flex-start;
}

.tv-ch-card.active .tv-ch-number { color: var(--live-accent); }

/* Logo */
.tv-ch-logo {
    width: 58px;
    height: 58px;
    border-radius: 12px;
    overflow: hidden;
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s;
}

.tv-ch-card.active .tv-ch-logo { border-color: rgba(239, 68, 68, 0.3); }

.tv-ch-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tv-ch-logo svg { color: #2e2e2e; }

/* Nombre */
.tv-ch-name {
    font-size: 0.76rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.3;
    word-break: break-word;
    max-width: 100%;
}

.tv-ch-card.active .tv-ch-name { color: #fff; }

/* Categoría */
.tv-ch-cat {
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.25);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Badge VIVO */
.tv-ch-live {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--live-accent);
    letter-spacing: 0.08em;
}

.tv-ch-live .pulse-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--live-accent);
    animation: pulse-live 1.5s ease-in-out infinite;
}

/* Empty state */
.canales-empty {
    text-align: center;
    padding: 5rem 2rem;
    color: rgba(255, 255, 255, 0.25);
}

.canales-empty svg { margin-bottom: 1rem; opacity: 0.25; }
.canales-empty h3  { color: rgba(255, 255, 255, 0.4); margin: 0 0 0.5rem; }
.canales-empty p   { margin: 0; font-size: 0.9rem; }

/* ===================================================
   RESPONSIVE MÓVIL — diseño optimizado para táctil
   =================================================== */

/* --- Tablet 768px --- */
@media (max-width: 768px) {

    /* Player */
    .canal-hero { padding: 0.875rem 0.75rem 0.75rem; }

    .canal-player-wrapper {
        max-height: none;
        border-radius: 12px;
    }

    /* OSD */
    .tv-osd {
        bottom: 58px;
        left: 12px;
        right: 12px;
        max-width: none;
    }

    /* Info bar */
    .canal-info-bar { padding: 0.75rem 1rem; gap: 0.75rem; }
    #canalDescActiva { display: none; }
    .cib-details h2  { font-size: 0.95rem; }

    /* Guide header apilado */
    .tv-guide-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    /* Filtros de categoría: scroll horizontal sin wrap */
    .cat-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
        width: 100%;
    }
    .cat-filters::-webkit-scrollbar { display: none; }

    /* Cards más grandes para toque */
    .tv-ch-card {
        width: 114px;
        padding: 0.875rem 0.75rem 0.875rem;
        -webkit-tap-highlight-color: transparent;
    }

    /* Reemplazar hover por feedback táctil */
    .tv-ch-card:hover { transform: none; box-shadow: none; }
    .tv-ch-card:active {
        transform: scale(0.95);
        background: #1c1c1c;
        transition: transform 0.1s ease;
    }
    .tv-ch-card.active:active { transform: scale(0.97); }

    .tv-ch-logo { width: 56px; height: 56px; }
    .tv-ch-name { font-size: 0.8rem; }
}

/* --- Móvil 600px --- */
@media (max-width: 600px) {

    /* En móvil no hay espacio lateral, se ocultan */
    .tv-nav-btn { display: none; }

    /* Player casi borde a borde */
    .canal-hero { padding: 0.625rem 0.5rem 0.5rem; }

    .canal-player-wrapper {
        border-radius: 10px;
        box-shadow:
            0 0 0 1px rgba(0, 0, 0, 0.5),
            0 12px 40px rgba(0, 0, 0, 0.6);
    }

    /* Info bar de una sola línea */
    .canal-info-bar {
        padding: 0.625rem 0.75rem;
        gap: 0.625rem;
    }

    .cib-logo { width: 36px; height: 36px; border-radius: 7px; }
    .cib-details h2 { font-size: 0.875rem; }
    #canalCatActiva { display: none; }

    /* Botón admin solo ícono */
    .btn-canal-edit { padding: 0.45rem; }
    .btn-canal-edit span { display: none; }

    /* Guide */
    .tv-guide { padding: 1rem 0.625rem 2.5rem; }

    /* Ocultar botones de flecha (el usuario desliza) */
    .tv-strip-btn { display: none; }
    .tv-guide-strip-wrap { gap: 0; }

    /* Strip con scroll snap para precisión */
    .tv-channel-strip {
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        padding: 0.375rem 0.5rem 1rem;
        gap: 0.625rem;
    }

    /* Cards cómodas para el pulgar */
    .tv-ch-card {
        width: 120px;
        padding: 1rem 0.75rem;
        scroll-snap-align: start;
        border-radius: 12px;
        gap: 0.5rem;
    }

    .tv-ch-logo {
        width: 62px;
        height: 62px;
        border-radius: 11px;
    }

    .tv-ch-number { font-size: 0.58rem; }
    .tv-ch-name   { font-size: 0.82rem; }
    .tv-ch-cat    { display: none; }

    /* OSD más pegado al borde */
    .tv-osd {
        bottom: 48px;
        left: 10px;
        right: 10px;
        padding: 0.625rem 1rem;
        border-radius: 10px;
    }

    .tv-osd-number { font-size: 0.875rem; min-width: 40px; }
    .tv-osd-logo   { width: 32px; height: 32px; }
    .tv-osd-name   { font-size: 0.82rem; }
}

/* --- Teléfonos pequeños 400px --- */
@media (max-width: 400px) {

    .canal-hero { padding: 0.5rem 0.375rem 0.375rem; }

    .canal-player-wrapper { border-radius: 8px; }

    .canal-info-bar { padding: 0.5rem 0.625rem; }
    .cib-logo { width: 32px; height: 32px; }
    .cib-details h2 { font-size: 0.82rem; }

    .tv-guide { padding: 0.875rem 0.5rem 2rem; }

    .tv-ch-card {
        width: 108px;
        padding: 0.875rem 0.625rem;
    }

    .tv-ch-logo { width: 56px; height: 56px; }
    .tv-ch-name { font-size: 0.78rem; }
}

/* ===================================
   ADMIN - ADMINISTRAR CANALES
   =================================== */
.admin-canales-page {
    min-height: 100vh;
    background: #0a0a0a;
}

.admin-canales-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

.canales-table-wrap {
    background: #111;
    border-radius: 12px;
    border: 1px solid #1e1e1e;
    overflow: hidden;
}

.canales-table {
    width: 100%;
    border-collapse: collapse;
}

.canales-table th {
    background: #0a0a0a;
    padding: 12px 16px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-bottom: 1px solid #1e1e1e;
}

.canales-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #171717;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    vertical-align: middle;
}

.canales-table tr:last-child td { border-bottom: none; }
.canales-table tr:hover td      { background: rgba(255, 255, 255, 0.02); }

.logo-thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: contain;
    background: #1a1a1a;
    border: 1px solid #252525;
}

.logo-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #1a1a1a;
    border: 1px solid #252525;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

.badge-cat {
    padding: 0.2rem 0.6rem;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.badge-activo {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-activo.on  { background: rgba(34, 197, 94, 0.1); color: #4ade80; }
.badge-activo.off { background: rgba(255, 255, 255, 0.05); color: rgba(255, 255, 255, 0.3); }

.td-actions { display: flex; gap: 6px; align-items: center; }

.btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-toggle { background: rgba(255, 255, 255, 0.07); color: rgba(255, 255, 255, 0.6); }
.btn-toggle:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

.btn-delete { background: rgba(239, 68, 68, 0.1); color: #f87171; }
.btn-delete:hover { background: rgba(239, 68, 68, 0.2); }

.url-truncate {
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.78rem;
    font-family: monospace;
}
