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

:root {
    /* Color System - Modern Dark Theme with Purple Accents */
    --background: #0a0a0b;
    --surface: #1a1a1d;
    --surface-elevated: #242428;
    --surface-hover: #2a2a2f;
    --border: #333338;
    --border-hover: #444449;

    /* Primary Purple Theme */
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-light: #a78bfa;
    --primary-dark: #6d28d9;

    /* Text Colors */
    --foreground: #ffffff;
    --foreground-secondary: #a1a1aa;
    --foreground-muted: #71717a;

    /* Accent Colors */
    --success: #10b981;
    --success-light: #34d399;
    --error: #ef4444;
    --error-light: #f87171;
    --warning: #f59e0b;
    --warning-light: #fbbf24;

    /* Semantic Colors */
    --correct: var(--success);
    --incorrect: var(--error);

    /* Spacing & Layout */
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;
    --shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 8px -2px rgba(0, 0, 0, 0.4);

    /* Typography */
    --font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: var(--background);
    color: var(--foreground);
    line-height: 1.4;
    min-height: 100vh;
    background-image: radial-gradient(circle at 20% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
}

/* Header - Made header more compact */
header {
    background: var(--surface);
    border-bottom: 1px solid red; /* start color */
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    animation: rgbBorder 3s infinite linear;
}
@keyframes rgbBorder {
    0%   { border-color: #8b5cf6; }
    66%  { border-color: white; }
    33%  { border-color: #10102d; }
    100% { border-color: #8b5cf6; }
}
.title {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    background-image: linear-gradient(to bottom, #8b5cf6, white);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: -0.02em;
}

/* Main Container - Optimized for compact layout */
main {
    max-width: 700px;
    margin: 0 auto;
    padding: 0.5rem;
    min-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.quiz-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    margin-top: 1rem;
}

/* Front Score Display - Made more compact */
.front-score {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    margin: 25px auto 1rem;
    text-align: center;
    font-weight: 500;
    max-width: 500px;
    box-shadow: var(--shadow);
    font-size: 0.9rem;
}

/* Start Screen - Reduced padding significantly */
#start-screen {
    padding: 2rem 1.5rem;
    text-align: center;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--foreground);
    font-size: 1rem;
}

#username {
    width: 100%;
    max-width: 350px;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-elevated);
    color: var(--foreground);
    font-size: 1rem;
    transition: all 0.2s ease;
    outline: none;
}

#username:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Theme Selector - Made more compact */
.theme-selector {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.theme-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-elevated);
    background-size: cover;
    background-position: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.theme-btn:hover {
    border-color: var(--primary);
    background: var(--surface-hover);
    color: var(--foreground);
    transform: translateY(-1px);
}

.theme-btn.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    -webkit-box-shadow: 1px 2px 15px 5px #6D28D9FF;
    box-shadow: 1px 2px 15px 5px #6D28D9FF;
}
.theme-btn[data-theme="javascript"] {
    background-image: url('../images/code.gif');
}

.theme-btn[data-theme="html"] {
    background-image: url('../images/code.gif');
}

.theme-btn[data-theme="css"] {
    background-image: url('../images/code.gif');

}

/* Buttons - Made more compact */
.btn,
#start-btn,
#next-btn,
#submit-btn,
#restart-btn,
#close {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-width: 120px;
}

#start-btn,
#submit-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow);
    margin-top: 1rem;
}

#start-btn:hover,
#submit-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

#next-btn {
    background: var(--surface-elevated);
    color: var(--foreground);
    border: 2px solid var(--border);
}

#next-btn:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
}

#restart-btn {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    margin-top: 1rem;
}

#close {
    background: var(--surface-elevated);
    color: var(--foreground-secondary);
    border: 2px solid var(--border);
}

#close:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

/* Quiz Content - Significantly reduced padding and margins */
#quiz-content {
    padding: 1rem;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--surface-elevated);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.question-counter,
.timer {
    font-weight: 600;
    color: var(--foreground);
    font-size: 0.9rem;
}

.timer {
    color: var(--primary);
}

/* Question Timer - Made more compact */
.question-timer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--surface-elevated);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

#question-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: width 1s linear;
    border-radius: 3px;
}

/* Quiz Questions - Significantly reduced padding and margins */
.quiz-question {
    background: var(--surface-elevated);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--foreground);
    line-height: 1.4;
}

.multi-answer {
    background: linear-gradient(135deg, var(--warning), var(--warning-light));
    color: white;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 1rem;
    display: inline-block;
}

.options-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-item {
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.option-item:hover {
    border-color: var(--primary);
    background: var(--surface);
}

.option-item input[type="radio"],
.option-item input[type="checkbox"] {
    margin-right: 0.75rem;
    transform: scale(1.1);
    accent-color: var(--primary);
}

.option-item label {
    cursor: pointer;
    font-weight: 500;
    color: var(--foreground);
    display: flex;
    align-items: center;
    width: 100%;
    font-size: 0.95rem;
}

/* Instant Feedback - Made more compact */
.instant-feedback {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    text-align: center;
}

.instant-feedback .correct {
    color: var(--success);
    font-weight: 600;
    font-size: 1rem;
}

.instant-feedback .incorrect {
    color: var(--error);
    font-weight: 600;
    font-size: 1rem;
}

.validate-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.validate-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    transform: translateY(-1px);
}

/* Action Buttons - Reduced margin */
.btns {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Results - Reduced padding */
.result {
    padding: 1.5rem;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

#score {
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

#feedback {
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--foreground-secondary);
}

/* Corrections - Made more compact */
.corrections {
    margin: 1.5rem 0;
}

.question-result {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.question-result .q-r {
    color: var(--primary);
    font-size: 1rem;
}

.question-result .correct {
    color: var(--success);
    font-weight: 600;
}

.question-result .incorrect {
    color: var(--error);
    font-weight: 600;
}

/* Statistics and Charts - Made more compact */
.TileH {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 1.5rem 0 0.75rem;
    color: var(--foreground);
    text-align: center;
}

.charts-section {
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: var(--surface-elevated);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 0.75rem;
}

.chart-item {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    height: 250px;
}

/* History - Made more compact */
.history {
    background: var(--surface-elevated);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin: 1rem 0;
}

.history-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--foreground-secondary);
    font-size: 0.9rem;
}

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

.statistics-section {
    margin-bottom: 1.5rem;
}

.statistics-section h4 {
    color: var(--primary);
    font-weight: 600;
    margin: 0.75rem 0 0.4rem;
    font-size: 1rem;
}

.statistics-section p {
    color: var(--foreground-secondary);
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

/* PDF Download Button */
#download-pdf-btn {
    background: linear-gradient(135deg, var(--warning), var(--warning-light));
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    margin: 0.75rem 0;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

#download-pdf-btn:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
/* CSV Export Modal */
.csv-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.csv-modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--border);
}

.csv-modal h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    text-align: center;
}

.csv-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.csv-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.csv-option input[type="checkbox"] {
    accent-color: var(--primary);
}

.csv-option label {
    color: var(--foreground);
    font-size: 0.9rem;
}

.csv-modal-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

#download-csv-btn {
    background: linear-gradient(135deg, var(--warning), var(--warning-light));
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    margin: 0.75rem 0;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

#download-csv-btn:hover {
    background: linear-gradient(135deg, var(--warning-light), var(--warning));
    transform: translateY(-1px);
}


/* Responsive Design - Optimized for mobile */
@media (max-width: 768px) {
    main {
        padding: 0.5rem;
    }

    .title {
        font-size: 1.75rem;
    }

    #start-screen {
        padding: 1.5rem 1rem;
    }

    .theme-selector {
        flex-direction: column;
        align-items: center;
    }

    .theme-btn {
        width: 100%;
        max-width: 280px;
    }

    .quiz-header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .question-timer {
        flex-direction: column;
        gap: 0.4rem;
    }

    .btns {
        flex-direction: column;
        align-items: center;
    }

    .btn,
    #start-btn,
    #next-btn,
    #submit-btn,
    #restart-btn,
    #close {
        width: 100%;
        max-width: 280px;
    }

    .charts-container {
        grid-template-columns: 1fr;
    }

    .chart-item {
        height: 200px;
    }
}

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

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

/* Focus States for Accessibility */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Loading States */
.validate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Hover Effects */
.quiz-container {
    transition: all 0.3s ease;
}

.option-item input:checked + label {
    color: var(--primary);
    font-weight: 600;
}

.option-item:has(input:checked) {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--primary);
}

/* Added scroll optimization for quiz content */
#quiz-content::-webkit-scrollbar {
    width: 6px;
}

#quiz-content::-webkit-scrollbar-track {
    background: var(--surface);
}

#quiz-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

#quiz-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}
