/* =========================================
   1. VARIABLES Y RESET GLOBAL
========================================= */
:root {
    --azul-oscuro: #023047;
    --azul-claro: #007bff;
    --verde: #28a745;
    --rojo: #dc3545;
    --amarillo: #ffc107;
    --gris: #6c757d;
    --gris-fondo: #f4f6f9;
    --blanco: #ffffff;
    
    /* Colores Roles */
    --rol-admin-bg: #f8d7da; --rol-admin-txt: #721c24;
    --rol-profe-bg: #fff3cd; --rol-profe-txt: #856404;
    --rol-estu-bg: #d4edda; --rol-estu-txt: #155724;
}

* { box-sizing: border-box; }

body { 
    font-family: 'Montserrat', sans-serif; 
    background-color: var(--gris-fondo); 
    margin: 0; 
    padding: 0; 
    color: #333; 
}

.hidden { display: none !important; }

/* =========================================
   2. LOGIN
========================================= */
.login-container { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    height: 100vh; 
    background: linear-gradient(135deg, var(--azul-oscuro) 0%, #005f8f 100%); 
}

.login-card { 
    background: var(--blanco); 
    padding: 40px; 
    border-radius: 10px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.2); 
    width: 100%; 
    max-width: 400px; 
    text-align: center; 
}

.login-card input { 
    width: 100%; 
    padding: 12px; 
    margin: 10px 0; 
    border: 1px solid #ccc; 
    border-radius: 5px; 
}

.btn-block { 
    width: 100%; 
    padding: 12px; 
    background: var(--azul-oscuro); 
    color: white; 
    border: none; 
    border-radius: 5px; 
    cursor: pointer; 
    font-weight: bold; 
}

/* =========================================
   3. DASHBOARD (CURSOS Y HEADER)
========================================= */
.header { 
    background: var(--blanco);
    padding: 15px 40px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* Contenedor de botones alineados */
#adminButtons {
    display: flex;
    gap: 15px;
    align-items: center; /* Asegura que estén centrados verticalmente */
}

/* Botón Nuevo Curso (Azul Claro - Sólido) */
.btn-primary {
    background: var(--azul-claro);
    color: white;
    border: none;
    padding: 12px 25px; /* Ajustado para que se vea igual de grande */
    border-radius: 50px; /* Redondeado completo */
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
    text-decoration: none; /* Por si acaso es un enlace <a> */
}

.btn-primary:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

/* Botón Usuarios (Azul Oscuro - Sólido, igual al otro) */
.btn-secondary {
    background: var(--azul-oscuro); /* Sólido, color de marca */
    color: white; /* Texto blanco */
    border: none; /* Sin borde */
    padding: 10px 25px; /* Mismo tamaño exacto que el primario */
    border-radius: 6px; /* Redondeado completo */
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(2, 48, 71, 0.3); /* Sombra acorde al color */
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #001f30; /* Un poco más oscuro al pasar el mouse */
    transform: translateY(-2px);
}

.logout-btn { 
    background: transparent; 
    border: 1px solid var(--rojo); 
    color: var(--rojo); 
    padding: 8px 18px; /* Ajuste leve para alineación */
    border-radius: 20px;
    cursor: pointer; 
    font-weight: 600;
}
.logout-btn:hover { background: var(--rojo); color: white; }

/* GRID DE CURSOS */
.courses-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
    gap: 30px;
    margin-top: 20px; 
}

/* Tarjeta Clickeable */
.course-card { 
    background: var(--blanco); 
    border-radius: 10px; 
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08); 
    position: relative; 
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.course-card:hover { 
    transform: translateY(-5px); 
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.course-img { 
    width: 100%; 
    height: 160px; 
    object-fit: cover; 
}

.course-info { padding: 20px; }

.course-info h3 { 
    margin: 0 0 10px 0; 
    color: var(--azul-oscuro); 
    font-size: 1.1em;
}

.course-desc { 
    font-size: 0.9em; 
    color: #666; 
    margin-bottom: 0; 
    height: 40px; 
    overflow: hidden; 
    display: -webkit-box; 
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; 
}

/* Botones de edición flotantes */
.card-actions { 
    position: absolute; 
    top: 10px; 
    right: 10px;
    display: flex; 
    gap: 5px; 
    z-index: 10; 
}

/* =========================================
   4. PLAYER Y SIDEBAR
========================================= */
.player-header { 
    background: var(--blanco); 
    height: 60px; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 20px; 
    border-bottom: 1px solid #ddd; 
}

.player-body { 
    display: flex; 
    height: calc(100vh - 60px); 
    overflow: hidden; 
}

/* Sidebar */
.sidebar { 
    width: 340px; 
    background: var(--blanco); 
    border-right: 1px solid #ddd; 
    display: flex; 
    flex-direction: column; 
    flex-shrink: 0; 
}

.add-module-area { 
    padding: 15px; 
    background: #f8f9fa; 
    border-bottom: 1px solid #eee; 
}

.btn-add-module { 
    width: 100%; 
    padding: 12px; 
    background: #17a2b8; 
    color: white; 
    border: none; 
    border-radius: 5px; 
    cursor: pointer; 
    font-weight: bold; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
}

.modules-list { 
    flex: 1; 
    overflow-y: auto; 
    padding: 15px; 
}

/* Módulos */
.module-item { 
    border: 1px solid #eee; 
    border-radius: 8px; 
    margin-bottom: 15px; 
    overflow: hidden; 
    background: white; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.02); 
}

.module-header { 
    padding: 12px 15px; 
    background: white; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    cursor: pointer; 
    border-bottom: 1px solid #f0f0f0; 
}

.module-header strong { 
    color: var(--azul-oscuro); 
    font-size: 1.05em; 
}

.module-content { 
    background: #fafafa; 
    padding: 10px; 
}

/* Clases */
.class-block { 
    background: white; 
    padding: 8px 10px; 
    margin-bottom: 10px; 
    border-left: 4px solid var(--verde); 
    border-radius: 0 5px 5px 0; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); 
}

.class-title { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    font-weight: 600; 
    font-size: 0.95em; 
    color: #333; 
    margin-bottom: 8px; 
}

/* Grupo de botones bien alineados */
.action-group { 
    display: flex; 
    align-items: center; 
    gap: 4px; 
}

/* Materiales */
.material-list { 
    margin-top: 5px; 
    padding-left: 5px; 
}

.material-item { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 6px 0; 
    border-top: 1px dashed #eee; 
    font-size: 0.9em; 
    color: #555; 
}

.mat-info { 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    flex: 1; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
}

.mat-info:hover { 
    color: var(--azul-claro); 
    font-weight: 500; 
}

/* Examen Item */
.exam-item { 
    background: #fff9db; 
    border-left: 4px solid var(--amarillo); 
    padding: 10px; 
    margin: 8px 0; 
    border-radius: 4px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    font-weight: 600; 
    color: #664d03; 
    cursor: pointer; 
}

/* --- BOTONES E ICONOS --- */
.icon-btn-circle { 
    width: 30px; 
    height: 30px; 
    border-radius: 50%; 
    border: none; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    color: white; 
    transition: 0.2s; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.15); 
}

.icon-btn-circle i { font-size: 13px; }
.icon-btn-circle:hover { transform: scale(1.1); }

.edit { background: var(--azul-claro); }
.delete { background: var(--rojo); }
.add-exam-btn { background: var(--amarillo); color: #555; }

/* Botón Más (+) Materiales - Mismo tamaño que los otros para alinear */
.btn-plus { 
    width: 24px; 
    height: 24px; 
    border-radius: 50%; 
    background: var(--verde); 
    color: white; 
    border: none; 
    cursor: pointer; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 14px; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.15); 
}
.btn-plus:hover { background: #218838; transform: scale(1.1); }

.btn-ghost { 
    background: transparent; 
    border: none; 
    cursor: pointer; 
    color: #aaa; 
    padding: 4px; 
}
.btn-ghost:hover { color: #333; }

/* VISOR */
.viewer-area { 
    flex: 1; 
    background: var(--gris-fondo); /* CAMBIO AQUÍ */
    overflow-y: auto; 
    position: relative; 
}
.viewer-placeholder { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    height: 100%; 
    color: #666; 
}

/* =========================================
   5. MODALES (ESTILO MODERNO)
========================================= */
.modal-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.6); 
    z-index: 2000; 
    display: none; 
    justify-content: center; 
    align-items: center; 
    backdrop-filter: blur(2px); 
}

.modal-box { 
    background: white; 
    padding: 35px; 
    border-radius: 12px; 
    width: 95%; 
    max-width: 550px; 
    box-shadow: 0 15px 40px rgba(0,0,0,0.25); 
    max-height: 90vh; 
    overflow-y: auto; 
    animation: slideIn 0.3s ease; 
}

@keyframes slideIn { 
    from { transform: translateY(-20px); opacity: 0; } 
    to { transform: translateY(0); opacity: 1; } 
}

.modal-box h3 { 
    margin-top: 0; 
    color: var(--azul-oscuro); 
    border-bottom: 2px solid #f0f0f0; 
    padding-bottom: 15px; 
    margin-bottom: 20px; 
    font-size: 1.4em; 
}

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #444; font-size: 0.95em; }
.form-group input, .form-group select, .form-group textarea { 
    width: 100%; 
    padding: 12px 15px; 
    border: 1px solid #ccc; 
    border-radius: 6px; 
    font-size: 1em; 
    font-family: inherit; 
    transition: border 0.3s; 
    background: #fdfdfd; 
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { 
    border-color: var(--azul-claro); 
    outline: none; 
    background: white; 
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1); 
}

.modal-actions { 
    margin-top: 25px; 
    display: flex; 
    justify-content: flex-end; 
    gap: 12px; 
    border-top: 1px solid #f0f0f0; 
    padding-top: 20px; 
}

.btn-primary { 
    background: var(--azul-claro); 
    color: white; 
    padding: 10px 20px; 
    border: none; 
    border-radius: 6px; 
    cursor: pointer; 
    font-weight: 600; 
}

.btn-cancel { 
    background: white; 
    border: 1px solid #ccc; 
    color: #666; 
    padding: 10px 20px; 
    border-radius: 6px; 
    cursor: pointer; 
    font-weight: 600; 
}
.btn-cancel:hover { background: #f8f9fa; }

/* Tabla Usuarios */
table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 10px; 
}
table th { 
    text-align: left; 
    background: #f1f3f5; 
    padding: 12px; 
    color: #555; 
    font-size: 0.9em; 
}
table td { 
    padding: 12px; 
    border-bottom: 1px solid #eee; 
    font-size: 0.95em; 
}

/* Badges para Roles */
.badge-role { 
    padding: 5px 12px; 
    border-radius: 20px; 
    font-size: 0.85em; 
    font-weight: bold; 
    text-transform: capitalize; 
    display: inline-block; 
}
.badge-admin { background-color: var(--rol-admin-bg); color: var(--rol-admin-txt); }
.badge-teacher { background-color: var(--rol-profe-bg); color: var(--rol-profe-txt); }
.badge-student { background-color: var(--rol-estu-bg); color: var(--rol-estu-txt); }

/* =========================================
   6. EXAMEN (PANTALLA COMPLETA)
========================================= */
.exam-cover { 
    width: 100%; 
    height: 100%; 
    padding: 0; 
    margin: 0; 
    background: var(--gris-fondo); 
    display: flex; 
    flex-direction: column; 
}

.exam-header-card { 
    background: white; 
    width: 100%; 
    flex: 1; 
    padding: 40px; 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: center; 
    text-align: center; 
}

.exam-icon { 
    font-size: 50px; 
    color: var(--azul-claro); 
    margin-bottom: 25px; 
}

.exam-title { 
    font-size: 2.5em; 
    color: var(--azul-oscuro); 
    margin-bottom: 30px; 
    font-weight: 700; 
}

.exam-meta { 
    display: flex; 
    justify-content: center; 
    gap: 40px; 
    margin-bottom: 40px; 
    color: #555; 
    font-size: 1.1em; 
}

.btn-start-exam { 
    background: var(--azul-claro); 
    color: white; 
    padding: 18px 50px; 
    font-size: 1.2em; 
    border: none; 
    border-radius: 50px; 
    cursor: pointer; 
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.3); 
    text-transform: uppercase; 
    font-weight: 800; 
    letter-spacing: 1px; 
    transition: 0.3s; 
}
.btn-start-exam:hover { 
    background: #005f8f; 
    transform: translateY(-3px); 
}

.exam-active-container { 
    max-width: 1200px; /* CAMBIO: Más ancho para aprovechar pantalla */
    margin: 0 auto; 
    padding-bottom: 60px; 
    width: 96%; /* Usa casi todo el ancho disponible */
}

.exam-sticky-header { 
    position: sticky; 
    top: 0; 
    background: rgba(255,255,255,0.95); 
    backdrop-filter: blur(5px); 
    padding: 15px 20px; 
    z-index: 100; 
    border-bottom: 1px solid #ddd; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.question-card-view { 
    background: white; 
    margin: 20px 0; 
    padding: 40px; /* CAMBIO: Más espacio interno para leer mejor */
    border-radius: 8px; 
    border-left: 6px solid var(--azul-claro); 
    box-shadow: 0 4px 15px rgba(0,0,0,0.08); 
}

.option-label { 
    display: flex; 
    align-items: center; 
    padding: 15px; 
    border: 2px solid #eee; 
    border-radius: 8px; 
    cursor: pointer; 
    transition: 0.2s; 
    background: #fff; 
    margin-bottom: 8px; 
}
.option-label:hover { 
    background: #f8f9fa; 
    border-color: #ccc; 
}

.btn-finish-exam { 
    background: var(--verde); 
    color: white; 
    padding: 15px 50px; 
    font-size: 1.2em; 
    border: none; 
    border-radius: 5px; 
    cursor: pointer; 
    font-weight: bold; 
}

.attempts-section { 
    width: 100%; 
    max-width: 800px; 
    margin-top: 50px; 
    border-top: 2px dashed #eee; 
    padding-top: 20px; 
}

.badge-score { 
    padding: 5px 12px; 
    border-radius: 15px; 
    font-weight: bold; 
}
.badge-score.pass { background: #d4edda; color: #155724; }
.badge-score.fail { background: #f8d7da; color: #721c24; }

.score-circle { 
    width: 120px; 
    height: 120px; 
    border-radius: 50%; 
    border: 8px solid #ddd; 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: center; 
    margin: 20px auto; 
    font-weight: bold; 
}
.score-number { 
    font-size: 2.5em; 
    color: #333; 
    line-height: 1; 
}