@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap');

:root {
    --primary-color: #007bff;
    --background-color: #f4f7f6;
    --dark-color: #333;
    --light-color: #fff;
    --danger-color: #dc3545;
    --shadow: 0 4px 15px rgba(0,0,0,0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: var(--dark-color);
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
}

.login-box {
    background: var(--light-color);
    padding: 40px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-box h2 {
    margin-bottom: 10px;
    color: var(--dark-color);
}

.login-box p {
    margin-bottom: 30px;
    color: #777;
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.9em;
}

.input-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    font-family: 'Poppins', sans-serif;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-login {
    width: 100%;
    padding: 15px;
    border: none;
    background-color: var(--primary-color);
    color: var(--light-color);
    font-size: 1.1em;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-login:hover {
    background-color: #0056b3;
}

.error-message {
    color: var(--danger-color);
    margin-top: 15px;
    font-weight: 600;
    font-size: 0.9em;
    height: 20px; /* Para que no se mueva el layout */
}



/* --- Estilos del Dashboard --- */
.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
}

.dashboard-header {
    background-color: var(--light-color);
    padding: 20px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 40px;
}

.dashboard-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header h1 {
    font-size: 1.5em;
    color: var(--primary-color);
}

.user-info {
    font-weight: 600;
}

main h2 {
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.exam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.exam-card {
    background-color: var(--light-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 25px;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.exam-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.exam-card h3 {
    font-size: 1.2em;
    margin-bottom: 10px;
    color: var(--dark-color);
}

.exam-card p {
    color: #666;
    flex-grow: 1; /* Empuja el botón hacia abajo */
    margin-bottom: 20px;
}

.btn-start-exam {
    display: inline-block;
    padding: 12px 20px;
    background-color: #28a745;
    color: var(--light-color);
    text-align: center;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 600;
    transition: background-color 0.3s ease;
    align-self: flex-start; /* Se alinea a la izquierda */
}

.btn-start-exam:hover {
    background-color: #218838;
}


/* --- Estilos del Examen --- */
.loader-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
}
.loader {
    border: 8px solid #f3f3f3;
    border-radius: 50%;
    border-top: 8px solid var(--primary-color);
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.instructions-box {
    background-color: var(--light-color);
    padding: 40px;
    margin-top: 50px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.instructions-box h1 { color: var(--primary-color); }
.instructions-box ul {
    list-style-position: inside;
    margin: 20px 0;
}

.exam-container {
    width: 90%;
    max-width: 900px;
    margin: 30px auto;
    background-color: var(--light-color);
    padding: 30px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
}

.progress-indicator {
    background-color: #e9ecef;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9em;
}

.question-content img {
    width: 100%;
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.answers-content {
    margin-top: 25px;
}

.answer-option {
    display: block;
    background-color: #f8f9fa;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.answer-option:hover {
    border-color: var(--primary-color);
    background-color: #e2e6ea;
}
.answer-option input[type="radio"] {
    margin-right: 15px;
}
.answer-option.selected {
    border-color: var(--primary-color);
    background-color: #d1e7fd;
    font-weight: 600;
}

.navigation-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.btn-nav, .btn-submit {
    padding: 12px 30px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}
.btn-nav {
    background-color: #6c757d;
    color: white;
}
.btn-nav:hover {
    background-color: #5a6268;
}
.btn-submit {
    background-color: #28a745;
    color: white;
}
.btn-submit:hover {
    background-color: #218838;
}

/* --- Estilos del Encabezado Informativo del Examen --- */
.exam-info-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    padding: 15px 20px;
    border-radius: 8px 8px 0 0; /* Bordes redondeados solo arriba */
    border: 1px solid #dee2e6;
    margin-bottom: -1px; /* Para que se junte con el header de abajo */
}

.info-item {
    font-size: 0.9em;
    color: #495057;
    margin: 5px 10px;
}

.info-item strong {
    color: #343a40;
}

.timer {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--primary-color);
}
/* Clase para cuando el tiempo se está acabando */
.timer-warning {
    color: var(--danger-color) !important;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.exam-header {
    border-top: none; /* Quitamos el borde superior que ya no es necesario */
}

.exam-cancelled-overlay {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    z-index: 2000;
    text-align: center;
    padding: 20px;
}
.exam-cancelled-overlay h1 {
    color: #dc3545;
    font-size: 2.5em;
}
.exam-cancelled-overlay p {
    font-size: 1.2em;
    color: #333;
}
.save-indicator {
    font-size: 0.9em;
    color: #28a745;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}
.save-indicator.visible {
    opacity: 1;
}

/* --- Estilos para la Página de Resultados --- */
.result-container {
    max-width: 800px;
    margin: 40px auto;
    padding: 20px;
}
.result-header {
    text-align: center;
    margin-bottom: 30px;
}
.result-header h1 {
    font-size: 2.5em;
    color: #333;
}
.result-header .check-icon {
    width: 60px;
    height: 60px;
    stroke: var(--success-color);
    stroke-width: 1.5;
    margin-bottom: 10px;
}

.card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid #dee2e6;
    margin-bottom: 30px;
    padding: 30px;
}

.score-card {
    text-align: center;
}
.final-score {
    font-size: 5em;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}
.score-details {
    font-size: 1.2em;
    color: #6c757d;
}

/* Estilos de la Constancia */
.constancia-header {
    text-align: center;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 15px;
    margin-bottom: 25px;
}
.constancia-body {
    text-align: center;
    line-height: 1.8;
}
.constancia-body .student-name {
    font-size: 1.5em;
    color: #333;
    margin: 10px 0;
}
.constancia-body .materia-name {
    font-size: 1.3em;
    color: var(--primary-color);
    margin: 10px 0;
}
.constancia-firma {
    margin-top: 50px;
}

.result-actions {
    text-align: center;
}
.result-actions .btn {
    margin: 0 10px;
    padding: 12px 30px;
}

/* Estilos para Impresión */
@media print {
    body * {
        visibility: hidden;
    }
    #constancia-container, #constancia-container * {
        visibility: visible;
    }
    #constancia-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        border: none;
        box-shadow: none;
    }
}


/* --- ESTILOS MEJORADOS PARA BOTONES --- */

/* Estilo base que comparten todos los botones */
.btn {
    display: inline-block;
    padding: 12px 20px;
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 600;
    transition: background-color 0.3s ease;
    align-self: flex-start;
}

/* Botón para Iniciar Examen (Verde) */
.btn-start-exam {
    background-color: #28a745; 
}
.btn-start-exam:hover {
    background-color: #218838;
}

/* Botón para Ver Resultados (Azul) */
.btn-view-results {
    background-color: #007bff;
}
.btn-view-results:hover {
    background-color: #0056b3;
}

/* --- Estilos para el Encabezado del Dashboard del Estudiante --- */

.dashboard-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 20px; /* Espacio entre el nombre y el botón */
}

.user-info {
    font-weight: 600;
}

.btn-logout {
    background-color: #dc3545; /* Color rojo */
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.btn-logout:hover {
    background-color: #c82333; /* Rojo más oscuro al pasar el mouse */
}