/* CSS Variables - Dark Theme */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --bg-hover: #475569;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-secondary: #64748b;
    --accent-secondary-hover: #475569;
    
    --success: #22c55e;
    --success-bg: #14532d;
    --error: #ef4444;
    --error-bg: #7f1d1d;
    --warning: #f59e0b;
    
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    
    --transition: all 0.3s ease;
}

/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.screen.active {
    display: block;
    opacity: 1;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 40px 0;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Cards */
.setup-card,
.results-card,
.question-card {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 24px;
}

.setup-card h2,
.results-card h3 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--text-primary);
}

/* Form Elements */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    background-color: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    transition: var(--transition);
    cursor: pointer;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-control:hover {
    background-color: var(--bg-hover);
}

/* Checkbox */
.checkbox-group {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--text-secondary);
    user-select: none;
}

.checkbox-label input {
    display: none;
}

.checkmark {
    width: 22px;
    height: 22px;
    background-color: var(--bg-card);
    border-radius: 6px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    border: 2px solid transparent;
}

.checkbox-label input:checked + .checkmark {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.checkbox-label input:checked + .checkmark::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: bold;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--bg-hover);
}

.btn-text {
    background: transparent;
    color: var(--accent-primary);
    padding: 8px 12px;
}

.btn-text:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.btn-large {
    width: 100%;
    padding: 16px 24px;
    font-size: 1.1rem;
}

/* Progress Restore */
.progress-restore {
    margin-top: 24px;
    padding: 20px;
    background-color: rgba(59, 130, 246, 0.1);
    border-radius: var(--border-radius-sm);
    border-left: 4px solid var(--accent-primary);
    text-align: center;
}

.progress-restore p {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.hidden {
    display: none !important;
}

/* Quiz Header */
.quiz-header {
    margin-bottom: 20px;
}

.progress-bar {
    height: 6px;
    background-color: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), #60a5fa);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.quiz-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Question Navigation */
.question-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 0;
    margin-bottom: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-card) transparent;
}

.question-nav::-webkit-scrollbar {
    height: 6px;
}

.question-nav::-webkit-scrollbar-thumb {
    background-color: var(--bg-card);
    border-radius: 3px;
}

.nav-item {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-card);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    border: 2px solid transparent;
}

.nav-item:hover {
    background-color: var(--bg-hover);
}

.nav-item.current {
    border-color: var(--accent-primary);
    background-color: rgba(59, 130, 246, 0.2);
}

.nav-item.answered {
    background-color: var(--success);
    color: white;
}

.nav-item.answered-wrong {
    background-color: var(--error);
    color: white;
}

/* Question Card */
.question-card {
    flex: 1;
}

.question-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
    line-height: 1.5;
}

/* Options */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.option-btn {
    display: flex;
    align-items: flex-start;
    padding: 16px 20px;
    background-color: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    gap: 12px;
}

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

.option-btn.selected {
    border-color: var(--accent-primary);
    background-color: rgba(59, 130, 246, 0.15);
}

.option-btn.correct {
    border-color: var(--success);
    background-color: var(--success-bg);
}

.option-btn.wrong {
    border-color: var(--error);
    background-color: var(--error-bg);
}

.option-btn:disabled {
    cursor: default;
}

.option-letter {
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-secondary);
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.875rem;
}

.option-btn.selected .option-letter,
.option-btn.correct .option-letter,
.option-btn.wrong .option-letter {
    background-color: transparent;
}

.option-text {
    flex: 1;
    line-height: 1.5;
}

/* Explanation */
.explanation-container {
    margin-top: 24px;
    padding: 20px;
    background-color: var(--bg-primary);
    border-radius: var(--border-radius-sm);
}

.explanation-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--bg-card);
}

.explanation-item:last-child {
    border-bottom: none;
}

.explanation-item.correct {
    color: var(--success);
}

.explanation-item.wrong {
    color: var(--text-secondary);
}

.explanation-item strong {
    display: block;
    margin-bottom: 4px;
}

/* Quiz Footer */
.quiz-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--bg-card);
}

/* Results Screen */
.results-card {
    text-align: center;
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: conic-gradient(var(--accent-primary) var(--score-deg), var(--bg-card) var(--score-deg));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    position: relative;
}

.score-circle::before {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    background-color: var(--bg-secondary);
    border-radius: 50%;
}

#score-percent {
    position: relative;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.score-details {
    margin-bottom: 32px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Mistakes */
.mistakes-container {
    text-align: left;
    margin-bottom: 32px;
}

.mistakes-container h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
}

.mistake-item {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--error);
}

.mistake-question {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.mistake-answer {
    color: var(--success);
    font-size: 0.95rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: auto;
}

/* Responsive */
@media (max-width: 600px) {
    html {
        font-size: 14px;
    }
    
    .container {
        padding: 16px;
    }
    
    .header {
        padding: 24px 0;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .setup-card,
    .results-card,
    .question-card {
        padding: 20px;
    }
    
    .question-text {
        font-size: 1.1rem;
    }
    
    .option-btn {
        padding: 14px 16px;
    }
    
    .quiz-footer {
        flex-direction: column;
    }
    
    .quiz-footer .btn {
        width: 100%;
    }
    
    .nav-item {
        min-width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }
}

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

.question-card {
    animation: fadeIn 0.3s ease;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Focus styles for keyboard navigation */
.btn:focus-visible,
.option-btn:focus-visible,
.form-control:focus-visible,
.nav-item:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #1a1a1a;
        --text-primary: #ffffff;
        --accent-primary: #0066ff;
    }
}
