:root {
    --primary: #00a8ff;
    --bg-dark: rgba(20, 20, 20, 0.95);
    --glass: rgba(15, 15, 15, 0.85);
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
    --safe-left: env(safe-area-inset-left);
}

* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-tap-highlight-color: transparent; }

body { background: #000; width: 100vw; height: 100vh; overflow: hidden; font-family: -apple-system, system-ui, sans-serif; color: white; }

#video-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }
video { width: 100%; height: 100%; object-fit: contain; background: #000; }

#fullscreen-btn { position: absolute; bottom: 30px; right: 30px; width: 50px; height: 50px; background: rgba(0,0,0,0.6); border: 2px solid rgba(255,255,255,0.3); border-radius: 50%; z-index: 100; fill: white; display: flex; align-items: center; justify-content: center; transition: opacity 0.5s; cursor: pointer; }
#fullscreen-btn svg { width: 28px; height: 28px; fill: white; }

#osd { position: fixed; bottom: 0; left: 0; width: 100%; background: linear-gradient(to top, rgba(0,0,0,0.95) 10%, rgba(0,0,0,0.6) 80%, transparent 100%); padding: 20px 40px; padding-bottom: max(30px, var(--safe-bottom)); z-index: 50; transition: transform 0.3s; }
#osd.hidden { transform: translateY(110%); }
.osd-content { display: flex; align-items: flex-end; gap: 20px; }
#osd-poster { width: 130px; height: 74px; object-fit: cover; border-radius: 6px; background: #222; box-shadow: 0 4px 10px rgba(0,0,0,0.6); flex-shrink: 0; border: 1px solid rgba(255,255,255,0.1); }
#osd-text-container { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; }
.osd-header-row { display: flex; align-items: baseline; gap: 15px; margin-bottom: 5px; }
#osd-num { font-size: 3rem; font-weight: 800; color: var(--primary); line-height: 1; text-shadow: 0 2px 4px black; }
#osd-title { font-size: 1.5rem; font-weight: 700; text-shadow: 0 2px 4px black; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#osd-program { font-size: 1.1rem; color: #ddd; margin-bottom: 8px; font-weight: 500; }
.osd-bar-bg { width: 100%; height: 6px; background: rgba(255,255,255,0.2); border-radius: 3px; }
#osd-bar-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.5s; }

#side-menu { position: fixed; top: 0; left: 0; height: 100%; width: 380px; background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); z-index: 60; transform: translateX(0); transition: transform 0.3s; display: flex; flex-direction: column; padding-left: var(--safe-left); border-right: 1px solid rgba(255,255,255,0.1); }
#side-menu.hidden { transform: translateX(-100%); }
.menu-header { padding: 30px 20px 20px; font-size: 1.3rem; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: space-between; align-items: center; }
#logout-btn { background: none; border: none; color: #ff4757; font-size: 1.2rem; cursor: pointer; }
#channel-list { flex: 1; overflow-y: auto; padding: 15px; -webkit-overflow-scrolling: touch; }

.channel-item { padding: 10px; border-radius: 12px; margin-bottom: 8px; display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,0.05); transition: all 0.2s; cursor: pointer; border: 1px solid transparent; position: relative; }
.channel-item:active { transform: scale(0.98); }
.channel-item.active { background: rgba(0, 168, 255, 0.25); border-color: rgba(0, 168, 255, 0.4); }

.channel-item.focused {
    background: linear-gradient(90deg, rgba(255,255,255,0.15), rgba(255,255,255,0.05));
    border-left: 4px solid #00a8ff;
    box-shadow: 0 0 20px rgba(0,168,255,0.5);
    transform: scale(1.02);
}

.channel-item.active.focused {
    border-left: 4px solid #00a8ff;
    box-shadow: 0 0 25px rgba(0,168,255,0.6);
}

.ch-media-box { width: 80px; height: 45px; flex-shrink: 0; position: relative; border-radius: 4px; overflow: hidden; background: #222; display: flex; align-items: center; justify-content: center; }
.ch-list-thumb { width: 100%; height: 100%; object-fit: cover; display: none; }
.ch-circle { font-weight: 800; font-size: 1.2rem; color: #555; }
.channel-item.active .ch-circle { color: var(--primary); }
.ch-info { flex: 1; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.ch-name { font-weight: 700; font-size: 0.95rem; color: #aaa; margin-bottom: 2px; }
.channel-item.active .ch-name { color: var(--primary); }
.ch-prog { font-size: 0.9rem; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.ch-time { font-size: 0.75rem; color: var(--primary); margin-top: 2px; font-weight: 500; }
.btn-guide { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: white; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; cursor: pointer; transition: 0.2s; flex-shrink: 0; }
.btn-guide:hover { background: var(--primary); border-color: var(--primary); color: black; }

/* NUEVOS ESTILOS PARA INDICADORES DE ESTADO */
.ch-status-dot {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #555; /* Default: Gris/Desconocido */
    border: 1px solid #000;
    z-index: 10;
    transition: background-color 0.3s;
}
.ch-status-dot.online { background-color: #2ecc71; box-shadow: 0 0 5px #2ecc71; }
.ch-status-dot.offline { background-color: #e74c3c; opacity: 0.8; }

#loading { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 70; background: rgba(0,0,0,0.6); padding: 25px; border-radius: 15px; backdrop-filter: blur(5px); }
.spinner { width: 45px; height: 45px; border: 4px solid rgba(255,255,255,0.1); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { opacity: 0; pointer-events: none; }

.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); backdrop-filter: blur(5px); z-index: 200; display: flex; justify-content: center; align-items: center; transition: opacity 0.3s, visibility 0.3s; opacity: 1; visibility: visible; }
.modal.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.modal-content { background: #1a1a1a; border-radius: 16px; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 30px 60px rgba(0,0,0,1); display: flex; flex-direction: column; overflow: hidden; }

.guide-content { width: 600px; max-width: 95%; height: 80vh; }
.modal-header { padding: 20px; background: #222; border-bottom: 1px solid #333; display: flex; justify-content: space-between; align-items: center; }
.close-modal { background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; }
#guide-list { flex: 1; overflow-y: auto; padding: 15px; }
.guide-item { display: flex; gap: 15px; padding: 15px; border-bottom: 1px solid rgba(255,255,255,0.05); cursor: pointer; border-radius: 8px; transition: all 0.2s; }
.guide-item:hover { background: rgba(255,255,255,0.05); }
.guide-item.current { background: linear-gradient(90deg, rgba(0, 168, 255, 0.15), transparent); border-left: 4px solid var(--primary); }

.guide-item.focused {
    background: linear-gradient(90deg, rgba(255,255,255,0.15), rgba(255,255,255,0.05));
    border-left: 4px solid #00a8ff;
    box-shadow: 0 0 20px rgba(0,168,255,0.5);
    transform: scale(1.02);
}

.guide-item.current.focused {
    border-left: 4px solid #00a8ff;
    box-shadow: 0 0 25px rgba(0,168,255,0.6);
}

.g-thumb { width: 110px; height: 62px; object-fit: cover; border-radius: 4px; background: #252525; flex-shrink: 0; }
.g-info { flex: 1; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.g-time { font-size: 0.9rem; color: var(--primary); font-weight: 700; margin-bottom: 4px; }
.g-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-desc-short { font-size: 0.85rem; color: #999; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.detail-content { max-width: 95%; max-height: 90vh; position: relative; transition: all 0.3s; }
.close-modal-floating { position: absolute; top: 15px; right: 15px; width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,0.6); color: white; border: 1px solid rgba(255,255,255,0.4); cursor: pointer; z-index: 20; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; transition: transform 0.2s; }
.detail-content.mode-portrait { width: 750px; display: flex; flex-direction: row; height: 550px; }
.detail-content.mode-portrait #detail-img-container { width: 45%; height: 100%; flex-shrink: 0; background: black; }
.detail-content.mode-portrait #detail-img { width: 100%; height: 100%; object-fit: contain; }
.detail-content.mode-portrait .detail-body { width: 55%; padding: 40px; overflow-y: auto; }
.detail-content.mode-landscape { width: 600px; display: flex; flex-direction: column; max-height: 90vh; }
.detail-content.mode-landscape #detail-img-container { width: 100%; height: auto; max-height: 50vh; background: black; flex-shrink: 0; display: flex; justify-content: center; align-items: center; }
.detail-content.mode-landscape #detail-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.detail-content.mode-landscape .detail-body { padding: 25px; overflow-y: auto; flex: 1; background: #1a1a1a; }
#detail-title { font-size: 1.8rem; margin-bottom: 10px; line-height: 1.1; font-weight: 800; }
#detail-meta { color: var(--primary); font-weight: 700; font-size: 1rem; margin-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 15px; }
#detail-desc { color: #ccc; line-height: 1.6; font-size: 1.05rem; white-space: pre-wrap; }

/* --- ESTILOS MANTENIMIENTO --- */
.maint-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #000;
    z-index: 9999;
    display: flex; justify-content: center; align-items: center;
    text-align: center;
}
.maint-content {
    background: #111; padding: 40px; border-radius: 15px; border: 1px solid #333;
    max-width: 90%;
}
.maint-icon { font-size: 60px; margin-bottom: 20px; }
.maint-content h1 { color: #e74c3c; margin-bottom: 15px; font-size: 24px; }
.maint-content p { color: #aaa; margin-bottom: 20px; font-size: 16px; }
.maint-content button {
    padding: 10px 20px; background: #333; color: white; border: none;
    border-radius: 5px; font-size: 16px; cursor: pointer;
}