/* CSS Variables for Theme */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --accent-primary: #4361ee;
    --accent-secondary: #3f37c9;
    --accent-light: #4895ef;
    --success: #2ecc71;
    --error: #e74c3c;
    --warning: #f39c12;
    --border: #dee2e6;
    --shadow: rgba(0, 0, 0, 0.1);
    --card-bg: #ffffff;
    --header-bg: #ffffff;
}

[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0a0;
    --text-muted: #6c6c6c;
    --accent-primary: #4895ef;
    --accent-secondary: #4361ee;
    --accent-light: #4895ef;
    --success: #27ae60;
    --error: #c0392b;
    --warning: #d68910;
    --border: #2d3748;
    --shadow: rgba(0, 0, 0, 0.3);
    --card-bg: #16213e;
    --header-bg: #0f3460;
}

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

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', -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;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Container */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s ease;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.theme-toggle {
    background: var(--bg-tertiary);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.05);
}

.icon-dark { display: none; }
[data-theme="dark"] .icon-light { display: none; }
[data-theme="dark"] .icon-dark { display: inline; }

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

/* Screens */
.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Welcome Section */
.welcome {
    text-align: center;
}

.welcome h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.welcome > p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.welcome h3 {
    font-size: 1.25rem;
    margin: 2rem 0 1rem;
    color: var(--text-secondary);
}

/* Stats Overview */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Section Grid */
.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

.section-card {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.section-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow);
}

.section-card:active {
    transform: translateY(-2px);
}

.section-icon {
    font-size: 2.5rem;
}

.section-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.section-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Quiz Screen */
.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.quiz-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.question-counter {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-tertiary);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: 600;
}

.timer.warning {
    color: var(--warning);
    animation: pulse 1s infinite;
}

.timer.danger {
    color: var(--error);
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Progress Bar */
.progress-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-bottom: 2rem;
    overflow: hidden;
}

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

/* Question Container */
.question-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.question-text {
    font-size: 1.25rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.question-text p {
    margin-bottom: 1rem;
}

.question-text .article {
    background: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.8;
}

.question-text .highlight {
    background: linear-gradient(120deg, rgba(67, 97, 238, 0.2) 0%, rgba(72, 149, 239, 0.2) 100%);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}

/* Answer Options */
.answer-options {
    display: grid;
    gap: 0.75rem;
}

.answer-option {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.answer-option.selected {
    border-color: var(--accent-primary);
    background: rgba(67, 97, 238, 0.1);
}

.answer-option.correct {
    border-color: var(--success);
    background: rgba(46, 204, 113, 0.15);
}

.answer-option.incorrect {
    border-color: var(--error);
    background: rgba(231, 76, 60, 0.15);
}

.answer-option.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

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

.answer-option.correct .option-letter {
    background: var(--success);
    color: white;
}

.answer-option.incorrect .option-letter {
    background: var(--error);
    color: white;
}

/* Quiz Actions */
.quiz-actions {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

/* Feedback Overlay */
.feedback-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.feedback-overlay.active {
    display: flex;
}

.feedback-content {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 2.5rem;
    text-align: center;
    max-width: 400px;
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.feedback-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    font-size: 2.5rem;
}

.feedback-icon.correct {
    background: rgba(46, 204, 113, 0.2);
    color: var(--success);
}

.feedback-icon.incorrect {
    background: rgba(231, 76, 60, 0.2);
    color: var(--error);
}

.feedback-text {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Results Screen */
.results-container {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.results-container h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
}

.results-summary {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.score-circle {
    position: relative;
    width: 200px;
    height: 200px;
}

.score-circle svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.score-bg {
    fill: none;
    stroke: var(--bg-tertiary);
    stroke-width: 8;
}

.score-fill {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 1s ease;
}

.score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.results-details {
    text-align: center;
}

.results-details p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.results-breakdown {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    text-align: left;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

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

.breakdown-section {
    font-weight: 600;
    color: var(--text-primary);
}

.breakdown-score {
    font-weight: 500;
    color: var(--accent-primary);
}

.results-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.4);
}

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

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

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

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }

    .logo {
        font-size: 1.25rem;
    }

    .welcome h2 {
        font-size: 1.5rem;
    }

    .section-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .quiz-header {
        flex-direction: column;
        align-items: stretch;
    }

    .quiz-info {
        order: 1;
    }

    .timer {
        justify-content: center;
    }

    #back-btn {
        order: 2;
    }

    .question-container {
        padding: 1.25rem;
    }

    .question-text {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .section-grid {
        grid-template-columns: 1fr;
    }

    .section-card {
        flex-direction: row;
        justify-content: flex-start;
        text-align: left;
    }

    .section-icon {
        font-size: 2rem;
    }

    .stats-overview {
        grid-template-columns: 1fr;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection */
::selection {
    background: var(--accent-primary);
    color: white;
}
