:root {
    --bg-primary: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #0f172a;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-sidebar: #e2e8f0;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    --border-color: #e2e8f0;
    --success-color: #16a34a;
    --success-bg: #f0fdf4;
    --error-color: #dc2626;
    --error-bg: #fef2f2;
    --warning-color: #d97706;
    --warning-bg: #fffbeb;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.2s ease-in-out;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-surface: #1e293b;
    --bg-sidebar: #020617;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --text-sidebar: #cbd5e1;
    --accent-color: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-light: #1e3a8a;
    --border-color: #334155;
    --success-color: #22c55e;
    --success-bg: #052e16;
    --error-color: #ef4444;
    --error-bg: #450a0a;
    --warning-color: #f59e0b;
    --warning-bg: #451a03;
}

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.container {
    padding: 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

/* Sidebar Elements */
.brand {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-icon {
    font-size: 1.8rem;
}

.brand-text h2 {
    font-size: 1.1rem;
    color: #fff;
}

.brand-text span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.nav-menu {
    padding: 1rem 0;
    flex: 1;
    overflow-y: auto;
}

.nav-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-sidebar);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}

.nav-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.nav-btn.active {
    background-color: var(--accent-color);
    color: #fff;
    font-weight: 600;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

/* Top Header Bar */
.top-bar {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.4rem;
    border-radius: var(--radius);
}

.btn-icon:hover {
    background-color: var(--accent-light);
}

#mobile-menu-toggle {
    display: none;
}

/* Section Switching */
.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

/* UI Cards */
.card {
    background-color: var(--bg-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.hero-card {
    background: linear-gradient(135deg, #2563eb, #1e3a8a);
    color: #fff;
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
}

.hero-card p {
    margin: 0.5rem 0 1.5rem 0;
    opacity: 0.9;
}

.hero-actions {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.btn-secondary { background-color: var(--text-secondary); color: #fff; }
.btn-secondary:hover { opacity: 0.9; }

.btn-outline { background-color: transparent; border-color: var(--border-color); color: var(--text-primary); }
.btn-outline:hover { background-color: var(--border-color); }

.btn-danger { background-color: var(--error-color); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.btn-large { padding: 0.8rem 1.6rem; font-size: 1rem; }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.width-full { width: 100%; }

/* Stats Display */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.icon-blue { background-color: #dbeafe; color: #1e40af; }
.icon-purple { background-color: #f3e8ff; color: #6b21a8; }
.icon-green { background-color: #dcfce7; color: #15803d; }
.icon-red { background-color: #fee2e2; color: #b91c1c; }
.icon-yellow { background-color: #fef3c7; color: #b45309; }
.icon-orange { background-color: #ffedd5; color: #c2410c; }

.stat-data { display: flex; flex-direction: column; }
.stat-value { font-size: 1.3rem; font-weight: bold; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

/* Accordion and Form Controls */
.bloques-accordion { margin-top: 1rem; }

.bloque-group {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.bloque-header {
    background-color: var(--bg-surface);
    padding: 0.8rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-weight: 600;
}

.temas-container {
    padding: 0.8rem 1rem;
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

.questions-preset-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.questions-preset-buttons .btn.active {
    background-color: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

/* Test Execution Views */
.test-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--accent-color);
    transition: width 0.3s ease;
}

.scenario-card {
    background-color: var(--accent-light);
    border-left: 4px solid var(--accent-color);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.question-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.question-tags {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-bloque { background-color: #e0e7ff; color: #3730a3; }
.badge-tema { background-color: #f1f5f9; color: #475569; }
.badge-warning { background-color: var(--warning-bg); color: var(--warning-color); }
.badge-success { background-color: var(--success-bg); color: var(--success-color); }

.question-title {
    font-size: 1.15rem;
    margin-bottom: 1.5rem;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option-btn {
    text-align: left;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    gap: 0.75rem;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--accent-color);
    background-color: var(--accent-light);
}

.option-btn.selected { border-color: var(--accent-color); background-color: var(--accent-light); }
.option-btn.correct { border-color: var(--success-color); background-color: var(--success-bg); color: var(--success-color); font-weight: 600; }
.option-btn.incorrect { border-color: var(--error-color); background-color: var(--error-bg); color: var(--error-color); }

.explanation-box {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: var(--radius);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.explanation-status { font-weight: bold; margin-bottom: 0.5rem; }

.options-detail-list {
    margin-top: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.88rem;
}

.question-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
}

/* Timer Display */
.timer-display {
    font-weight: bold;
    font-family: monospace;
    font-size: 1.1rem;
    background: var(--bg-surface);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

/* Results Section */
.score-summary-card {
    text-align: center;
    padding: 2rem;
    background-color: var(--accent-light);
    border-radius: var(--radius);
    margin: 1.5rem 0;
}

.score-value {
    font-size: 3rem;
    font-weight: bold;
    color: var(--accent-color);
}

.score-breakdown {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.dot-green { background-color: var(--success-color); }
.dot-red { background-color: var(--error-color); }
.dot-gray { background-color: var(--text-muted); }

.results-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.result-block-card {
    background-color: var(--bg-primary);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.res-stat-row {
    display: flex;
    justify-content: space-between;
    margin-top: 0.4rem;
}

/* Data Tables */
.table-responsive { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table th { background-color: var(--bg-primary); }

/* Modals & Loading */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner-card {
    background: var(--bg-surface);
    padding: 2rem;
    border-radius: var(--radius);
    text-align: center;
    max-width: 400px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem auto;
}

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

/* Helper Utility Classes */
.hidden { display: none !important; }
.margin-top-small { margin-top: 0.5rem; }
.margin-top-medium { margin-top: 1rem; }
.margin-top-large { margin-top: 1.5rem; }
.text-green { color: var(--success-color); }
.text-red { color: var(--error-color); }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: bold; }
.divider { border: 0; border-top: 1px solid var(--border-color); margin: 1.5rem 0; }
.input-group { display: flex; gap: 0.5rem; }

/* Responsive Adjustments */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    #mobile-menu-toggle { display: block; }
    .results-grid-2 { grid-template-columns: 1fr; }
}
