/* ==========================================================================
   1. OFFICE AUTH (Login y Registro)
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--tenant-font, 'Segoe UI', system-ui, -apple-system, sans-serif);
}

.auth-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    background-color: var(--bg-color, #ffffff);
    color: var(--text-color, #333333);
}

.auth-form-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    width: 100%;
}

.auth-form-container {
    width: 100%;
    max-width: 420px; 
}

.auth-header { text-align: center; margin-bottom: 2.5rem; }
.auth-logo { max-height: 60px; margin-bottom: 1rem; }
.auth-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--text-color, #1e293b); }
.auth-subtitle { color: color-mix(in srgb, var(--text-color) 70%, transparent); font-size: 0.95rem; }

.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; margin-bottom: 0.5rem; font-weight: 600; font-size: 0.9rem; color: var(--text-color, #333333); }
.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: transparent;
    color: var(--text-color, #333333);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color, #2563eb); 
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color, #2563eb) 20%, transparent);
}

.auth-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; font-size: 0.9rem; }
.auth-link { color: var(--primary-color, #2563eb); text-decoration: none; font-weight: 600; }
.auth-link:hover { color: var(--secondary-color, #1d4ed8); text-decoration: underline; }

.auth-layout .btn-primary {
    display: block;
    width: 100%;
    padding: 0.85rem;
    background-color: var(--primary-color, #2563eb);
    color: var(--btn-text-color, #ffffff) !important;
    border: 2px solid var(--btn-border-color, transparent);
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}
.auth-layout .btn-primary:hover { opacity: 0.9; }

.auth-image-section { display: none; }

@media (min-width: 768px) {
    .auth-layout { display: grid; grid-template-columns: 1fr 1fr; }
    .auth-image-section {
        display: block;
        background-color: var(--primary-color, #f3f4f6);
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        position: relative;
    }
    .auth-image-section::after {
        content: '';
        position: absolute;
        inset: 0;
        background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    }
}

/* ==========================================================================
   2. DASHBOARDS OFFICE Y PROFESOR (ESTADÍSTICAS OPERATIVAS)
   ========================================================================== */
.stats-grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
    gap: 1.5rem; 
    margin-bottom: 2.5rem; 
}

/* Base de la Tarjeta */
.stat-card { 
    background: white; 
    padding: 1.5rem; 
    border-radius: 8px; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); 
    border-left: 4px solid var(--primary-color, #2563eb); /* Color por defecto */
    text-decoration: none; 
    display: block; 
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 15px rgba(0,0,0,0.05); }

/* Colores personalizados para las tarjetas operativas (Border Left) */
.stat-card-yellow { border-left: 4px solid #eab308; background: white; padding: 1.5rem; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); text-decoration: none; display: block;}
.stat-card-yellow .stat-title { color: #ca8a04; }
.stat-card-yellow .stat-value { color: var(--text-color, #1e293b); }
.stat-card-yellow:hover { background: #fef3c7; }

.stat-card-indigo { border-left: 4px solid #8b5cf6; background: white; padding: 1.5rem; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); text-decoration: none; display: block;}
.stat-card-indigo .stat-title { color: #7c3aed; }
.stat-card-indigo .stat-value { color: var(--text-color, #1e293b); }
.stat-card-indigo:hover { background: #eaccff; }

.stat-card-orange { border-left: 4px solid #f97316; background: white; padding: 1.5rem; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); text-decoration: none; display: block;}
.stat-card-orange .stat-title { color: #ea580c; }
.stat-card-orange .stat-value { color: var(--text-color, #1e293b); }
.stat-card-orange:hover { background: #ffedd5; }

.stat-card-red { border-left: 4px solid #ef4444; background: white; padding: 1.5rem; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); text-decoration: none; display: block;}
.stat-card-red .stat-title { color: #dc2626; }
.stat-card-red .stat-value { color: var(--text-color, #1e293b); }
.stat-card-red:hover { background: #fee2e2; }

/* Colores específicos de bordes y títulos para las tarjetas */
.stat-card.blue   { border-left-color: #2563eb; } .stat-card.blue   .stat-title { color: #2563eb; }
.stat-card.green  { border-left-color: #10b981; } .stat-card.green  .stat-title { color: #10b981; }
.stat-card.purple { border-left-color: #8b5cf6; } .stat-card.purple .stat-title { color: #8b5cf6; }
.stat-card.yellow { border-left-color: #eab308; } .stat-card.yellow .stat-title { color: #ca8a04; }
.stat-card.indigo { border-left-color: #4f46e5; } .stat-card.indigo .stat-title { color: #4338ca; }
.stat-card.orange { border-left-color: #f97316; } .stat-card.orange .stat-title { color: #ea580c; }
.stat-card.red    { border-left-color: #ef4444; } .stat-card.red    .stat-title { color: #dc2626; }

/* Tipografía dentro de las tarjetas */
.stat-title { 
    font-size: 0.85rem; 
    text-transform: uppercase; 
    font-weight: 700; 
    letter-spacing: 0.5px; 
    margin-bottom: 0.5rem; 
    color: var(--primary-color, #2563eb); 
}
.stat-value { 
    font-size: 2.5rem; 
    font-weight: 700; 
    color: var(--text-color, #1e293b); 
    margin: 0; 
    line-height: 1; 
}

/* Badges específicos para estados de inscripciones */
.badge-warning { background: #fef08a; color: #854d0e; padding: 0.25rem 0.6rem; border-radius: 9999px; font-size: 0.75rem; font-weight: bold; border: 1px solid #fde047;}
.badge-danger { background: #fee2e2; color: #991b1b; padding: 0.25rem 0.6rem; border-radius: 9999px; font-size: 0.75rem; font-weight: bold; border: 1px solid #fecaca;}
.badge-active { background: #dcfce7; color: #166534; padding: 0.25rem 0.6rem; border-radius: 9999px; font-size: 0.75rem; font-weight: bold; border: 1px solid #bbf7d0;}
.text-highlight { font-weight: bold; color: var(--primary-color, #2563eb); }
.text-strong { font-weight: 600; color: var(--text-color, #1e293b); }

/* ==========================================================================
   ESTILOS EXCLUSIVOS DEL OFFICE (Admin de Instituto)
   ========================================================================== */
.office-main { display: flex; flex-direction: column; min-height: 100%; }

.dashboard-header { margin-bottom: 2rem; }
.dashboard-header h1 { margin: 0; color: var(--text-color, #1e293b); font-size: 1.8rem; border: none; }
.dashboard-header p { color: color-mix(in srgb, var(--text-color) 70%, #64748b); margin-top: 0.5rem; margin-bottom: 0; font-size: 0.95rem; }

/* Botones de acción frecuente (Sección Media) */
.section-title { font-size: 1.1rem; color: var(--text-color, #1e293b); margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid #e2e8f0; }

.actions-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 1rem; 
    margin-bottom: 2.5rem; 
}
.action-btn { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 1rem; 
    background: white; 
    border: 1px solid #cbd5e1; 
    border-radius: 8px; 
    text-decoration: none; 
    color: var(--text-color, #334155); 
    font-weight: 600; 
    transition: all 0.2s; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.02); 
    gap: 0.5rem;
}
.action-btn:hover { 
    border-color: var(--primary-color, #2563eb); 
    color: var(--primary-color, #2563eb); 
    transform: translateY(-2px); 
    box-shadow: 0 4px 6px rgba(37,99,235,0.1); 
}

/* ==========================================================================
   CONFIGURACIÓN DE MARCA (VISTA PREVIA DE IMÁGENES CON ZOOM)
   ========================================================================== */
.img-zoom-wrapper {
    width: 100%; 
    height: 140px; 
    background: #f1f5f9; 
    border: 1px dashed #cbd5e1; 
    border-radius: 6px; 
    margin-bottom: 8px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    position: relative;
}

.zoomable-img {
    max-width: 100%; 
    max-height: 100%; 
    object-fit: contain;
    cursor: zoom-in; 
    transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1); 
    position: relative; 
    z-index: 1;
    border-radius: 4px;
}

.zoomable-img:hover {
    transform: scale(3.5);
    z-index: 100;
    background: #ffffff;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 4px;
    border: 1px solid #e2e8f0;
}

.zoom-origin-left { transform-origin: left center; }
.zoom-origin-right { transform-origin: right center; }

/* ==========================================================================
   UTILIDADES DE FORMULARIOS Y CAJAS (Cero estilos en línea)
   ========================================================================== */
.form-container-wide { max-width: 800px; margin-left: 0; }
.field-note { font-size: 0.85rem; color: #64748b; margin-top: 0.25rem; display: block; }
.error-text { color: #dc2626; font-size: 0.85rem; margin-top: 0.25rem; display: flex; align-items: center; gap: 0.3rem; font-weight: 600; }

.box-highlight { background: color-mix(in srgb, var(--bg-color) 95%, #000); padding: 1.5rem; border-radius: 8px; border: 1px dashed #cbd5e1; margin-bottom: 1.5rem; }
.box-highlight-flex { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }

.checkbox-label { cursor: pointer; display: flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--text-color, #1e293b); }
.form-divider { border: 0; border-top: 1px solid #e2e8f0; margin-bottom: 1.5rem; }
.form-actions-right { text-align: right; }

.btn-icon-text { 
    display: inline-flex; align-items: center; gap: 0.4rem; justify-content: center; 
    padding: 0.6rem 1.2rem; border-radius: 6px; text-decoration: none; font-weight: 600; 
    transition: all 0.2s; cursor: pointer;
}

/* Previsualización de imágenes en formularios */
.cover-preview-wrapper { flex-shrink: 0; text-align: center; }
.cover-preview-title { display: block; font-size: 0.85rem; color: #64748b; margin-bottom: 0.5rem; font-weight: 600; }
.cover-preview-img { width: 120px; border-radius: 6px; border: 1px solid #e2e8f0; object-fit: cover; }
.form-control-file { background: white; margin-bottom: 0.5rem; padding: 0.5rem; }

/* ==========================================================================
   CURRÍCULUM Y TEMARIO (Contenedores Multimedia)
   ========================================================================== */
.topic-content-box { padding: 1rem 1.5rem; background: #ffffff; border-bottom: 1px dashed #cbd5e1; font-size: 0.95rem; color: var(--text-color, #334155); }
.lessons-list { list-style: none; padding: 0; margin: 0 0 1.5rem 0; min-height: 10px; }
.lesson-content-box { padding: 1.5rem; background: var(--bg-color, #f8fafc); border-top: 1px dashed #cbd5e1; font-size: 0.95rem; color: var(--text-color, #334155); }

/* Reproductores Multimedia */
.media-video-wrapper { width: 80%; margin: 0 auto; border-radius: 8px; overflow: hidden; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.2); background: #000; }
.media-video-iframe { width: 100%; aspect-ratio: 16/9; display: block; border: none; }

.media-audio-wrapper { width: 80%; margin: 0 auto; background: white; padding: 1.5rem; border-radius: 8px; border: 1px solid #cbd5e1; box-shadow: 0 4px 6px rgba(0,0,0,0.05); text-align: center; }
.media-audio-title { display: flex; align-items: center; justify-content: center; gap: 0.5rem; font-weight: bold; margin-bottom: 1rem; color: var(--text-color, #0f172a); }

.media-doc-wrapper { width: 95%; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; align-items: center; }
.media-doc-container { width: 100%; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.1); border: 1px solid #cbd5e1; background: #e2e8f0; }

.media-book-wrapper { width: 80%; margin: 0 auto; background: color-mix(in srgb, var(--primary-color) 10%, #eff6ff); padding: 1.5rem; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--primary-color) 30%, #bfdbfe); text-align: center; }
.media-book-title { color: var(--primary-color, #1e40af); margin-bottom: 0.5rem; }
.media-book-desc { color: color-mix(in srgb, var(--primary-color) 80%, #3b82f6); font-size: 0.9rem; }

/* Modal y Editores Quill */
.quill-editor-container { background: white; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; height: 200px; }
.btn-add-activity { background: var(--bg-color, #f1f5f9); color: var(--text-color, #475569); border: 1px dashed #cbd5e1; padding: 0.6rem 1rem; border-radius: 6px; cursor: pointer; font-weight: 600; width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.5rem; transition: all 0.2s; }
.btn-add-activity:hover { border-color: var(--primary-color); color: var(--primary-color); }

/* ==========================================================================
   TEMARIO: UNIDADES Y ACTIVIDADES (Drag & Drop)
   ========================================================================== */
.empty-state-dashed { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 4rem 2rem; text-align: center; color: #64748b; background: #f8fafc; margin-top: 2rem; }

/* Unidades (Nivel 1) */
.topic-item { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 1.5rem; box-shadow: 0 2px 4px rgba(0,0,0,0.02); overflow: hidden; }
.topic-header { background: #f8fafc; padding: 1rem 1.5rem; display: flex; align-items: center; gap: 1rem; border-bottom: 1px solid #e2e8f0; }
.topic-title { flex-grow: 1; margin: 0; font-size: 1.15rem; color: var(--text-color, #1e293b); font-weight: 700; }

/* Actividades (Nivel 2) */
.lesson-item { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 6px; margin-bottom: 0.75rem; overflow: hidden; transition: box-shadow 0.2s; }
.lesson-item:hover { box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.lesson-header { padding: 0.75rem 1rem; display: flex; align-items: center; gap: 1rem; background: #ffffff; }

/* Utilidades Drag & Drop */
.drag-handle { cursor: grab; color: #94a3b8; display: flex; align-items: center; justify-content: center; }
.drag-handle:active { cursor: grabbing; color: var(--primary-color, #2563eb); }
.drag-handle:hover { color: var(--primary-color, #2563eb); }

.content-limiter { max-height: 250px; overflow: hidden; position: relative; transition: max-height 0.3s ease; }
.content-limiter.expanded { max-height: 5000px; }
.content-limiter.has-overflow::after { content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 60px; background: linear-gradient(to bottom, transparent, white); pointer-events: none; }
.content-limiter.expanded::after { display: none; }
.read-more-btn { background: none; border: none; color: var(--primary-color, #2563eb); font-weight: 600; cursor: pointer; display: none; align-items: center; gap: 0.3rem; margin-top: 0.5rem; padding: 0; }

/* ==========================================================================
   MÓDULO DE EXÁMENES Y EVALUACIONES (Cero Estilos en Línea)
   ========================================================================== */
.exam-layout, .builder-layout, .review-layout { display: flex; flex-direction: column; gap: 2rem; }
@media (min-width: 992px) {
    .exam-layout, .builder-layout, .review-layout { flex-direction: row; align-items: flex-start; }
    .exam-layout > div:first-child, .builder-layout > div:first-child, .review-layout > div:first-child { flex: 1; min-width: 0; }
    .exam-layout > div:last-child, .builder-layout > div:last-child, .review-layout > div:last-child { width: 380px; flex-shrink: 0; position: sticky; top: 2rem; }
}

/* Listado de Exámenes */
.exam-title-group { font-weight: 600; font-size: 1.05rem; color: var(--text-color, #1e293b); margin-bottom: 0.25rem; }
.exam-meta-group { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: #64748b; }

/* Builder: Panel de Puntuación */
.score-panel { display: flex; justify-content: space-between; background: var(--bg-color, #f8fafc); padding: 1.5rem; border-radius: 8px; border: 1px solid #e2e8f0; margin-bottom: 1.5rem; }
.score-total { font-size: 1.1rem; color: var(--primary-color, #2563eb); }
.score-passing { font-size: 1.1rem; color: #10b981; }

/* Builder: Tarjetas de Preguntas */
.question-card { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 1.5rem; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.question-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; border-bottom: 1px dashed #e2e8f0; padding-bottom: 1rem; }
.question-badge { background: color-mix(in srgb, var(--primary-color) 10%, #eff6ff); color: var(--primary-color, #2563eb); padding: 0.3rem 0.8rem; border-radius: 9999px; font-size: 0.8rem; font-weight: bold; }
.question-title { margin: 0 0 1rem 0; font-size: 1.1rem; color: var(--text-color, #1e293b); font-weight: 600; line-height: 1.5; }
.question-options { list-style: disc; margin: 0 0 1rem 1.5rem; padding: 0; color: #475569; line-height: 1.6; }
.correct-answer-box { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; padding: 1rem; border-radius: 6px; font-size: 0.9rem; }

/* Review: Tarjetas de Respuestas */
.review-answer-card { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 1.5rem; margin-bottom: 1.5rem; border-left: 4px solid #cbd5e1; }
.review-answer-correct { border-left-color: #10b981; background: #f0fdf4; }
.review-answer-incorrect { border-left-color: #ef4444; background: #fef2f2; }
.review-student-ans, .review-correct-ans { padding: 0.75rem; border-radius: 6px; background: white; border: 1px solid #e2e8f0; margin-bottom: 0.5rem;}

/* Review: Veredicto y Paneles Laterales */
.verdict-panel { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 2rem; text-align: center; margin-bottom: 1.5rem; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.verdict-label { font-size: 0.9rem; color: #64748b; text-transform: uppercase; font-weight: bold; letter-spacing: 1px; margin-bottom: 0.5rem; }
.verdict-score { font-size: 3.5rem; font-weight: 800; line-height: 1; margin-bottom: 1rem; }
.verdict-badge { display: inline-block; padding: 0.5rem 1.5rem; border-radius: 9999px; font-weight: bold; font-size: 0.9rem; letter-spacing: 0.5px; }
.verdict-badge-pass { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0;}
.verdict-badge-fail { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca;}

.warning-panel { background: #fef2f2; border: 1px solid #fecaca; padding: 1.5rem; border-radius: 8px; color: #991b1b; margin-bottom: 1.5rem; }
.retake-panel { background: #fffbeb; border: 1px solid #fde68a; padding: 1.5rem; border-radius: 8px; margin-bottom: 1.5rem; }

/* ==========================================================================
   ROLES Y ESTADOS DE USUARIOS (Directorio)
   ========================================================================== */
.badge-role { padding: 0.25rem 0.6rem; border-radius: 9999px; font-size: 0.75rem; font-weight: bold; border: 1px solid transparent; display: inline-block; }
.role-super { background: #f3e8ff; color: #7e22ce; border-color: #d8b4fe; }
.role-admin { background: color-mix(in srgb, var(--primary-color) 10%, #eff6ff); color: var(--primary-color, #2563eb); border-color: color-mix(in srgb, var(--primary-color) 30%, #bfdbfe); }
.role-teacher { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.role-student { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }

.status-indicator { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.85rem; font-weight: 600; }
.status-active { color: #10b981; }
.status-inactive { color: #94a3b8; }

.user-meta-info { font-size: 0.85rem; color: #64748b; margin-top: 0.25rem; }
.text-strike { text-decoration: line-through; opacity: 0.7; }

.history-section { margin-top: 3rem; border-top: 2px dashed #e2e8f0; padding-top: 2rem; }
.history-title { margin: 0; color: #64748b; font-size: 1.3rem; }

/* ==========================================================================
   MÓDULO DE GRUPOS Y ESTUDIANTES
   ========================================================================== */
.dates-info strong { color: var(--text-color, #1e293b); font-weight: 600; margin-right: 0.25rem; }
.text-lg-strong { font-size: 1.1rem; font-weight: 700; color: var(--text-color, #1e293b); }
.text-sm-badge { font-size: 0.85rem; }

/* Barras de Progreso */
.table-progress-container { display: flex; align-items: center; gap: 0.75rem; width: 100%; max-width: 150px; }
.table-progress-track { flex-grow: 1; height: 8px; background: #e2e8f0; border-radius: 9999px; overflow: hidden; }
.table-progress-fill { height: 100%; border-radius: 9999px; transition: width 0.5s ease; }
.table-progress-text { font-size: 0.85rem; font-weight: 600; color: var(--text-color, #334155); min-width: 35px; text-align: right; }

/* Iconos Sociales Específicos */
.btn-icon-whatsapp { color: #16a34a !important; }
.btn-icon-whatsapp:hover { background: #dcfce7 !important; color: #15803d !important; }
.btn-icon-email { color: #8b5cf6 !important; }
.btn-icon-email:hover { background: #f3e8ff !important; color: #7e22ce !important; }
.btn-icon-profile { color: #0ea5e9 !important; }
.btn-icon-profile:hover { background: #e0f2fe !important; color: #0369a1 !important; }

/* ==========================================================================
   CENTRO DE EVALUACIONES (Revisiones y Actividades)
   ========================================================================== */
.dashboard-section-block { margin-bottom: 3rem; }
.section-title-wrapper { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.section-title-main { margin: 0; font-size: 1.3rem; color: var(--text-color, #1e293b); }

/* Fila oculta de respuestas (Acordeón) */
.reply-row.hidden { display: none; }
.reply-cell { padding: 0 !important; background: color-mix(in srgb, var(--bg-color) 95%, #000); border-bottom: 1px solid #e2e8f0; }
.reply-content-box { padding: 1.5rem 3rem; border-left: 4px solid var(--primary-color, #2563eb); }
.reply-header { display: flex; align-items: center; gap: 0.5rem; color: #64748b; font-size: 0.85rem; margin-bottom: 0.75rem; font-weight: 600; }
.reply-body { color: var(--text-color, #334155); line-height: 1.6; }

/* Tarjetas y Layout de la vista "Revisar" */
.review-grid-layout { display: grid; grid-template-columns: 1fr; gap: 2rem; margin-bottom: 2rem; }
@media (min-width: 992px) { .review-grid-layout { grid-template-columns: 1fr 1fr; } }

.eval-context-card { background: white; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.02); }
.eval-context-header { padding: 1.5rem; border-bottom: 1px solid #e2e8f0; background: var(--bg-color, #f8fafc); }
.eval-context-body { padding: 1.5rem; }

.eval-student-info { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.avatar-circle { width: 48px; height: 48px; background: #e2e8f0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; color: #64748b; font-size: 1.2rem; }
.eval-activity-content { background: color-mix(in srgb, var(--bg-color) 95%, #000); padding: 1.25rem; border-radius: 8px; color: var(--text-color, #334155); line-height: 1.6; overflow-wrap: break-word; }

.eval-form-card { background: white; border: 1px solid #e2e8f0; border-radius: 12px; padding: 1.5rem; box-shadow: 0 4px 6px rgba(0,0,0,0.02); }

/* ==========================================================================
   OFFICE LANDING PAGE (PORTADA DEL INSTITUTO Y HERO)
   ========================================================================== */
/* Contenedor principal que envuelve el Hero para darle los márgenes y bordes */
.hero-container-wrapper {
    width: 100%;
    padding: 2rem 5%;
    box-sizing: border-box;
    background-color: var(--bg-color, #ffffff);
}

.hero-section { 
    width: 100%;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    box-sizing: border-box;
    /* Usamos el color primario del instituto y lo oscurecemos ligeramente para el gradiente */
    background: linear-gradient(135deg, var(--primary-color) 0%, color-mix(in srgb, var(--primary-color) 40%, black) 100%);
    box-shadow: 0 10px 25px -5px color-mix(in srgb, var(--primary-color) 40%, transparent);
}

.hero-title { 
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    /* El texto toma el color configurado para resaltar sobre botones (usualmente blanco) */
    color: var(--btn-text-color, #ffffff);
    max-width: 800px;
    margin: 0 auto 1rem auto;
    word-wrap: break-word;
    border: none;
}

.hero-subtitle { 
    font-size: 1.1rem;
    /* Un color de contraste suave basado en el texto del botón */
    color: color-mix(in srgb, var(--btn-text-color, #ffffff) 80%, transparent);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Grid de Cursos (Catálogo) */
.features-section { max-width: 1200px; margin: 0 auto 4rem auto; padding: 0 2rem; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 2rem; }

/* Tarjetas de Curso */
.course-card { background: #ffffff; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.05); transition: all 0.3s ease; border: 1px solid #e2e8f0; display: flex; flex-direction: column; }
.course-card:hover { transform: translateY(-8px); box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); }

.course-image { width: 100%; height: 220px; background-size: cover; background-position: center; border-bottom: 1px solid #e2e8f0; }
.course-card-body { padding: 2rem; display: flex; flex-direction: column; flex-grow: 1; }

.course-header-flex { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; gap: 1rem; }
.feature-title { font-size: 1.25rem; font-weight: 700; color: var(--text-color, #1e293b); margin: 0; line-height: 1.3; }
.course-badge { display: flex; align-items: center; gap: 0.3rem; background: color-mix(in srgb, var(--primary-color) 10%, #eff6ff); color: var(--primary-color, #2563eb); padding: 0.4rem 0.8rem; border-radius: 9999px; font-size: 0.85rem; font-weight: 700; white-space: nowrap; }

.feature-text { color: color-mix(in srgb, var(--text-color) 80%, transparent); font-size: 0.95rem; line-height: 1.6; margin-bottom: 2rem; flex-grow: 1; }

/* Temario en Tarjeta */
.course-topics-section { margin-bottom: 2rem; }
.course-topics-title { font-size: 0.8rem; color: #94a3b8; text-transform: uppercase; font-weight: 700; letter-spacing: 0.5px; margin-bottom: 1rem; }
.course-topics-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.course-topic-item { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.9rem; color: var(--text-color, #334155); }

/* Botones Landing */
.btn-course-action { display: flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%; padding: 1rem; text-decoration: none; border-radius: 8px; font-weight: 600; font-size: 1rem; transition: all 0.2s; }
.btn-enroll-req { background-color: transparent !important; color: #94a3b8 !important; border: 1px dashed #cbd5e1 !important; cursor: not-allowed; }
.btn-enroll-request { background-color: var(--secondary-color, #0ea5e9) !important; color: var(--btn-text-color, #ffffff) !important; border: none !important; }
.btn-enroll-request:hover { filter: brightness(0.9); }
.btn-enroll-pending { background-color: #fef3c7 !important; color: #d97706 !important; border: 1px solid #fde68a !important; cursor: not-allowed; }
.btn-enroll-continue { background-color: #10b981 !important; color: white !important; border: none !important; }
.btn-enroll-continue:hover { filter: brightness(0.9); }
.btn-enroll-review { background-color: #f1f5f9 !important; color: #475569 !important; border: 1px solid #cbd5e1 !important; }
.btn-enroll-review:hover { background-color: #e2e8f0 !important; }

/* ==========================================================================
   CONSTRUCTOR VISUAL Y FORMULARIOS (Libros Interactivos)
   ========================================================================== */

/* Formularios de Crear/Editar */
.form-card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 2rem; max-width: 800px; margin: 0 auto; box-shadow: 0 4px 6px rgba(0,0,0,0.02); }
.form-group-spaced { margin-bottom: 1.5rem; }
.form-label-bold { display: block; font-weight: 600; color: var(--text-color, #1e293b); margin-bottom: 0.5rem; }
.form-control-full { width: 100%; padding: 0.75rem 1rem; border: 1px solid #cbd5e1; border-radius: 6px; font-family: inherit; font-size: 0.95rem; transition: border-color 0.2s; box-sizing: border-box; }
.form-control-full:focus { outline: none; border-color: var(--primary-color, #2563eb); }
.form-checkbox-label { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; font-size: 0.95rem; color: #475569; }
.form-checkbox-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary-color, #2563eb); }
.form-actions-footer { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid #e2e8f0; }

.btn-primary-large { background: var(--primary-color, #2563eb); color: white; border: none; padding: 0.75rem 1.5rem; border-radius: 6px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.btn-primary-large:hover { background: color-mix(in srgb, var(--primary-color) 80%, black); }

.back-link { display: inline-flex; align-items: center; gap: 0.25rem; color: #64748b; text-decoration: none; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.5rem; transition: color 0.2s; }
.back-link:hover { color: var(--primary-color, #2563eb); }

/* Layout Principal del Editor (3 Columnas) */
.builder-layout { display: flex; height: calc(100vh - 140px); min-height: 600px; border: 1px solid #cbd5e1; border-radius: 8px; overflow: hidden; background: #f8fafc; margin-bottom: 2rem; }

/* Paneles Laterales (Columna 1 y 3) */
.builder-panel { background: #ffffff; display: flex; flex-direction: column; flex-shrink: 0; height: 100%; overflow: hidden; }
.builder-panel.panel-left { width: 200px; border-right: 1px solid #cbd5e1; }
.builder-panel.panel-right { width: 300px; border-left: 1px solid #cbd5e1; }

.builder-panel-header { padding: 1rem; font-weight: 700; color: var(--text-color, #1e293b); border-bottom: 1px solid #cbd5e1; background: color-mix(in srgb, var(--primary-color) 5%, #f8fafc); text-transform: uppercase; font-size: 0.85rem; flex-shrink: 0; }
.builder-panel-body { flex: 1; overflow-y: auto; padding: 1.5rem 1rem; }

/* Botón Subir Página */
.btn-upload-page { border: 2px dashed #94a3b8; background: #f1f5f9; border-radius: 8px; padding: 1.5rem 1rem; text-align: center; cursor: pointer; color: #64748b; font-weight: 600; font-size: 0.85rem; transition: all 0.2s; margin-bottom: 1.5rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.btn-upload-page:hover { border-color: var(--primary-color, #2563eb); color: var(--primary-color, #2563eb); background: color-mix(in srgb, var(--primary-color) 5%, white); }
.btn-upload-page svg { width: 24px; height: 24px; }

/* Miniaturas de Páginas */
.page-thumbnail { position: relative; border: 2px solid transparent; border-radius: 6px; overflow: hidden; margin: 0 auto 1.5rem auto; width: 60%; cursor: grab; background: #e2e8f0; transition: border-color 0.2s; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.page-thumbnail img { width: 100%; display: block; aspect-ratio: 3/4; object-fit: cover; pointer-events: none; }
.page-thumbnail.active { border-color: var(--primary-color, #2563eb); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 20%, transparent); }
.page-number-badge { position: absolute; top: 0.5rem; left: 0.5rem; background: rgba(0,0,0,0.6); color: white; font-size: 0.75rem; font-weight: bold; padding: 0.15rem 0.4rem; border-radius: 4px; z-index: 2; }
.page-actions { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.7); display: flex; justify-content: center; gap: 0.5rem; padding: 0.4rem; opacity: 0; transition: opacity 0.2s; }
.page-thumbnail:hover .page-actions { opacity: 1; }
.btn-thumb-action { background: white; border: none; width: 24px; height: 24px; border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #475569; }
.btn-thumb-action:hover { color: var(--primary-color, #2563eb); }
.btn-thumb-delete:hover { color: #ef4444; }

/* Espacio de Trabajo Central (Lienzo) */
.builder-workspace { flex-grow: 1; overflow: hidden; position: relative; background: #cbd5e1; display: flex; align-items: center; justify-content: center; }
.canvas-container { position: relative; transform-origin: center center; transition: transform 0.1s ease-out; box-shadow: 0 10px 25px rgba(0,0,0,0.15); background: white; display: inline-block; }
.canvas-bg-image { display: block; height: 75vh; width: auto; max-width: none; pointer-events: none; object-fit: contain; }

/* Herramientas (Botones Drag & Drop) */
.tool-btn { background: white; border: 1px solid #cbd5e1; border-radius: 6px; padding: 0.75rem; margin-bottom: 0.5rem; cursor: grab; display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; color: #334155; font-weight: 500; transition: all 0.2s; }
.tool-btn:hover { border-color: var(--primary-color, #2563eb); color: var(--primary-color, #2563eb); box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.tool-btn svg { width: 18px; height: 18px; }

/* Elementos inyectados en el Canvas */
.canvas-element { position: absolute; box-sizing: border-box; z-index: 10; }
.canvas-element.selected { outline: 2px solid var(--primary-color, #3b82f6); outline-offset: 2px; }
.canvas-element.locked { outline: 2px dashed #10b981; outline-offset: 2px; }
.resizer { position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px; background: var(--primary-color, #3b82f6); border: 2px solid white; border-radius: 50%; cursor: se-resize; display: none; z-index: 20; }
.canvas-element.selected .resizer { display: block; }
.canvas-element.locked .resizer { display: none !important; }

/* Botón de Audio inyectado */
.audio-widget { position: relative; border-radius: 50%; background: var(--primary-color, #2563eb); box-shadow: 0 4px 6px rgba(0,0,0,0.1); display: flex; align-items: center; justify-content: center; }
.audio-btn-toggle { background: transparent; border: none; color: white; width: 100%; height: 100%; cursor: pointer; border-radius: 50%; display: flex; align-items: center; justify-content: center; padding: 0; }
.audio-btn-toggle svg { width: 50%; height: 50%; fill: currentColor; }

/* Controles Flotantes (Zoom, Pan, Preview) */
.floating-controls-wrapper { position: absolute; bottom: 1.5rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 1rem; z-index: 100; }
.zoom-controls { background: white; border: 1px solid #cbd5e1; border-radius: 9999px; display: flex; align-items: center; padding: 0.25rem; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.btn-zoom { background: transparent; border: none; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #64748b; transition: all 0.2s; }
.btn-zoom:hover { background: #f1f5f9; color: var(--primary-color, #2563eb); }
.btn-zoom.active-tool { background: color-mix(in srgb, var(--primary-color) 10%, transparent); color: var(--primary-color, #2563eb); }
.zoom-level-display { font-size: 0.8rem; font-weight: 700; color: #475569; min-width: 45px; text-align: center; }

/* Paginación en Vista Previa */
.preview-pagination { background: #1e293b; border-radius: 9999px; display: flex; align-items: center; padding: 0.25rem 0.5rem; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3); }
.preview-pagination button { background: transparent; border: none; color: white; padding: 0.5rem 1rem; font-weight: 600; font-size: 0.85rem; cursor: pointer; border-radius: 9999px; transition: background 0.2s; }
.preview-pagination button:hover:not(:disabled) { background: rgba(255,255,255,0.1); }
.preview-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.preview-page-indicator { color: #94a3b8; font-size: 0.85rem; font-weight: 600; padding: 0 1rem; }

/* Panel de Propiedades */
.properties-divider { height: 1px; background: #e2e8f0; margin: 1.5rem 0; }
.properties-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.properties-header h3 { margin: 0; font-size: 1.1rem; color: var(--text-color, #1e293b); }
.prop-badge { background: color-mix(in srgb, var(--primary-color) 10%, #f1f5f9); color: var(--primary-color, #2563eb); font-size: 0.75rem; font-weight: 700; padding: 0.2rem 0.5rem; border-radius: 4px; }
.prop-label { display: block; font-size: 0.85rem; font-weight: 600; color: #475569; margin-bottom: 0.4rem; }
.prop-input, .prop-textarea, .prop-select { width: 100%; padding: 0.6rem; border: 1px solid #cbd5e1; border-radius: 4px; font-family: inherit; font-size: 0.9rem; margin-bottom: 1rem; box-sizing: border-box; }
.prop-textarea { resize: vertical; min-height: 60px; }
.prop-checkbox-wrapper { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 1rem; cursor: pointer; }
.prop-checkbox-wrapper input { margin-top: 0.2rem; accent-color: var(--primary-color, #2563eb); }
.prop-checkbox-label { font-size: 0.85rem; color: #334155; line-height: 1.4; }
.prop-file-btn { display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.6rem; background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 4px; cursor: pointer; color: #475569; font-size: 0.85rem; font-weight: 500; transition: border-color 0.2s; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop-file-btn:hover { border-color: var(--primary-color, #2563eb); }
.prop-file-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-delete-widget { width: 100%; padding: 0.75rem; background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; border-radius: 6px; font-weight: 600; cursor: pointer; margin-top: 1rem; transition: background 0.2s; }
.btn-delete-widget:hover { background: #fee2e2; }

/* Variables de Dibujo */
#drawSelection { display: none; position: absolute; border: 2px dashed var(--primary-color, #3b82f6); background: color-mix(in srgb, var(--primary-color) 15%, transparent); z-index: 50; pointer-events: none; }
#widgetContextMenu { display: none; position: absolute; background: #ffffff; border: 1px solid #cbd5e1; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.15); z-index: 1000; padding: 0.5rem; min-width: 180px; }
#widgetContextMenu .menu-title { font-size: 0.75rem; font-weight: 700; color: #64748b; text-transform: uppercase; margin-bottom: 0.5rem; padding: 0 0.5rem; }
#widgetContextMenu button { display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.5rem; background: transparent; border: none; text-align: left; color: #334155; font-size: 0.85rem; font-weight: 500; border-radius: 6px; cursor: pointer; transition: background 0.2s; }
#widgetContextMenu button:hover { background: #f1f5f9; color: #0f172a; }
.canvas-element .full-size-widget { width: 100%; height: 100%; box-sizing: border-box; }
.canvas-element .centered-widget-wrapper { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.checkbox-ui { width: 24px; height: 24px; cursor: pointer; pointer-events: auto; accent-color: var(--primary-color, #3b82f6); }

/* Blindar botones outline en el Header del Builder */
.dashboard-header .btn-outline { background: #ffffff !important; border: 1px solid #cbd5e1 !important; color: #475569 !important; border-radius: 6px; cursor: pointer; transition: all 0.2s; font-weight: 600; }
.dashboard-header .btn-outline:hover { background: #f8fafc !important; color: var(--primary-color, #2563eb) !important; border-color: var(--primary-color, #2563eb) !important; }

/* MODO VISTA PREVIA (Estudiante) en el Builder */
body.preview-active .builder-panel { display: none !important; }
body.preview-active .dashboard-header { display: none !important; }
body.preview-active .builder-layout { border: none !important; height: 100vh !important; margin: 0 !important; border-radius: 0 !important; }
body.preview-active .builder-workspace { background: #1e293b !important; }
body.preview-active .canvas-element { outline: none !important; }
body.preview-active .resizer { display: none !important; }
body.preview-active .text-widget-input { border: 1px solid transparent !important; background: transparent !important; }
body.preview-active .text-widget-input:focus { border: 1px solid var(--primary-color, #2563eb) !important; background: white !important; }

/* Espacio de Trabajo Central (Lienzo) */
.builder-workspace {
    flex-grow: 1;
    overflow: hidden; /* Ocultamos overflow para permitir PAN (arrastrar lienzo) */
    position: relative;
    background: #cbd5e1; /* Fondo gris para contrastar la página blanca */
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%; /* Ocupar todo el alto de la columna central */
}

/* El cursor cambia a manito cuando se activa el botón PAN */
.builder-workspace.pan-mode-active {
    cursor: grab !important;
}
.builder-workspace.pan-mode-dragging {
    cursor: grabbing !important;
}

/* El contenedor de la página real */
.canvas-container {
    position: relative; 
    transform-origin: center center;
    transition: transform 0.1s ease-out; /* Movimiento suave al hacer Zoom/Pan */
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    background: white;
    display: inline-block; 
}

/* La imagen de fondo del libro */
.canvas-bg-image {
    display: block;
    height: 100%; /* Ahora la imagen manda. Si es más grande que la pantalla, se usará Pan/Zoom */
    max-height: 85vh; /* Límite inicial para que no desborde brutalmente al cargar */
    width: auto;  
    max-width: none; 
    pointer-events: none; 
    object-fit: contain; 
}

/* El botón de la manito activo toma el color primario */
.btn-zoom.active-tool {
    background: color-mix(in srgb, var(--primary-color) 15%, transparent);
    color: var(--primary-color, #2563eb);
}

/* Asegurar que la paginación de la Vista Previa flote por encima de todo */
.preview-pagination {
    background: #1e293b;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
    z-index: 1000; /* CRÍTICO para que no se oculte */
    margin-bottom: 1rem;
}

/* ==========================================================================
   CONSTRUCTOR DE EXÁMENES (OFFICE)
   ========================================================================== */
.exam-builder-layout {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Columna izquierda (preguntas) más ancha que el formulario */
    gap: 2rem;
    height: calc(100vh - 160px); /* Altura fija para activar los scrolls internos */
    margin: 1.5rem;
    align-items: start;
}

.exam-builder-left-panel {
    background: transparent;
    height: 100%;
    overflow-y: auto; /* Scroll independiente para la lista de preguntas */
    padding-right: 0.5rem; /* Margen para que la barra de scroll no pise el contenido */
}

.exam-builder-right-panel {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    height: 100%;
    overflow-y: auto; /* Scroll independiente para el formulario */
    padding: 1.5rem;
}

/* Panel de Puntaje */
.exam-score-panel {
    display: flex;
    justify-content: space-between;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.exam-score-total {
    color: var(--primary-color, #2563eb);
    font-size: 1.1rem;
}

.exam-score-passing {
    color: #10b981;
    font-size: 1.1rem;
}

.exam-questions-title {
    margin-top: 0;
    color: var(--text-color, #1e293b);
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

/* Tarjeta de Pregunta */
.exam-question-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    margin-bottom: 1rem;
}

.exam-question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.exam-question-badge {
    background: color-mix(in srgb, var(--primary-color) 10%, #eff6ff);
    color: var(--primary-color, #2563eb);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

.exam-question-title {
    font-size: 1.1rem;
    color: var(--text-color, #1e293b);
    margin: 0 0 1rem 0;
    line-height: 1.4;
}

.exam-question-options {
    list-style-type: disc;
    margin: 0 0 1rem 1.5rem;
    padding: 0;
    color: #475569;
}

.exam-question-options li {
    margin-bottom: 0.25rem;
}

.exam-correct-answer-box {
    background: #f0fdf4;
    border: 1px dashed #86efac;
    padding: 1rem;
    border-radius: 6px;
    color: #166534;
    font-size: 0.9rem;
}

/* Elementos del Formulario */
.exam-form-title {
    margin-top: 0;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color, #1e293b);
    font-size: 1.1rem;
}

.exam-form-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.exam-form-group {
    margin-bottom: 1rem;
}

.exam-form-group-no-margin {
    margin-bottom: 0;
}

.exam-form-buttons {
    display: flex;
    gap: 0.5rem;
    flex-direction: column;
    margin-top: 1.5rem;
}

.exam-btn-full {
    width: 100%;
}

/* ==========================================================================
   MÓDULO DE MENSAJERÍA INTERNA (Estilo Chat)
   ========================================================================== */
.chat-wrapper {
    display: flex;
    height: calc(100vh - 120px);
    max-height: 800px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    margin: 1rem;
}

/* Barra Lateral (Contactos) */
.chat-sidebar {
    width: 350px;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    flex-shrink: 0;
}

.chat-sidebar-header {
    padding: 1.2rem;
    border-bottom: 1px solid #e2e8f0;
    background: white;
}

.chat-sidebar-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-color, #1e293b);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: white;
}

.chat-tab-btn {
    flex: 1;
    padding: 0.75rem;
    text-align: center;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-tab-btn.active {
    color: var(--primary-color, #2563eb);
    border-bottom-color: var(--primary-color, #2563eb);
}

.chat-contacts-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chat-contact-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid transparent;
}

.chat-contact-item:hover {
    background: white;
    border-color: #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.chat-contact-item.active {
    background: color-mix(in srgb, var(--primary-color) 10%, #eff6ff);
    border-color: color-mix(in srgb, var(--primary-color) 20%, #bfdbfe);
}

.chat-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary-color, #2563eb);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.chat-contact-info {
    flex-grow: 1;
    overflow: hidden;
}

.chat-contact-name {
    font-weight: 700;
    color: var(--text-color, #1e293b);
    margin: 0 0 0.2rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-contact-role {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.chat-unread-badge {
    background: #ef4444;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
}

/* Área Principal de Chat */
.chat-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.chat-main-empty {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

.chat-main-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #ffffff;
}

.chat-messages-area {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-bubble-wrapper {
    display: flex;
    width: 100%;
}

.chat-bubble-wrapper.sent {
    justify-content: flex-end;
}

.chat-bubble-wrapper.received {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 70%;
    padding: 0.85rem 1.2rem;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.chat-bubble.sent {
    background: var(--primary-color, #2563eb);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-bubble.received {
    background: white;
    color: var(--text-color, #1e293b);
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.chat-time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 0.4rem;
    text-align: right;
    display: block;
}

.chat-input-area {
    padding: 1.2rem 1.5rem;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.chat-input {
    flex-grow: 1;
    padding: 0.85rem 1.2rem;
    border: 1px solid #cbd5e1;
    border-radius: 24px;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
    background: #f8fafc;
}

.chat-input:focus {
    border-color: var(--primary-color, #2563eb);
    background: white;
}

.chat-send-btn {
    background: var(--primary-color, #2563eb);
    color: white;
    border: none;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: filter 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    filter: brightness(0.9);
}

.chat-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}