* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #f0f3f1;
    color: #333;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Test Selection View */
.test-selection-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, #0a8442 0%, #e2ebf0 100%);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 3000;
    overflow-y: auto;
    padding: 40px 20px;
}
.test-selection-overlay.hidden {
    display: none !important;
}

.test-selection-container {
    width: 100%;
    max-width: 1100px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    overflow: hidden;
    margin-bottom: 40px;
}

.test-selection-header {
    background: white;
    padding: 25px 30px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
}

.test-selection-header h2 {
    color: #0A8442;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.test-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 20px;
    background: #eef2f5;
}

.test-card {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    transition: transform 0.2s, box-shadow 0.2s;
    height: 110px;
    background-color: #001a33; 
}

.test-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

.test-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.75;
    transition: opacity 0.2s;
    filter: brightness(0.9);
}

.test-card:hover img {
    opacity: 1;
}

.test-card-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.85);
    padding: 4px 8px;
    font-size: 13px;
    font-weight: bold;
    color: #333;
}

/* Start Overlay (Seleccion de Modo) */
.start-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #0A8442;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.start-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.junta-logo {
    height: 100px;
    margin-bottom: 5px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.logo-container {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.brand-badge {
    background-color: #0A8442;
    color: white;
    padding: 2px 12px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: -10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.start-box h2 {
    color: #0A8442;
    margin-bottom: 15px;
    font-size: 28px;
    font-weight: 900;
    text-transform: uppercase;
}

.start-box p {
    color: #666;
    margin-bottom: 30px;
}

.mode-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.mode-btn {
    flex: 1;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mode-btn:hover {
    border-color: #0A8442;
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(10, 132, 66, 0.2);
}

.mode-icon {
    font-size: 40px;
    color: #0A8442;
    margin-bottom: 15px;
}

.mode-btn h3 {
    margin-bottom: 10px;
    color: #333;
}

.mode-btn p {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.change-test-btn {
    margin-top: 30px;
    background: transparent;
    border: 1px solid #0A8442;
    color: #0A8442;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.change-test-btn:hover {
    background-color: #0A8442;
    color: white;
}

/* Base Layout */
#app-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100vh;
}

/* Header Styles */
.header {
    background-color: #0A8442;
    color: white;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background-color: white;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #0A8442;
    font-size: 20px;
}

.header-titles {
    display: flex;
    flex-direction: column;
}

.test-title {
    font-size: 14px;
    opacity: 0.9;
}

.user-name {
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
}

.timer {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    align-items: flex-end;
}

#time-display {
    font-size: 16px;
    font-weight: bold;
}

.finish-btn {
    background-color: white;
    color: #cc0000;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s;
}
.finish-btn:hover {
    background-color: #f0f0f0;
}

/* Main Layout */
.main-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 150px;
    background-color: #ffffff;
    border-right: 4px solid #0A8442;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.side-btn {
    background-color: #888888;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: opacity 0.2s;
}
.side-btn:hover {
    opacity: 0.9;
}

/* Content Area */
.content {
    flex: 1;
    background-color: #ffffff;
    padding: 40px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#quiz-container {
    flex: 1;
}

.question-header {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    font-size: 20px;
}

.question-number {
    font-weight: bold;
}

.question-text {
    line-height: 1.4;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
    padding-left: 20px;
}

.option-row {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

/* Mode Exam States */
.mode-examen .option-row:not(.disabled):hover .option-letter {
    background-color: #d35400;
}
.mode-examen .option-row.selected .option-letter {
    background-color: #e67e22; /* Naranja = contestada (igual que el panel) */
    color: white;
}
.mode-examen .option-row.selected .option-text {
    font-weight: 600;
    color: #e67e22;
}

/* Mode Ayuda / Review States */
.option-row.disabled {
    cursor: default;
}
.option-row.correct .option-letter {
    background-color: #28a745 !important;
    color: white;
}
.option-row.correct .option-text {
    color: #28a745;
    font-weight: 500;
}
.option-row.wrong .option-letter {
    background-color: #dc3545 !important;
    color: white;
}
.option-row.wrong .option-text {
    color: #dc3545;
}

.option-letter {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #888888;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    flex-shrink: 0;
    transition: background 0.3s;
}

.option-text {
    font-size: 16px;
    line-height: 1.5;
    padding-top: 3px;
}

/* Navigation */
.navigation-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.nav-btn {
    padding: 10px 20px;
    background-color: #0A8442;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav-btn:hover:not(:disabled) {
    opacity: 0.9;
}
.nav-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 14px;
    color: #666;
}

/* Bottom Panel Pagination */
.bottom-panel {
    background-color: #e5e5e5;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s ease;
    z-index: 100;
}

.toggle-panel-btn {
    width: 100%;
    background: #f8f9fa;
    border: none;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    padding: 8px 15px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.toggle-panel-btn:hover {
    background: #e9ecef;
    color: #0A8442;
}

.panel-content {
    padding: 10px;
    overflow-y: auto;
    max-height: 180px; 
    display: flex;
    background: white;
}
.panel-content.collapsed {
    display: none !important;
}

.grid-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: flex-start;
    width: 100%;
}

.grid-item {
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 13px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: transform 0.1s;
}

.grid-item:hover {
    transform: scale(1.1);
}

.grid-item.st-current {
    box-shadow: inset 0 0 0 3px #0A8442, 0 0 5px rgba(0,0,0,0.5);
    z-index: 2;
}

/* Status colors map to screenshots */
.grid-item.st-unanswered { background-color: #777; }
.grid-item.st-answered { background-color: #e67e22; }
.grid-item.st-correct { background-color: #28a745; }
.grid-item.st-wrong { background-color: #cc0000; }

.legend {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 5px 10px;
    background: #f0f3f1;
    font-size: 11px;
    color: #555;
    border-top: 1px solid #ccc;
}

.legend-title {
    font-weight: bold;
}

.box-leg {
    display: inline-flex;
    align-items: center;
    padding: 2px 5px;
    color: white;
    font-weight: bold;
}

.box-leg.leg-answered { background-color: #e67e22; }
.box-leg.leg-unanswered { background-color: #777; }
.box-leg.leg-correct { background-color: #28a745; }
.box-leg.leg-wrong { background-color: #cc0000; }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-box {
    background: white;
    padding: 40px;
    border-radius: 8px;
    text-align: center;
    width: 400px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.modal-box h2 {
    margin-bottom: 20px;
    color: #0A8442;
}

.score-text {
    font-size: 18px;
    margin-bottom: 15px;
}

.status-pass {
    color: #28a745;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 30px;
}

.status-fail {
    color: #cc0000;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 30px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.btn.primary {
    background-color: #0A8442;
    color: white;
}

.btn.secondary {
    background-color: #eee;
    color: #333;
}

/* Score Breakdown (Modal CAP) */
.score-breakdown {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
    text-align: left;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 8px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    gap: 10px;
}

.score-row:last-child {
    border-bottom: none;
}

.score-row-total {
    background: #e8f5e9;
    border-radius: 6px;
    font-weight: bold;
    font-size: 15px !important;
    margin-top: 4px;
    padding: 10px 8px;
    color: #0A8442;
}

.score-row-total.fail {
    background: #ffebee;
    color: #cc0000;
}

.score-row-bonus {
    background: #fff8e1;
    border-radius: 6px;
    font-size: 12px !important;
    color: #888;
    padding: 6px 8px;
    margin-top: 4px;
}

.pass-note {
    font-size: 12px;
    color: #888;
    margin-bottom: 15px;
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {

    /* dvh = dynamic viewport height: se adapta a la barra del navegador móvil */
    body {
        height: 100dvh;
        overflow: hidden;
    }

    #app-content {
        height: 100dvh;
        overflow: hidden;
    }

    /* Header compacto */
    .header {
        flex-wrap: nowrap;
        padding: 6px 10px;
        gap: 6px;
        flex-shrink: 0;
    }

    .header-left {
        gap: 8px;
        min-width: 0;
    }

    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 14px;
        flex-shrink: 0;
    }

    .header-titles {
        min-width: 0;
    }

    .test-title {
        font-size: 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .user-name {
        font-size: 9px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-right {
        gap: 6px;
        flex-shrink: 0;
    }

    .finish-btn {
        padding: 5px 8px;
        font-size: 10px;
        gap: 4px;
    }

    .timer {
        font-size: 9px;
    }

    #time-display {
        font-size: 12px;
    }

    /* Sidebar: ocultar */
    .sidebar {
        display: none;
    }

    /* Layout principal: columna flexible */
    .main-wrapper {
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
        min-height: 0;
    }

    .main-container {
        display: flex;
        flex: 1;
        overflow: hidden;
        min-height: 0;
    }

    /* Zona de contenido: scroll interno (no de página) */
    .content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 15px 12px 20px 12px;
        min-height: 0;
    }

    /* Pregunta */
    .question-header {
        font-size: 15px;
        gap: 8px;
        margin-bottom: 15px;
    }

    .question-text {
        line-height: 1.35;
    }

    /* Opciones */
    .options-container {
        gap: 14px;
        padding-left: 0;
    }

    .option-row {
        gap: 10px;
    }

    .option-letter {
        width: 26px;
        height: 26px;
        font-size: 12px;
        min-width: 26px;
        flex-shrink: 0;
    }

    .option-text {
        font-size: 13px;
        line-height: 1.4;
    }

    /* Navegación Anterior/Siguiente */
    .navigation-buttons {
        margin-top: 20px;
        padding-top: 12px;
        gap: 8px;
    }

    .nav-btn {
        padding: 8px 12px;
        font-size: 12px;
        gap: 5px;
    }

    .pagination-info {
        font-size: 11px;
    }

    /* Panel inferior: al fondo pero NO se superpone */
    .bottom-panel {
        position: relative !important;
        flex-shrink: 0;
        border-top: 3px solid #0A8442;
    }

    .toggle-panel-btn {
        padding: 10px 15px;
        font-size: 14px;
        font-weight: 700;
        background: #f0f3f1;
    }

    .panel-content {
        max-height: 110px;
    }

    .grid-item {
        width: 26px;
        height: 26px;
        font-size: 10px;
    }

    /* Ocultar leyenda para ganar espacio */
    .legend {
        display: none !important;
    }

    /* Modal */
    .modal-box {
        width: 90%;
        padding: 25px 18px;
    }

    .score-text {
        font-size: 15px;
    }

    .status-pass, .status-fail {
        font-size: 18px;
    }

    .modal-actions {
        flex-direction: column;
        gap: 8px;
    }

    .modal-actions .btn {
        width: 100%;
    }

    /* Selección de test */
    .test-selection-overlay {
        padding: 10px;
    }

    .test-selection-container {
        margin-top: 5px;
    }

    .test-selection-header h2 {
        font-size: 18px;
    }

    .test-selection-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 10px;
    }

    .test-card {
        height: 80px;
    }

    .test-card-label {
        font-size: 11px;
        padding: 3px 6px;
    }

    /* Pantalla de selección de modo */
    .start-box {
        padding: 20px 15px;
        width: 95%;
    }

    .start-box h2 {
        font-size: 18px;
    }

    .start-box p {
        font-size: 13px;
        margin-bottom: 16px;
    }

    .junta-logo {
        height: 50px;
    }

    .mode-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .mode-icon {
        font-size: 28px;
        margin-bottom: 6px;
    }

    .mode-btn {
        padding: 14px;
    }

    .mode-btn h3 {
        font-size: 14px;
    }

    .mode-btn p {
        font-size: 12px;
    }
}
