/* =========================================
   VARIABLES GLOBALES
   ========================================= */
:root {
    /* Colores principales */
    --primary: #1e293b;
    --primary-light: #334155;
    --accent: #3b82f6;
    --accent-hover: #2563eb;

    /* Estados */
    --correct: #16a34a;
    --correct-bg: #dcfce7;
    --wrong: #dc2626;
    --wrong-bg: #fee2e2;
    --tool: #fbbf24;
    --tool-hover-bg: rgba(251, 191, 36, 0.1);

    /* Fondos y superficies */
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;

    /* Texto */
    --text: #1e293b;
    --text-light: #64748b;
    --sidebar-text: rgba(255, 255, 255, 0.7);
    --sidebar-text-active: #ffffff;

    /* Dimensiones y efectos */
    --sidebar-w: 270px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   RESET Y BASE
   ========================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* =========================================
   SIDEBAR
   ========================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--primary);
    color: var(--sidebar-text-active);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform var(--transition);
}

.sidebar__header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__logo {
    font-size: 1.5em;
    font-weight: 800;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar__nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

/* Scrollbar sutil para el nav */
.sidebar__nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar__nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 1em;
    font-weight: 500;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.sidebar__link:hover {
    color: var(--sidebar-text-active);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar__link.active {
    color: var(--sidebar-text-active);
    background: rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent);
}

/* Separador entre secciones del menú */
.sidebar__divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 12px 20px;
}

/* Enlace a herramienta (generador) */
.sidebar__link--tool {
    color: var(--tool) !important;
}

.sidebar__link--tool:hover {
    background: var(--tool-hover-bg) !important;
    border-left-color: var(--tool) !important;
}

.sidebar__footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.5;
}

/* =========================================
   OVERLAY MÓVIL
   ========================================= */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity var(--transition);
    backdrop-filter: blur(2px);
}

.overlay.visible {
    display: block;
    opacity: 1;
}

/* =========================================
   BOTÓN HAMBURGUESA
   ========================================= */
.menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    background: var(--primary);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    font-size: 1.4em;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: background var(--transition);
    align-items: center;
    justify-content: center;
}

.menu-toggle:hover {
    background: var(--primary-light);
}

/* =========================================
   CONTENIDO CENTRAL
   ========================================= */
.main {
    margin-left: var(--sidebar-w);
    padding: 40px;
    max-width: 900px;
    transition: margin var(--transition);
}

/* =========================================
   ESTADO BIENVENIDA
   ========================================= */
.welcome {
    text-align: center;
    padding: 80px 20px;
    animation: fadeIn 0.5s ease;
}

.welcome h1 {
    font-size: 2.2em;
    color: var(--primary);
    margin-bottom: 12px;
}

.welcome p {
    font-size: 1.2em;
    color: var(--text-light);
    max-width: 500px;
    margin: 0 auto;
}

.welcome code {
    background: var(--border);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* =========================================
   ESTILOS DEL TEST
   ========================================= */
.test-header {
    margin-bottom: 30px;
    animation: slideUp 0.4s ease;
}

.test-header h1 {
    font-size: 1.8em;
    color: var(--primary);
    border-bottom: 3px solid var(--accent);
    padding-bottom: 12px;
}

.card {
    background: var(--card);
    padding: 24px;
    margin-bottom: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: slideUp 0.4s ease backwards;
}

/* Escalonar animación de las tarjetas */
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; }
.card:nth-child(5) { animation-delay: 0.2s; }
.card:nth-child(6) { animation-delay: 0.25s; }
.card:nth-child(7) { animation-delay: 0.3s; }
.card:nth-child(8) { animation-delay: 0.35s; }
.card:nth-child(9) { animation-delay: 0.4s; }
.card:nth-child(10) { animation-delay: 0.45s; }

.q-text {
    font-weight: 700;
    font-size: 1.1em;
    margin-bottom: 12px;
}

.q-img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 12px auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fafafa;
}

/* Opciones de respuesta */
.option-label {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin: 6px 0;
    cursor: pointer;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    transition: all 0.2s ease;
    font-weight: 500;
    user-select: none;
}

.option-label:hover {
    border-color: var(--accent);
    background: #eff6ff;
}

.option-label input[type="radio"] {
    margin-right: 12px;
    accent-color: var(--accent);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Estados de respuesta */
.option-label.correct {
    border-color: var(--correct) !important;
    background: var(--correct-bg) !important;
    color: var(--correct);
}

.option-label.wrong {
    border-color: var(--wrong) !important;
    background: var(--wrong-bg) !important;
    color: var(--wrong);
    opacity: 0.85;
}

/* Deshabilitar interacción tras evaluar */
.option-label input[type="radio"]:disabled {
    cursor: default;
}

.option-label input[type="radio"]:disabled + * {
    pointer-events: none;
}

/* Botones */
.btn {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 1.15em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 24px;
    text-align: center;
}

.btn--primary {
    background: var(--accent);
    color: #fff;
}

.btn--primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn--secondary {
    background: var(--text-light);
    color: #fff;
    margin-top: 12px;
}

.btn--secondary:hover {
    background: var(--primary);
}

/* Panel de resultados */
.result {
    display: none;
    text-align: center;
    padding: 40px;
    background: var(--card);
    border-radius: var(--radius);
    margin-top: 24px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.4s ease;
}

.score {
    font-size: 3em;
    font-weight: 800;
    margin: 8px 0;
}

.feedback {
    font-size: 1.3em;
    color: var(--text-light);
}

/* =========================================
   LOADING
   ========================================= */
.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-light);
    font-size: 1.1em;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin-left: 10px;
    vertical-align: middle;
    animation: spin 0.8s linear infinite;
}

/* =========================================
   ANIMACIONES
   ========================================= */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
        padding: 20px;
        padding-top: 70px;
    }

    .menu-toggle {
        display: flex;
    }

    .welcome {
        padding: 40px 10px;
    }

    .welcome h1 {
        font-size: 1.6em;
    }

    .welcome p {
        font-size: 1em;
    }

    .test-header h1 {
        font-size: 1.4em;
    }

    .card {
        padding: 18px;
    }

    .score {
        font-size: 2.2em;
    }

    .result {
        padding: 25px;
    }
}

/* Pantallas muy pequeñas */
@media (max-width: 380px) {
    .sidebar__logo {
        font-size: 1.2em;
    }

    .sidebar__link {
        padding: 12px 16px;
        font-size: 0.95em;
    }

    .option-label {
        padding: 10px 12px;
        font-size: 0.95em;
    }
}