/* === NIVEL ELITE: VARIABLES & RESET === */
:root {
    --bg-dark: #0f0f0f;       
    --bg-panel: #161616;      
    --bg-hover: #1f1f1f;      
    --accent: #0084ff;        
    --accent-glow: rgba(0, 132, 255, 0.15); 
    --success: #00e676; /* Verde "Completado" */
    --text-main: #ffffff;
    --text-muted: #888888;
    --border-subtle: rgba(255, 255, 255, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', sans-serif; 
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased; 
}

/* --- LAYOUT --- */
.curso-layout { display: flex; width: 100%; height: 100vh; }

/* --- 1. ZONA VIDEO (IZQUIERDA) --- */
.video-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-dark);
    position: relative;
    overflow-y: auto;
    padding-top: 20px; 
}

.video-header {
    padding: 0 40px 15px 40px; 
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
}

.video-header h1 {
    font-size: 1.6rem; 
    font-weight: 600; 
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: #fff;
}

/* Botón flotante estilizado */
.toggle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(30, 30, 30, 0.8);
    backdrop-filter: blur(5px);
    color: #fff;
    border: 1px solid var(--border-subtle);
    border-radius: 8px; 
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; cursor: pointer; z-index: 100;
    transition: all 0.3s ease;
}
.toggle-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.05);
}

.video-player-wrapper {
    width: 100%;
    padding: 0 40px;
    margin-bottom: 25px; 
}

.video-details {
    padding: 0 40px 60px 40px;
    max-width: 1180px;
    margin: 0 auto;
    width: 100%;
}
.video-details p { color: #b0b0b0; line-height: 1.7; font-size: 1rem; font-weight: 300; }

/* --- 2. SIDEBARS (BASE COMÚN) --- */
aside {
    background-color: var(--bg-panel);
    border-left: 1px solid var(--border-subtle);
    display: flex; flex-direction: column;
}

.sidebar-header {
    background-color: var(--bg-panel); 
    padding: 20px;
    border-bottom: 1px solid var(--border-subtle);
    min-height: 70px;
    display: flex; align-items: center;
}

.sidebar-header h2, .sidebar-header h3 {
    font-size: 0.9rem; 
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--text-muted);
}

.sidebar-content { overflow-y: auto; flex-grow: 1; }

/* --- 3. SIDEBAR CAPÍTULOS --- */
.chapters-sidebar {
    width: 0;
    overflow: hidden;
    transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-right: 1px solid var(--border-subtle);
    border-left: none; 
}
.chapters-sidebar.active { width: 300px; }

.chapter-list { list-style: none; padding: 20px 0; }
.chapter-item {
    padding: 12px 20px;
    cursor: pointer;
    display: flex; gap: 15px;
    position: relative;
    transition: background 0.2s;
}
.chapter-item:hover { background-color: var(--bg-hover); }

/* Timeline */
.timeline-marker {
    width: 2px; background-color: #333; position: relative; margin-left: 5px;
}
.timeline-marker::after {
    content: ''; width: 8px; height: 8px;
    background-color: #555; border-radius: 50%;
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}
.chapter-item.active .timeline-marker::after {
    background-color: var(--accent);
    box-shadow: 0 0 12px var(--accent); 
    width: 10px; height: 10px;
}
.chapter-info { display: flex; flex-direction: column; gap: 4px; }
.chapter-info .title { font-size: 0.9rem; color: #ccc; font-weight: 400; transition: color 0.2s; }
.chapter-item.active .title { color: var(--accent); font-weight: 600; }
.chapter-info .time { font-size: 0.75rem; color: #666; font-family: 'Inter', monospace; }

/* --- 4. SIDEBAR PLAYLIST Y BARRA DE PROGRESO --- */
.playlist-sidebar { width: 350px; flex-shrink: 0; }

/* Header especial con columna para la barra */
.sidebar-header-col {
    background-color: var(--bg-panel);
    padding: 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sidebar-title-row {
    display: flex; justify-content: space-between; align-items: center;
}
.sidebar-title-row h2 {
    font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.08em;
    font-weight: 700; color: var(--text-muted); margin: 0;
}
.progress-text {
    font-size: 0.75rem; color: var(--accent); font-weight: 600;
}
.progress-bar-track {
    width: 100%; height: 6px;
    background-color: #2a2a2a;
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, #00c6ff 100%);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 0 10px rgba(0, 132, 255, 0.3);
}

.section-divider {
    background: #111; padding: 12px 20px;
    font-size: 0.75rem; font-weight: 700; color: #666;
    text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-subtle);
    border-top: 1px solid var(--border-subtle);
}

.lesson-card {
    display: flex; gap: 15px; padding: 15px 20px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s;
    background-color: var(--bg-panel);
}
.lesson-card:hover { background-color: var(--bg-hover); transform: translateX(-4px); }

.lesson-card.active {
    background: linear-gradient(90deg, rgba(0,132,255,0.08) 0%, transparent 100%);
    border-left: 3px solid var(--accent);
}
.lesson-card.active h4 { color: var(--accent); }

.lesson-thumb {
    width: 110px; height: 62px;
    background: #000; border-radius: 6px;
    overflow: hidden; position: relative; flex-shrink: 0;
}
.lesson-thumb img {
    width: 100%; height: 100%; object-fit: cover;
    opacity: 0.7; transition: opacity 0.3s;
}
.lesson-card:hover .lesson-thumb img { opacity: 1; }

.playing-overlay, .check-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.3s;
}
.playing-overlay { background: rgba(0,0,0,0.6); color: var(--accent); opacity: 1; }

/* ESTILO PARA CHECK COMPLETADO */
.check-overlay {
    background: rgba(0, 230, 118, 0.85); /* Fondo verde semitransparente */
    color: #0bef53;
}
/* --- ESTADO COMPLETADO (DISEÑO MEJORADO) --- */

/* 1. Añadimos un borde verde a la caja de la imagen */
.lesson-card.completed .lesson-thumb {
    border: 2px solid #00c853; /* Borde verde brillante */
    box-sizing: border-box;    /* Asegura que el borde no rompa el tamaño */
}

/* 2. El overlay ahora es transparente (NO tapa la imagen) */
.lesson-card.completed .check-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent; /* ¡Aquí está la magia! Fondo invisible */
    
    /* Alinear el icono a la esquina superior derecha */
    display: flex;
    align-items: flex-start; 
    justify-content: flex-end; 
    padding: 5px; /* Espacio desde el borde */
    
    opacity: 1; /* Siempre visible si está completado */
    pointer-events: none;
}

/* 3. Estilo del Icono (Check) como una "Insignia/Badge" */
.lesson-card.completed .check-overlay i {
    background: #00c853;    /* Fondo verde SOLO para el icono */
    color: #fff;            /* Icono blanco */
    width: 22px;            /* Tamaño pequeño y elegante */
    height: 22px;
    border-radius: 50%;     /* Círculo perfecto */
    padding: 4px;           /* Espacio interno */
    box-shadow: 0 2px 4px rgba(0,0,0,0.5); /* Sombrita para que resalte */
}





/* =========================================
   RESPONSIVE MOBILE (Móvil y Tablet)
   ========================================= */
@media (max-width: 900px) {

    /* 1. Cambiamos la dirección: De lado a lado -> Uno encima de otro */
    .curso-layout {
        flex-direction: column;
        height: auto; /* Ya no forzamos altura fija */
        overflow: visible; /* Permitimos que crezca */
    }

    /* 2. Liberamos el Body para hacer scroll normal con el dedo */
    body {
        height: auto;
        overflow-y: auto; /* Scroll nativo del navegador */
    }

    /* 3. El contenedor del video ocupa el ancho completo y su altura natural */
    .video-container {
        width: 100%;
        height: auto;
        flex-grow: 0; /* Que no intente llenar vacíos */
        overflow: visible;
        padding-bottom: 20px;
    }

    /* 4. Ajustes visuales para pantallas pequeñas */
    .video-header {
        padding: 15px 20px; /* Menos relleno */
    }
    
    .video-player-wrapper {
        padding: 0 10px; /* Aprovechar más el ancho de pantalla */
    }

    /* 5. La Barra Lateral (Playlist) se va abajo del todo */
    .playlist-sidebar {
        width: 100%; /* Ancho completo */
        height: auto; /* Altura automática según contenido */
        border-left: none;
        border-top: 1px solid var(--border-subtle);
        flex-shrink: 1; /* Ahora sí puede encogerse si hace falta */
    }

    /* 6. Arreglo para la lista de capítulos (Sidebar Izquierdo) */
    /* Lo convertimos en un menú flotante absoluto para que no rompa el flujo */
    .chapters-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 2000; /* Por encima de todo */
        background: var(--bg-panel);
    }
    
    /* El botón de capítulos debe seguir visible */
    .toggle-btn {
        top: 10px;
        right: 10px;
    }
}




/* =========================================
   CAPA DE PORTADA (ANTI-FANTASMAS)
   ========================================= */
#custom-thumb-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10; /* Encima del iframe */
    background-color: #000;
    cursor: pointer;
    background-size: cover;
    background-position: center;
}

/* El botón de Play gigante centrado */
#custom-thumb-layer .play-icon-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff; /* Color base */
    width: 80px;
    height: 80px;
}

#custom-thumb-layer .play-icon-overlay svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
    transition: transform 0.2s ease;
}

#custom-thumb-layer:hover .play-icon-overlay svg {
    transform: scale(1.1);
}