:root {
    --primary-color: #1a365d;
    --primary-light: #2b6cb0;
    --secondary-color: #edf2f7;
    --text-main: #2d3748;
    --text-muted: #718096;
    --success-color: #38a169;
    --danger-color: #e53e3e;
    --warning-color: #dd6b20;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(200, 200, 200, 0.3);
    --border-color: #e2e8f0;
    --font-family: 'Inter', sans-serif;
    --border-radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background: url('fondo.jpg') center center / cover no-repeat fixed;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    overflow-x: hidden;
}

/* Backgrounds used in some tests */
.background-overlay, .background-animation {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: -1;
    background: rgba(0, 0, 0, 0.2); /* Semi-transparent overlay to ensure contrast */
}

/* Layout Containers */
.container, .app-container, #app, #app-container {
    width: 100%;
    max-width: 900px;
    padding: 20px;
    margin: 0 auto;
}

/* Screens */
.screen { display: none; animation: fadeIn 0.4s ease-out; width: 100%; flex-direction: column; }
.screen.active { display: flex; align-items: center; justify-content: center; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card, .glass-card, .test-container, .question-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

/* Typography */
h1 { color: var(--primary-color); margin-bottom: 15px; font-size: 28px; text-align: center; }
h2 { color: var(--primary-color); margin-bottom: 15px; font-size: 22px; text-align: center; }
h3 { color: var(--primary-color); margin-bottom: 10px; font-size: 18px; }
p { color: var(--text-muted); line-height: 1.6; margin-bottom: 20px; text-align: center; }

/* Forms & Inputs */
form { width: 100%; }
.input-group, .user-input-group { margin-bottom: 20px; width: 100%; display: flex; flex-direction: column; gap: 10px; }
.user-input-group { flex-direction: row; }
.input-group label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 14px; text-align: left; }
input[type="text"] {
    width: 100%; padding: 12px 15px; border: 2px solid #e2e8f0; border-radius: 8px;
    font-size: 16px; font-family: inherit; transition: all 0.3s;
}
input[type="text"]:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.2); }

/* Buttons Unified */
.btn, .btn-primary, .primary-btn, .btn-secondary, .secondary-btn, .danger-btn, .btn-success, button {
    display: inline-flex; justify-content: center; align-items: center;
    padding: 12px 24px; border: none; border-radius: 8px;
    font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.3s;
    text-align: center; font-family: inherit; margin-top: 10px; text-decoration: none; width: 100%;
}
.btn-primary, .primary-btn, button[type="submit"] { background: var(--primary-color); color: white; }
.btn-primary:hover, .primary-btn:hover, button[type="submit"]:hover { background: var(--primary-light); transform: translateY(-2px); }
.btn-secondary, .secondary-btn { background: #e2e8f0; color: var(--text-main); }
.btn-secondary:hover, .secondary-btn:hover { background: #cbd5e1; }
.danger-btn { background: var(--danger-color); color: white; }
.btn-success { background: var(--success-color); color: white; }
button:disabled, .btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.navigation-buttons, .test-footer, .bottom-bar { display: flex; justify-content: space-between; gap: 15px; margin-top: 20px; width: 100%; }

/* Header & Timer */
.test-header, .top-bar {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
    background: white; padding: 15px 20px; border-radius: var(--border-radius);
    box-shadow: 0 4px 6px rgba(0,0,0,0.02); width: 100%; flex-wrap: wrap; gap: 10px;
}
.timer, .timer-container { font-family: monospace; font-size: 20px; font-weight: 700; color: var(--danger-color); }
.warning, .danger { animation: pulse 1s infinite; }

/* Progress Bar */
/* The containers that act as tracks */
.progress-container, .progress-bar-bg, .progress-bar-container, .progress-bar {
    width: 100%; height: 8px; background: #e2e8f0; border-radius: 4px; margin-bottom: 20px; overflow: hidden;
}

/* Except when progress-container contains text (razonamiento numerico) */
.test-header .progress-container {
    height: auto; background: transparent; overflow: visible; margin-bottom: 0; flex: 1;
}

/* The elements that act as fills */
.progress-container > .progress-bar,
.progress-bar-container > .progress-bar,
.progress-bar > .progress,
.progress-bar-bg > .progress-bar-fill {
    height: 100%; background: var(--primary-light); width: 0%; transition: width 0.3s ease; border-radius: 4px;
}

.progress-info {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
    font-size: 14px; font-weight: 600; color: var(--text-muted);
}

/* Options */
.options-list, .options-grid, .options-container, .options {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; width: 100%;
}
.option-item, .option-btn, .option-label, .option {
    padding: 15px 20px; background: white; border: 2px solid #e2e8f0; border-radius: 8px;
    cursor: pointer; transition: all 0.2s; text-align: center; display: flex; align-items: center; justify-content: center; min-height: 80px; font-size: 16px;
}
.option-item:hover, .option-btn:hover, .option-label:hover, .option:hover { border-color: var(--primary-light); background: #ebf4ff; }
.option-item.selected, .option-btn.selected, .option-label.selected, .option.selected {
    border-color: var(--primary-color); background: #ebf4ff; box-shadow: 0 0 0 1px var(--primary-color); font-weight: 600;
}
.option-item input, .option-label input { display: none; }

/* Results */
.score-circle {
    width: 150px; height: 150px; border-radius: 50%;
    background: conic-gradient(var(--success-color) 0%, #e2e8f0 0%);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary-color); margin: 30px auto; position: relative;
}
.score-circle::before {
    content: ""; position: absolute; width: 120px; height: 120px;
    background: var(--glass-bg); border-radius: 50%; z-index: 1;
}
.score-text, #score-percentage, #score-percent { 
    font-size: 28px; font-weight: 700; position: relative; z-index: 2; margin: 0; padding: 0; line-height: 1;
}

.results-actions { display: flex; gap: 15px; justify-content: center; margin-bottom: 30px; flex-wrap: wrap; width: 100%; }

.review-container, .review-list, .results-list-container {
    margin-top: 30px; border-top: 1px solid #e2e8f0; padding-top: 20px; text-align: left; width: 100%;
}
.review-item, .result-item {
    background: white; padding: 15px; border-radius: 8px; margin-bottom: 15px; border-left: 4px solid var(--text-muted);
}
.review-item.correct, .result-item.correct { border-left-color: var(--success-color); }
.review-item.incorrect, .result-item.incorrect { border-left-color: var(--danger-color); }

/* Tests Grid */
.tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.test-card-link {
    display: block; text-decoration: none; background: white; padding: 25px 20px;
    border-radius: 12px; border: 2px solid #e2e8f0; color: var(--text-main); transition: all 0.3s ease; text-align: left;
}
.test-card-link:hover { border-color: var(--primary-light); transform: translateY(-5px); box-shadow: 0 8px 20px rgba(43, 108, 176, 0.15); background: #ebf4ff; }
.test-card-link h3 { color: var(--primary-color); font-size: 18px; margin-bottom: 10px; }
.test-card-link p { font-size: 14px; margin-bottom: 0; color: var(--text-muted); text-align: left; }

/* Specific test overrides - Razonamiento Inductivo */

/* Contenedor de secuencia visual */
.visual-seq {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; flex-wrap: wrap;
    background: #f7fafc; padding: 14px; border-radius: 10px; margin-bottom: 16px;
}
.visual-seq svg    { width: 55px !important; height: 55px !important; flex-shrink: 0; }
.question-mark     { width: 55px; height: 55px; border: 2px dashed #cbd5e1; border-radius: 6px;
                     display: flex; align-items: center; justify-content: center; font-size: 22px; color: #718096; flex-shrink: 0; }

/* Matriz lógica (Raven) */
.matrix-grid {
    display: grid; grid-template-columns: 60px 60px; gap: 8px;
    justify-content: center; margin: 0 auto;
}
.matrix-grid > div { width: 60px; height: 60px; display: flex; align-items: center; justify-content: center; }
.matrix-grid svg   { width: 60px !important; height: 60px !important; }

/* Analogías visuales */
.analogy-row       { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.analogy-row svg   { width: 55px !important; height: 55px !important; flex-shrink: 0; }

/* Botones de opción con figuras */
.option-btn svg    { width: 50px !important; height: 50px !important; }
.option-btn        { min-height: 70px; padding: 10px; }

/* Revisión de respuestas */
.review-opt svg    { width: 40px !important; height: 40px !important; }

.scenario-box { background: #f7fafc; border-left: 4px solid var(--primary-light); padding: 20px; border-radius: 8px; margin-bottom: 25px; text-align: left; }
.slider-container { margin: 30px 0; padding: 20px; background: white; border-radius: 8px; border: 1px solid #e2e8f0; }

/* Chart JS Container (Razonamiento Numerico) */
.chart-container {
    width: 250px;
    height: 250px;
    position: relative;
    margin: 0 auto 30px auto;
}
.score-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}
.summary-details {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 100%;
    margin-bottom: 20px;
}
.stat-box {
    background: rgba(0, 0, 0, 0.05);
    padding: 15px;
    border-radius: var(--border-radius);
    text-align: center;
    flex: 1;
}
.stat-label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; }
.stat-value { font-size: 1.4rem; font-weight: 700; }
.analysis-box { margin-top: 20px; width: 100%; display: flex; justify-content: space-between; gap: 15px; }
.analysis-item { background: rgba(0, 0, 0, 0.05); padding: 12px; border-radius: var(--border-radius); text-align: center; flex: 1; }
.analysis-item .stat-value { font-size: 1.1rem; font-weight: 600; margin-top: 5px; display: block; }
@media (max-width: 600px) {
    body { padding: 10px 0; align-items: flex-start; }

    .container, .app-container, #app, #app-container {
        padding: 10px;
    }

    .card, .glass-card, .test-container, .question-container {
        padding: 16px;
        border-radius: 10px;
        max-width: 100%;
    }

    h1 { font-size: 20px; margin-bottom: 10px; }
    h2 { font-size: 17px; }
    h3 { font-size: 15px; }
    p  { font-size: 14px; margin-bottom: 12px; }

    /* Botones en columna en móvil */
    .navigation-buttons, .results-actions, .test-footer, .bottom-bar {
        flex-direction: column; gap: 8px;
    }
    .navigation-buttons .btn,
    .results-actions .btn,
    .test-footer .btn,
    .bottom-bar .btn,
    .btn, button { width: 100%; margin-top: 6px; padding: 12px; font-size: 15px; }

    /* Header del test */
    .test-header, .top-bar {
        padding: 10px 12px; gap: 6px; flex-wrap: wrap;
    }
    .timer, .timer-container { font-size: 16px; }

    /* Opciones de respuesta: una columna, texto legible */
    .options-list, .options-grid, .options-container, .options {
        grid-template-columns: 1fr; gap: 8px;
    }
    .option-item, .option-btn, .option-label, .option {
        min-height: 50px; padding: 12px 14px; font-size: 14px;
    }

    /* SVG figuras y dominós: reducir tamaño */
    .visual-seq svg      { width: 38px !important; height: 38px !important; }
    .matrix-grid svg     { width: 44px !important; height: 44px !important; }
    .analogy-row svg     { width: 38px !important; height: 38px !important; }
    .question-mark       { width: 38px !important; height: 38px !important; font-size: 16px; }
    .option-btn svg      { width: 34px !important; height: 34px !important; }
    .review-opt svg      { width: 28px !important; height: 28px !important; }

    /* Contenedor visual del test numérico */
    .question-visual {
        font-size: 1rem !important; padding: 10px !important;
        letter-spacing: 0 !important; min-height: 40px !important;
        overflow-x: auto;
    }
    .visual-series { font-size: 1.2rem !important; letter-spacing: 2px !important; }

    /* Dominós: reducir SVG inline */
    .question-visual svg { width: 28px !important; height: 56px !important; }

    /* Chart (Razonamiento Numérico) */
    .chart-container { width: 180px; height: 180px; }
    .score-center    { font-size: 1.4rem; }
    .summary-details { flex-direction: column; gap: 8px; }
    .analysis-box    { flex-direction: column; gap: 8px; }

    /* Círculo de puntaje (otros tests) */
    .score-circle { width: 110px; height: 110px; margin: 20px auto; }
    .score-circle::before { width: 86px; height: 86px; }
    .score-text, #score-percentage, #score-percent { font-size: 20px; }

    /* Grid de tests en la página principal */
    .tests-grid { grid-template-columns: 1fr; gap: 12px; }
    .test-card-link { padding: 18px 14px; }
    .test-card-link h3 { font-size: 15px; }

    /* Inputs */
    input[type="text"] { font-size: 15px; padding: 10px 12px; }
    .user-input-group  { flex-direction: column; }
}
