:root {
    --primary: #2c3e50;
    --secondary: #3498db;
    --success: #27ae60;
    --error: #e74c3c;
    --bg: #f4f7f6;
    --max-width: 720px; /* Ancho unificado para alinear todos los componentes */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: #333;
    padding: 10px 10px 130px 10px; /* Espacio extra abajo para que la barra no tape nada */
    display: flex;
    justify-content: center;
}

/* Contenedor central que alinea verticalmente el Header y el Cuestionario */
.app-container {
    width: 100%;
    max-width: var(--max-width);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    width: 100%;
    text-align: center;
    margin-bottom: 15px;
}

.header h1 {
    font-size: 1.5rem;
    color: var(--primary);
}

.header h2 {
    font-size: 1.1rem;
    color: #7f8c8d;
    margin-bottom: 10px;
}

/* Alineación exacta del menú de selección */
.menu-filter {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    text-align: left;
    gap: 5px;
    width: 100%;
}

.filter-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #555;
}

select {
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #ccd1d1;
    font-size: 1rem;
    width: 100%;
    background-color: #fff;
}

/* Botonera general */
button {
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: background 0.2s, opacity 0.2s;
}

.btn-secondary {
    background-color: #eef2f5;
    color: var(--primary);
    border: 1px solid #d5dbdb;
    width: 100%;
}

.btn-secondary:hover { background-color: #d5dbdb; }

.btn-cancel {
    background-color: #7f8c8d;
    color: white;
    margin-top: 10px;
    width: auto;
    font-size: 0.9rem;
    padding: 8px 15px;
}

.stats {
    margin-top: 15px;
    font-weight: bold;
    color: var(--primary);
    font-size: 0.95rem;
}

/* Contenedor del Test */
#quiz-container {
    width: 100%;
}

.question-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-top: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    width: 100%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.tema-tag {
    display: inline-block;
    background: #ebf5fb;
    color: #2980b9;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-bottom: 12px;
    font-weight: bold;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--primary);
    line-height: 1.4;
}

/* Lista de Opciones */
.options-list {
    list-style: none;
}

.option {
    padding: 14px;
    border: 2px solid #eaeded;
    margin-bottom: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1.3;
    transition: all 0.15s;
}

.option:hover:not(.answered) {
    background-color: #f4f9fd;
    border-color: var(--secondary);
}

.option.correct {
    background-color: #e8f8f5 !important;
    border-color: var(--success) !important;
    color: #117a65;
    font-weight: bold;
}

.option.wrong {
    background-color: #fdeadc !important;
    border-color: var(--error) !important;
    color: #922b21;
}

.explanation {
    margin-top: 15px;
    padding: 15px;
    background-color: #ebf5fb;
    border-left: 4px solid var(--secondary);
    border-radius: 0 6px 6px 0;
    font-size: 0.9rem;
    line-height: 1.4;
    display: none;
}

/* Botones de navegación inferior */
.navigation-buttons {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    width: 100%;
}

.navigation-buttons button {
    flex: 1;
    background-color: var(--primary);
    color: white;
}

.navigation-buttons button:disabled {
    background-color: #d5dbdb;
    color: #95a5a6;
    cursor: not-allowed;
}

/* Barra de progreso fija inferior */
#progress-bar-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    box-shadow: 0 -3px 10px rgba(0,0,0,0.08);
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 1000;
}

.progress-stats {
    display: flex;
    width: 100%;
    max-width: var(--max-width);
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 0.9rem;
}

.stat-badge {
    padding: 3px 10px;
    border-radius: 12px;
    color: white;
    min-width: 45px;
    text-align: center;
}
.success-badge { background-color: var(--success); }
.error-badge { background-color: var(--error); }

.progress-track {
    width: 100%;
    max-width: var(--max-width);
    height: 8px;
    background: #eaeded;
    border-radius: 4px;
    overflow: hidden;
}

#progress-fill {
    width: 0%;
    height: 100%;
    background: var(--success);
    transition: width 0.2s ease;
}

/* Pantalla de Resultados */
.results-card {
    background: white;
    padding: 30px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    text-align: center;
    width: 100%;
    margin-top: 15px;
}

.results-score {
    font-size: 1.8rem;
    margin: 15px 0;
    font-weight: bold;
}

/* RESPONSIVE DESIGN (Media Queries para tablets y pantallas de escritorio) */
@media (min-width: 576px) {
    .header { padding: 25px; }
    .header h1 { font-size: 1.8rem; }
    .menu-filter { flex-direction: row; align-items: flex-end; }
    .filter-group { flex: 2; }
    .btn-secondary { flex: 1; height: 46px; }
    body { padding-top: 30px; }
}
/* ==========================================================================
   ESTILOS COMPLEMENTARIOS PARA LA INTERACTIVIDAD Y SELECCIÓN DE OPCIONES
   ========================================================================== */

/* Contenedor de la lista de opciones (A, B, C, D) */
.options-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 12px; /* Separación limpia entre opciones */
}

/* Cada opción individual: se transforma de texto plano a un botón interactivo */
.options-list li {
    background-color: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 14px 18px;
    font-size: 1rem;
    color: #495057;
    cursor: pointer; /* Fuerza el puntero de selección de mano */
    user-select: none; /* Evita que el usuario seleccione el texto por error al hacer clic rápido */
    transition: all 0.2s ease;
}

/* Efecto Hover: se activa solo si la pregunta no ha sido respondida aún */
.options-list li:hover {
    background-color: #e9ecef;
    border-color: #ced4da;
    color: #212529;
    transform: translateX(4px); /* Sutil desplazamiento dinámico de enfoque */
}

/* Clase de acierto: cambia instantáneamente a color verde al validar la respuesta */
.options-list li.correct {
    background-color: #d4edda !important;
    border-color: #2be072 !important;
    color: #155724 !important;
    font-weight: 600;
}

/* Clase de error: cambia instantáneamente a color rojo si falla la opción */
.options-list li.wrong {
    background-color: #f8d7da !important;
    border-color: #ff4d4d !important;
    color: #721c24 !important;
    font-weight: 600;
}

/* Cuadro inferior explicativo oficial */
.explanation {
    margin-top: 20px;
    padding: 15px;
    background-color: #fff3cd;
    border-left: 5px solid #ffcc00;
    border-radius: 4px;
    color: #856404;
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

/* Utilidad global de ocultación de flujos */
.oculto {
    display: none !important;
}

/* ==========================================================================
   MAQUETADO DE LA REVISIÓN FINAL DE ERRORES Y PANEL DE NOTAS
   ========================================================================== */

/* Caja contenedora de la puntuación final sobre base 10 */
.stats-final-box {
    background: linear-gradient(135deg, #343a40, #212529);
    color: #ffffff;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.nota-global {
    font-size: 1.4rem;
    margin-bottom: 15px;
}

.nota-global strong {
    font-size: 2.8rem;
    color: #ffcc00; /* Resalta la nota final */
    display: block;
    margin-top: 5px;
}

/* Contenedor de la revisión aislada de fallos */
#seccion-revision-fallos {
    margin-top: 30px;
    text-align: left;
}

#seccion-revision-fallos h4 {
    border-bottom: 2px solid #ff4d4d;
    padding-bottom: 8px;
    color: #212529;
    margin-bottom: 20px;
}

/* Tarjeta de cada pregunta errada para repasar explicaciones */
.fallo-card-item {
    background-color: #ffffff;
    border: 1px solid #f5c6cb;
    border-left: 6px solid #ff4d4d; /* Anchor visual rojo distintivo */
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.fallo-pregunta-titulo {
    font-size: 1.05rem;
    color: #212529;
    margin-bottom: 12px;
}

/* Clases de texto para la revisión final */
.txt-red { color: #dc3545; font-weight: bold; }
.txt-green { color: #28a745; font-weight: bold; }

/* Subcuadro de la justificación técnica de la oposición */
.fallo-justificacion-box {
    margin-top: 12px;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px dashed #ced4da;
    font-size: 0.9rem;
    color: #6c757d;
}

/* Alerta de examen perfecto de 10 sin errores */
.alert-success-test {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
}

/* Badge de contador inferior para preguntas en blanco */
.stat-badge.blank-badge {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* Pestañas de alternancia de modo de estudio */
.btn-mode {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
    font-weight: bold;
    background-color: #e9ecef;
    border: 2px solid #dee2e6;
    color: #495057;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-mode:hover {
    background-color: #dee2e6;
    color: #212529;
}

.btn-mode.active {
    background-color: #007bff;
    border-color: #0056b3;
    color: #ffffff;
    box-shadow: 0 4px 6px rgba(0, 123, 255, 0.2);
}

/* Contenedor de botones en versión escritorio */
.navigation-buttons {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}

/* Reglas unificadas para pantallas móviles */
@media (max-width: 480px) {
    /* Forzamos el comportamiento de cuadrícula usando una clase limpia */
    .navigation-buttons, 
    .navigation-buttons.mobile-grid {
        display: grid !important; 
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 8px !important;
        width: 100% !important;
    }

    .navigation-buttons button {
        padding: 10px 4px !important;
        font-size: 0.85rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
        white-space: nowrap !important; 
        text-align: center !important;
    }

    /* Sobrescribe por completo el botón de reporte */
    #btn-reportar {
        padding: 10px 4px !important;
        font-size: 0.85rem !important;
        width: 100% !important;
        margin: 0 !important;
    }
}
