/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes progressFill {
    from { width: 0; }
    to { width: var(--progress-width, 0%); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Base styles */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --success-color: #059669;
    --error-color: #dc2626;
    --bg-color: #f4f4f5;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-color);
    background-image: linear-gradient(135deg, var(--bg-color) 0%, #e5e7eb 100%);
    padding: 20px;
    transition: background-color 0.3s ease;
}

.container {
    background-color: white;
    border-radius: 16px;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 32px;
    width: 100%;
    max-width: 600px;
    position: relative;
    overflow: hidden;
}

/* Progress bar */
.progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: #e5e7eb;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
    animation: progressFill 0.3s ease-out;
}

/* Utility classes */
.hidden {
    display: none !important;
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out;
}

.animate-scale-in {
    animation: scaleIn 0.5s ease-out;
}

.animate-slide-up {
    animation: slideIn 0.5s ease-out;
}

/* Quiz content styles */
#quiz-title {
    color: var(--text-primary);
    font-size: 32px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 16px;
}

.quiz-description {
    color: var(--text-secondary);
    text-align: center;
    font-size: 16px;
    margin-bottom: 32px;
}

.btn {
    width: 100%;
    padding: 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.btn:disabled {
    background-color: #e5e7eb;
    cursor: not-allowed;
    color: var(--text-secondary);
}

.btn-secondary {
    background-color: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    margin-top: 12px;
}

.btn-secondary:hover {
    background-color: #f9fafb;
}

/* Question styles */
.question-header {
    margin-bottom: 24px;
}

#current-question {
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 600;
}

.question-text {
    color: var(--text-primary);
    font-size: 18px;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* Options styles */
.option {
    padding: 16px;
    margin-bottom: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
    background-color: white;
}

.option:hover:not(.disabled) {
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.option.selected {
    background-color: #dbeafe;
    border-color: var(--primary-color);
}

.option.correct {
    background-color: #ecfdf5;
    border-color: var(--success-color);
}

.option.incorrect {
    background-color: #fef2f2;
    border-color: var(--error-color);
}

.option.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

/* Results styles */
.score-display {
    text-align: center;
    margin-bottom: 32px;
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background-color: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    border: 4px solid var(--primary-color);
}

.score-percentage {
    font-size: 48px;
    font-weight: bold;
    color: var(--primary-color);
}

.score-fraction {
    color: var(--text-secondary);
    font-size: 16px;
}

.wrong-answer {
    background-color: #fef2f2;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 16px;
    border-left: 4px solid var(--error-color);
}

.wrong-answer .question {
    font-weight: 600;
    margin-bottom: 12px;
}

.wrong-answer .user-answer {
    color: var(--error-color);
    margin-bottom: 8px;
}

.wrong-answer .correct-answer {
    color: var(--success-color);
    margin-bottom: 8px;
}

.wrong-answer .explanation {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    background-color: white;
    padding: 12px;
    border-radius: 4px;
    margin-top: 12px;
}

/* Loading spinner */
.btn-loader {
    width: 20px;
    height: 20px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

/* Responsive design */
@media (min-width: 1024px) {
    .container {
        padding: 40px;
        max-width: 700px;
    }

    #quiz-title {
        font-size: 36px;
    }

    .question-text {
        font-size: 20px;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 24px;
    }

    #quiz-title {
        font-size: 24px;
    }

    .option {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 20px;
    }

    .score-circle {
        width: 120px;
        height: 120px;
    }

    .score-percentage {
        font-size: 36px;
    }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1f2937;
        background-image: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    }

    .container {
        background-color: #374151;
    }

    #quiz-title, .question-text {
        color: #f9fafb;
    }

    .option {
        background-color: #4b5563;
        border-color: #6b7280;
        color: #f9fafb;
    }

    .quiz-description {
        color: #e5e7eb;
    }
}