/* 1. Importar Tipografía Moderna (Inter) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

/* Reseteo básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, sans-serif;
}

/* 2. Fondo Blanco Limpio */
body {
    background-color: #fcfcfc; /* Un blanco roto muy limpio y elegante */
    color: #111827; /* Texto oscuro, más suave que el negro puro */
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Evita centrar forzosamente si el contenido crece */
    padding: 40px 20px;
}

/* 3. Corrección de Modales: Adiós a los scrollbars */
/* Cambiamos position absolute por un flujo normal usando display: none / flex */
.glass-modal {
    width: 100%;
    max-width: 1200px;
    background: #ffffff;
    border: 1px solid #f3f4f6;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
    border-radius: 16px;
    padding: 40px;
    flex-direction: column;
}

.activo {
    display: flex;
    animation: aparecer 0.4s ease;
}

.oculto {
    display: none !important; /* El !important fuerza a que el menú se esconda */
}

@keyframes aparecer {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- ESTILOS DEL LOGIN --- */
#modal-login {
    max-width: 400px;
    margin: auto;
    text-align: center;
    margin-top: 10vh; /* Lo bajamos un poco */
}

#modal-login h2 {
    font-weight: 600;
    margin-bottom: 8px;
}

#modal-login p {
    color: #6b7280;
    margin-bottom: 24px;
    font-size: 0.95rem;
}

#modal-login input {
    width: 100%;
    padding: 14px;
    margin: 8px 0;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #111827;
    outline: none;
    font-size: 1rem;
    transition: all 0.3s;
}

#modal-login input:focus {
    border-color: #d1d5db;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.03);
}

.btn-glass {
    width: 100%;
    padding: 14px;
    margin-top: 20px;
    border-radius: 8px;
    border: none;
    background: #111827; /* Botón oscuro minimalista */
    color: #ffffff;
    cursor: pointer;
    font-weight: 500;
    font-size: 1rem;
    transition: background 0.3s;
}

.btn-glass:hover {
    background: #374151;
}

/* --- HEADER DEL DASHBOARD --- */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.dashboard-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
}

.menu-usuario {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    position: relative; /* Para anclar el dropdown */
}

.nombre-usuario {
    font-weight: 500;
    font-size: 0.95rem;
}

.icono-usuario {
    font-size: 20px;
    background: #f3f4f6;
    padding: 8px 12px;
    border-radius: 50%;
}

.glass-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    padding: 10px 0;
    width: 160px;
    background: #ffffff;
    border: 1px solid #f3f4f6;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.glass-dropdown a {
    color: #374151;
    text-decoration: none;
    padding: 10px 20px;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.glass-dropdown a:hover {
    background: #f9fafb;
    color: #111827;
}

/* --- 4. REJILLA DE CURSOS (GRID DE 3) --- */
.rejilla-cursos {
    display: grid;
    /* Obligamos a que sean exactamente 3 columnas ocupando todo el ancho */
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    width: 100%;
}

/* --- ESTILOS DE LAS TARJETAS (Actualizado con imagen) --- */
.tarjeta-curso {
    background: #ffffff;
    border: 1px solid #e5e7eb; 
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); 
    border-radius: 12px;
    /* 1. ELIMINAMOS el padding de aquí para que la imagen toque los bordes de arriba */
    /* padding: 24px;  <-- Lo pasamos a .tarjeta-contenido */
    overflow: hidden; /* 2. CRÍTICO: Para que la imagen no se salga de las esquinas redondeadas */
    display: flex; /* 3. Para apilar la imagen y el texto correctamente */
    flex-direction: column;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.tarjeta-curso:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: #d1d5db; 
}

/* --- NUEVO: Contenedor de la Imagen --- */
.tarjeta-imagen {
    width: 100%;
    height: 180px; /* Puedes ajustar esta altura a tu gusto */
}

.tarjeta-imagen img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Esto garantiza que el personaje se vea estrictamente de la cintura para arriba sin cortar la cabeza */
    object-position: top; 
}

/* --- NUEVO: Contenedor del Texto y Barras --- */
.tarjeta-contenido {
    padding: 24px; /* El padding que quitamos arriba, lo ponemos aquí */
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Hace que el contenido ocupe el espacio restante */
}

/* Textos (Tus estilos exactos) */
.tarjeta-curso h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
    margin-top: 0; /* Previene saltos por estilos por defecto del navegador */
}

.tarjeta-curso p {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 24px;
    margin-top: 0;
}

/* --- BARRAS DE PROGRESO (Tus estilos intactos) --- */
.barra-progreso-contenedor {
    width: 100%;
    height: 6px;
    background: #f3f4f6;
    border-radius: 10px;
    margin-bottom: 8px;
    overflow: hidden;
}

.barra-progreso {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
}

.rojo { background: #ef4444; }
.amarillo { background: #f59e0b; }
.verde { background: #10b981; }

.porcentaje {
    font-size: 0.8rem;
    color: #6b7280;
    font-weight: 500;
}

/* --- SISTEMA DE NOTIFICACIONES INTERNAS --- */
#sistema-notificaciones {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notificacion-interna {
    padding: 14px 20px;
    border-radius: 8px;
    background: #111827; /* Notificación oscura para contraste */
    color: #ffffff;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-left: 4px solid #10b981;
    font-size: 0.9rem;
    animation: deslizarEntrada 0.4s ease;
}

@keyframes deslizarEntrada {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --- RESPONSIVO PARA LA REJILLA --- */
/* Si se ve en tablets, baja a 2 columnas. En celulares, a 1 columna. */
@media (max-width: 992px) {
    .rejilla-cursos {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .rejilla-cursos {
        grid-template-columns: 1fr;
    }
}

/* --- 5. VISOR DE APRENDIZAJE (Estilo Minimalista) --- */
.vista-completa {
    width: 100%;
    max-width: 1400px; /* Ancho máximo para pantallas grandes */
    height: 85vh; /* Altura controlada */
    gap: 30px;
    /* La clase .activo ya le aplica el display: flex */
}

/* Redefinimos los paneles para que parezcan tarjetas minimalistas */
.glass-panel {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    padding: 24px;
    color: #111827;
}

/* --- Panel Izquierdo (Menú) --- */
.visor-sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.btn-glass-outline {
    background: #ffffff;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 25px;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-glass-outline:hover {
    background: #f3f4f6;
}

.menu-herramientas {
    list-style: none;
    margin-bottom: 20px;
}

.menu-herramientas li {
    padding: 12px 15px;
    margin-bottom: 5px;
    cursor: pointer;
    border-radius: 8px;
    color: #4b5563;
    font-weight: 500;
    transition: all 0.2s;
}

.menu-herramientas li:hover {
    background: #f3f4f6;
    color: #111827;
}

.separador-sidebar {
    border: 0;
    height: 1px;
    background: #e5e7eb;
    margin: 15px 0 25px 0;
}

.modulo-titulo {
    font-weight: 600;
    margin-bottom: 12px;
    color: #111827;
    font-size: 1.05rem;
}

.temas-lista {
    list-style: none;
    padding-left: 10px;
    margin-bottom: 25px;
}

.temas-lista .tema {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.95rem;
    color: #6b7280;
    border-radius: 6px;
    transition: all 0.2s;
}

.temas-lista .tema:hover {
    background: #f9fafb;
    color: #111827;
}

.temas-lista .tema.activo {
    background: #f0fdf4; /* Fondo verde muy tenue */
    color: #15803d; /* Texto verde oscuro */
    border-left: 3px solid #10b981;
    font-weight: 500;
}

/* --- Panel Derecho (Contenido) --- */
.visor-contenido {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.contenido-header {
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.contenido-header h2 {
    font-size: 1.6rem;
    font-weight: 600;
    color: #111827;
}

.area-multimedia {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 25px;
    overflow-y: auto;
    padding-right: 10px; /* Espacio para el scroll */
}

.video-placeholder {
    background: #f9fafb;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    height: 450px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #6b7280;
}

.icono-play {
    font-size: 3.5rem;
    margin-bottom: 15px;
    color: #9ca3af;
}

.texto-contenido {
    color: #4b5563;
    line-height: 1.7;
    font-size: 1.05rem;
}

.contenido-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}
/* --- 6. MODAL MI PERFIL --- */
.perfil-contenedor {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding-top: 10px;
}

/* Contenedor y previsualización de la foto */
.foto-perfil-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.foto-preview {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: #f9fafb;
    border: 2px dashed #d1d5db;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    color: #9ca3af;
    overflow: hidden;
    position: relative;
}

.foto-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Asegura que la imagen no se deforme al llenar el círculo */
    position: absolute;
    top: 0;
    left: 0;
}

.btn-subir-foto {
    background: #ffffff;
    color: #374151;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #d1d5db;
    transition: background 0.2s;
}

.btn-subir-foto:hover {
    background: #f3f4f6;
}

/* Formulario minimalista */
.formulario-perfil {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-grupo {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
}

.form-grupo label {
    font-size: 0.9rem;
    color: #4b5563;
    font-weight: 500;
}

.form-grupo input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #6b7280;
    outline: none;
    font-size: 1rem;
}

/* --- Fondo Glassmorphism para el Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.4); /* Blanco semi-transparente */
    backdrop-filter: blur(12px); /* Efecto Glassmorphism */
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* La tarjeta emergente minimalista */
.perfil-tarjeta {
    background: #ffffff;
    width: 90%;
    max-width: 450px;
    padding: 35px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    animation: escalarModal 0.3s ease;
}

@keyframes escalarModal {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- 7. PANEL DE ADMINISTRADOR --- */
.admin-layout {
    width: 100vw;
    height: 100vh;
    background-color: #fcfcfc; /* Fondo general blanco/grisáceo */
}

/* Sidebar del Admin */
.admin-sidebar {
    width: 260px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
}

.admin-logo {
    font-size: 1.5rem;
    color: #111827;
    margin-bottom: 40px;
    text-align: center;
}

.admin-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
}

.admin-tab {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    color: #4b5563;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

.admin-tab:hover {
    background: #f9fafb;
    color: #111827;
}

/* Pestaña seleccionada en el Admin */
.admin-tab.activo {
    background: #f3f4f6;
    color: #111827;
    font-weight: 600;
}

/* Contenido Principal */
.admin-content {
    flex: 1;
    padding: 50px;
    overflow-y: auto;
    background: #fcfcfc;
}

.admin-seccion {
    animation: aparecer 0.4s ease;
    flex-direction: column; /* Compatible con nuestro .activo global */
    gap: 15px;
    max-width: 1000px;
}

.admin-seccion h2 {
    font-size: 1.8rem;
    color: #111827;
    font-weight: 600;
    letter-spacing: -0.5px;
}

/* --- Estilos Reutilizables para Formularios del Panel de Admin --- */
.admin-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.admin-form-row {
    display: flex;
    gap: 20px;
}

.admin-form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-form-group label {
    font-size: 0.9rem;
    color: #4b5563;
    font-weight: 500;
}

.admin-form-group input[type="text"],
.admin-form-group input[type="email"],
.admin-form-group input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: #374151;
    outline: none;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.admin-form-group input:focus {
    border-color: #10b981; /* Resalta en verde al escribir */
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Caja de previsualización del logo */
.logo-preview-box {
    width: 45px; 
    height: 45px; 
    background: #f3f4f6; 
    border-radius: 8px; 
    border: 1px dashed #d1d5db;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 1.5rem;
}

/* Selector de color */
.color-picker {
    width: 40px; 
    height: 40px; 
    border: none; 
    border-radius: 8px; 
    cursor: pointer; 
    padding: 0; 
    background: none;
}
.color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker::-webkit-color-swatch { border: none; border-radius: 8px; }

// 11. Lógica de la Sección Configuración
const btnGuardarConfig = document.getElementById('btn-guardar-config');

if (btnGuardarConfig) {
    btnGuardarConfig.addEventListener('click', () => {
        // Aquí en el futuro conectarás con Firebase para guardar los datos.
        // Por ahora, simulamos el éxito usando nuestro sistema de notificaciones:
        mostrarNotificacion('Configuración actualizada correctamente', 'exito');
    });
}

/* --- Selector y Grupos de Base de Datos --- */
.admin-form-group select.admin-select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: #374151;
    outline: none;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-form-group select.admin-select:focus {
    border-color: #10b981;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.db-campos-grupo {
    flex-direction: column;
    gap: 20px;
}

/* --- 8. TABLAS Y ETIQUETAS (BADGES) --- */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.admin-table th {
    background-color: #f9fafb;
    color: #6b7280;
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 15px 25px;
    border-bottom: 1px solid #e5e7eb;
}

.admin-table td {
    padding: 15px 25px;
    border-bottom: 1px solid #f3f4f6;
    color: #4b5563;
    font-size: 0.95rem;
    vertical-align: middle;
}

.admin-table tbody tr:hover {
    background-color: #f9fafb;
}

/* Etiquetas de estado y rol (Badges) */
.badge {
    padding: 4px 10px;
    border-radius: 9999px; /* Forma de píldora */
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-admin { background: #fee2e2; color: #991b1b; }
.badge-alumno { background: #e0e7ff; color: #3730a3; }
.badge-activo { background: #d1fae5; color: #065f46; }

/* Botones de acción en la tabla */
.btn-icono {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    margin-right: 8px;
}

.btn-icono:hover {
    opacity: 1;
}

/* --- 9. LISTAS DE SELECCIÓN (CHECKBOXES) --- */
.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 150px; /* Limita la altura */
    overflow-y: auto;  /* Agrega scroll si hay muchos cursos */
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    background: #f9fafb;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: #4b5563;
    cursor: pointer;
    user-select: none;
}

.checkbox-item input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: #10b981; /* Pinta la palomita del color de la marca */
}

/* --- 10. CONSTRUCTOR DE CURSOS (MÓDULOS Y CONTENIDO) --- */
.modulos-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.modulo-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.modulo-header {
    background: #f3f4f6;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}

.contenido-lista {
    padding: 10px 20px;
    display: flex;
    flex-direction: column;
}

.contenido-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
    color: #4b5563;
    font-size: 0.95rem;
}

.contenido-item:last-child {
    border-bottom: none;
}

/* --- MODALES Y GLASSMORPHISM --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Fondo semi-transparente claro con desenfoque */
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Reutilizamos la clase oculto pero aseguramos que quite el modal de la pantalla */
.modal-overlay.oculto {
    display: none;
    opacity: 0;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    /* Una sombra más pronunciada para dar sensación de elevación */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(0);
    animation: modalSlideIn 0.3s ease forwards;
}

@keyframes modalSlideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.contenido-enriquecido pre.ql-syntax { background: #1e293b; color: #f8fafc; padding: 12px; border-radius: 6px; font-family: monospace; overflow-x: auto; }