@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #0D9488;
    --primary-dark: #0F766E;
    --primary-light: #F0FDFA;
    --success: #10B981;
    --success-light: #D1FAE5;
    --error: #EF4444;
    --error-light: #FEE2E2;
    --neutral-50: #F9FAFB;
    --neutral-100: #F3F4F6;
    --neutral-200: #E5E7EB;
    --neutral-300: #D1D5DB;
    --neutral-400: #9CA3AF;
    --neutral-500: #6B7280;
    --neutral-600: #4B5563;
    --neutral-700: #374151;
    --neutral-800: #1F2937;
    --neutral-900: #111827;
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px 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);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Dark mode colors */
.dark-mode {
    --primary: #2DD4BF;
    --primary-dark: #14B8A6;
    --primary-light: #042F2E;
    --neutral-50: #1F2937;
    --neutral-100: #1F2937;
    --neutral-200: #374151;
    --neutral-300: #4B5563;
    --neutral-400: #6B7280;
    --neutral-500: #9CA3AF;
    --neutral-600: #D1D5DB;
    --neutral-700: #E5E7EB;
    --neutral-800: #F3F4F6;
    --neutral-900: #F9FAFB;
    --success-light: #064E3B;
    --error-light: #7F1D1D;
}

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

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    background-color: var(--neutral-100);
    color: var(--neutral-800);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s, color 0.3s;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--neutral-200);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.app-logo a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--neutral-600);
    font-size: 1.25rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

.theme-toggle:hover {
    background-color: var(--neutral-200);
    color: var(--neutral-800);
}

/* Quiz container */
.quiz-container {
    background-color: var(--neutral-50);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    transition: box-shadow 0.3s, background-color 0.3s;
}

.quiz-header {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background-color: white;
    border-bottom: 1px solid var(--neutral-200);
    transition: background-color 0.3s;
}

.dark-mode .quiz-header {
    background-color: var(--neutral-800);
}

.quiz-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--neutral-900);
    margin-bottom: 0.5rem;
    transition: color 0.3s;
}

.quiz-description {
    font-size: 1rem;
    color: var(--neutral-600);
    margin-top: 0.25rem;
    transition: color 0.3s;
}

/* Progress section */
.stats-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-primary {
    background-color: var(--primary-light);
    color: var(--primary);
}

.progress-container {
    width: 100%;
    height: 0.5rem;
    background-color: var(--neutral-200);
    border-radius: 9999px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary);
    border-radius: 9999px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Question info */
.question-info {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-light);
    color: var(--primary);
    font-size: 0.875rem;
    transition: background-color 0.3s, color 0.3s;
}

.dark-mode .question-info {
    color: var(--neutral-50);
}

/* Question content */
.quiz-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: white;
    transition: background-color 0.3s;
}

.dark-mode .quiz-content {
    background-color: var(--neutral-800);
}

.question {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    line-height: 1.6;
    color: var(--neutral-900);
    transition: color 0.3s;
}

.answers {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Answer styling */
.answer {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    background-color: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

.dark-mode .answer {
    background-color: var(--neutral-700);
    border-color: var(--neutral-600);
}

.answer:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.answer-letter {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background-color: var(--neutral-200);
    color: var(--neutral-700);
    font-weight: 600;
    margin-right: 1rem;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.dark-mode .answer-letter {
    background-color: var(--neutral-600);
    color: var(--neutral-200);
}

.answer-text {
    flex: 1;
}

.answer-selected {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.dark-mode .answer-selected {
    background-color: var(--primary-dark);
}

.answer-selected .answer-letter {
    background-color: var(--primary);
    color: white;
}

.answer-correct {
    border-color: var(--success);
    background-color: var(--success-light);
}

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

.answer-incorrect {
    border-color: var(--error);
    background-color: var(--error-light);
}

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

/* Results */
.result-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 2rem;
}

.result-icon {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.result-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--neutral-900);
    transition: color 0.3s;
}

.result-score {
    font-size: 1.5rem;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    background-color: var(--primary-light);
    color: var(--primary);
    border-radius: 9999px;
    margin-bottom: 1.5rem;
    transition: background-color 0.3s, color 0.3s;
}

.dark-mode .result-score {
    color: white;
}

.result-message {
    font-size: 1.125rem;
    margin-bottom: 2rem;
    max-width: 500px;
    color: var(--neutral-600);
    transition: color 0.3s;
}

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

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

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

/* Footer */
.app-footer {
    padding: 2rem 0;
    text-align: center;
    color: var(--neutral-500);
    font-size: 0.875rem;
    border-top: 1px solid var(--neutral-200);
    margin-top: 2rem;
    transition: color 0.3s;
}

/* Loading state */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
}

.loading-spinner {
    border: 3px solid var(--neutral-200);
    border-radius: 50%;
    border-top: 3px solid var(--primary);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Animation */
@keyframes fadeIn {
    from { opacity: 0.2; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Visibility control */
.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.visible {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.selection-content {
    display: flex;
    justify-content: center;
}

.selection-form {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.begin-button-form {
    margin: 0 auto;
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
    color: var(--neutral-700);
    transition: color 0.3s;
}

.dark-mode .form-group label {
    color: var(--neutral-300);
}

/* Random option */
.random-option {
    padding: 0.75rem;
    background-color: var(--primary-light);
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: background-color 0.3s, border-color 0.3s;
}

.dark-mode .random-option {
    background-color: var(--primary-dark);
    border-left-color: var(--primary);
}

.random-option input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.random-option label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
}

.dark-mode .random-option label {
    color: white;
}

.option-description {
    margin-left: 1.8rem;
    font-size: 0.85rem;
    color: var(--neutral-600);
}

.option-description2 {
    margin-left: 0rem;
    font-size: 0.85rem;
    color: var(--neutral-600);
}

.dark-mode .option-description {
    color: var(--neutral-300);
}

/* Source options */
.source-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 500px;
    width: 55vw;
    overflow-y: auto;
    padding: 0.5rem;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius);
    background-color: var(--neutral-50);
    transition: background-color 0.3s, border-color 0.3s;
}

.dark-mode .source-options {
    border-color: var(--neutral-600);
    background-color: var(--neutral-700);
}

.source-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: calc(var(--radius) / 2);
    transition: background-color 0.2s;
    cursor: pointer;
}

.source-checkbox:hover {
    background-color: var(--neutral-200);
}

.dark-mode .source-checkbox:hover {
    background-color: var(--neutral-600);
}

.source-checkbox input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.source-checkbox label {
    font-weight: normal;
    cursor: pointer;
}

/* Select input */
.select-input {
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--neutral-300);
    background-color: var(--neutral-50);
    font-family: var(--font-sans);
    font-size: 1rem;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='none' d='M0 0h24v24H0z'/%3E%3Cpath d='M12 15l-4.243-4.243 1.415-1.414L12 12.172l2.828-2.829 1.415 1.414z' fill='%236B7280'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.dark-mode .select-input {
    background-color: var(--neutral-700);
    border-color: var(--neutral-600);
    color: var(--neutral-200);
}

.select-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

/* Transitions */
.slide-in {
    animation: slideIn 0.4s ease-out forwards;
}

.slide-out {
    animation: slideOut 0.4s ease-out forwards;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(30px); visibility: visible; }
    to { opacity: 1; transform: translateX(0); visibility: visible; }
}

@keyframes slideOut {
    from { opacity: 1; transform: translateX(0); visibility: visible; }
    to { opacity: 0; transform: translateX(-30px); visibility: visible; }
}

#start-quiz-btn {
    margin-top: 1rem;
    align-self: center;
}

/* Result buttons */
.result-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Question history */
.question-history {
    margin-top: 2.5rem;
    width: 100%;
    border-top: 1px solid var(--neutral-200);
    padding-top: 2rem;
}

.question-history h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--neutral-800);
    text-align: center;
}

.dark-mode .question-history h2 {
    color: var(--neutral-200);
}

.history-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: 500px;
    overflow-y: auto;
    padding: 0 1rem 1rem 1rem;
}

.history-item {
    padding: 1.25rem;
    border-radius: var(--radius);
    background-color: var(--neutral-50);
    border-left: 4px solid var(--neutral-400);
    transition: background-color 0.3s, border-color 0.3s;
    box-shadow: var(--shadow-sm);
}

.history-item.history-correct {
    border-left-color: var(--success);
}

.history-item.history-incorrect {
    border-left-color: var(--error);
}

.dark-mode .history-item {
    background-color: var(--neutral-700);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.history-number {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

.history-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--neutral-500);
}

.dark-mode .history-meta {
    color: var(--neutral-400);
}

.history-question {
    font-weight: 600;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.history-answers {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-left: 1rem;
}

.history-answer {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: calc(var(--radius) / 2);
    background-color: var(--neutral-100);
    position: relative;
    transition: background-color 0.3s;
}

.dark-mode .history-answer {
    background-color: var(--neutral-600);
}

.history-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background-color: var(--neutral-300);
    color: var(--neutral-800);
    font-weight: 600;
    margin-right: 0.75rem;
}

.dark-mode .history-letter {
    background-color: var(--neutral-500);
    color: var(--neutral-800);
}

.history-text {
    flex: 1;
}

.history-correct-answer {
    background-color: var(--success-light);
}

.dark-mode .history-correct-answer {
    background-color: #064E3B;
}

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

.history-wrong-answer {
    background-color: var(--error-light);
}

.dark-mode .history-wrong-answer {
    background-color: #7F1D1D;
}

.history-wrong-answer .history-letter {
    background-color: var(--error);
    color: white;
}

.user-selected {
    position: absolute;
    right: 1rem;
    color: var(--neutral-600);
}

.dark-mode .user-selected {
    color: var(--neutral-300);
}

/* Exam mode */
.exam-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    padding: 0.5rem 1rem;
    background-color: var(--primary-light);
    border-radius: var(--radius);
    transition: background-color 0.3s, color 0.3s;
}

.exam-timer.warning {
    color: var(--error);
    background-color: var(--error-light);
}

/* Category filter */
.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius);
    background-color: var(--neutral-50);
    transition: background-color 0.3s, border-color 0.3s;
}

.dark-mode .category-filters {
    border-color: var(--neutral-600);
    background-color: var(--neutral-700);
}

.category-chip {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--neutral-300);
    background-color: white;
    color: var(--neutral-700);
    transition: all 0.2s;
}

.dark-mode .category-chip {
    background-color: var(--neutral-600);
    border-color: var(--neutral-500);
    color: var(--neutral-200);
}

.category-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.category-chip.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
}

.category-chip .chip-count {
    font-size: 0.7rem;
    opacity: 0.8;
}

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

    .quiz-header, .quiz-content {
        padding: 1rem;
    }

    .question {
        font-size: 1.125rem;
    }

    .answer {
        padding: 0.75rem 1rem;
    }

    .answer-letter {
        width: 1.75rem;
        height: 1.75rem;
        margin-right: 0.75rem;
    }

    .result-title {
        font-size: 1.5rem;
    }

    .result-score {
        font-size: 1.25rem;
    }

    .result-message {
        font-size: 1rem;
    }

    .source-options {
        width: 100% !important;
        max-width: none !important;
        margin: 0 auto;
    }

    .form-group {
        width: 100% !important;
        margin: 0 auto;
    }

    .select-input {
        width: 100% !important;
    }

    .quiz-content {
        padding: 10px !important;
    }

    .result-buttons {
        flex-direction: column;
    }

    .history-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .history-meta {
        flex-direction: column;
        gap: 0.25rem;
    }

    .history-answer {
        padding: 0.5rem;
    }

    .history-letter {
        min-width: 1.5rem;
        height: 1.5rem;
        margin-right: 0.5rem;
    }

    .category-filters {
        gap: 0.25rem;
    }

    .category-chip {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .exam-timer {
        font-size: 0.875rem;
    }
}
