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

:root {
    --primary-color: #16a34a;
    --primary-hover: #15803d;
    --primary-light: #dcfce7;
    --secondary-color: #0891b2;
    --danger-color: #dc2626;
    --warning-color: #ea580c;
    --success-color: #16a34a;
    --text-dark: #1f2937;
    --text-medium: #4b5563;
    --text-light: #6b7280;
    --bg-primary: #f0fdf4;
    --bg-secondary: #ffffff;
    --border-color: #d1d5db;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #059669 0%, #0891b2 100%);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 20px;
    color: var(--text-dark);
    line-height: 1.6;
}

.container {
    background-color: var(--bg-secondary);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 900px;
    width: 100%;
    text-align: center;
    animation: fadeIn 0.5s ease-in;
}

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

h1 {
    color: var(--primary-color);
    margin-bottom: 30px;
    font-size: 2.5em;
    font-weight: 700;
    background: linear-gradient(135deg, #059669 0%, #0891b2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    color: var(--text-dark);
    margin-bottom: 25px;
    font-size: 1.8em;
    font-weight: 600;
}

h3 {
    color: var(--text-dark);
    margin-bottom: 20px;
    font-size: 1.4em;
    font-weight: 600;
}

.section-description {
    margin-bottom: 20px;
    color: var(--text-medium);
    font-size: 1.05em;
    font-style: italic;
    background: linear-gradient(135deg, var(--primary-light), var(--bg-primary));
    padding: 12px 20px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--secondary-color);
    text-align: left;
}

/* Progress Indicator */
.progress-container {
    width: 100%;
    background-color: var(--border-color);
    border-radius: 50px;
    margin-bottom: 25px;
    overflow: hidden;
    height: 10px;
}

/* Timer Section */
.timer-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
}

.timer-button {
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    padding: 10px 24px;
    font-size: 15px;
}

.timer-button:hover {
    background: linear-gradient(135deg, #ea580c, #f59e0b);
}

.timer-button:disabled {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    cursor: not-allowed;
}

#timer-display {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3em;
    font-weight: 600;
    color: var(--primary-color);
}

.timer-label {
    color: var(--text-medium);
    font-size: 0.9em;
}

#timer-text {
    font-family: 'Courier New', monospace;
    background: white;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--primary-color);
    min-width: 80px;
    text-align: center;
}

.progress-container {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 50px;
    transition: width 0.4s ease;
    box-shadow: 0 2px 4px rgba(22, 163, 74, 0.4);
}

/* Button Styles */
button {
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    margin: 6px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

button:hover::before {
    left: 100%;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Week Selection Grid */
#learning-section {
    animation: slideIn 0.5s ease-out;
}

#assignment-selection {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
    animation: slideIn 0.5s ease-out;
}

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

.week-button {
    min-width: 140px;
    margin: 8px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.week-button:hover {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
}

.week-button[data-assignment="all"] {
    background: linear-gradient(135deg, #ea580c, #dc2626);
    width: calc(100% - 16px);
    margin-top: 20px;
    font-size: 18px;
    padding: 16px 28px;
}

.learning-button {
    min-width: 140px;
    margin: 8px;
    background: linear-gradient(135deg, #0891b2, #0e7490);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.learning-button:hover {
    background: linear-gradient(135deg, #0e7490, #0891b2);
}

#back-to-menu {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    padding: 10px 24px;
}

#back-to-menu:hover {
    background: linear-gradient(135deg, #4b5563, #6b7280);
}

/* Quiz Container */
#quiz-container, #results-container, #learning-container {
    margin-top: 30px;
    text-align: left;
    animation: fadeIn 0.5s ease-in;
}

#questions-wrapper,
#learning-questions-wrapper {
    display: flex;
    flex-direction: column;
    gap: 11px;
    margin-top: 12px;
    margin-bottom: 16px;
}

.question-card {
    background: var(--bg-primary);
    padding: 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.question-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.learning-card:hover {
    border-color: var(--secondary-color);
}

.learning-option,
.quiz-option {
    display: flex;
    align-items: center;
    width: 100%;
    background-color: var(--bg-secondary);
    color: var(--text-dark);
    text-align: left;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.quiz-option {
    cursor: pointer;
}

.quiz-option:hover {
    border-color: var(--primary-color);
    background-color: var(--primary-light);
    transform: translateX(0) !important;
}

.selected-quiz-option {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.learning-option {
    cursor: default;
}

.correct-learning-option {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border-color: var(--success-color);
    font-weight: 600;
    color: #15803d;
}

.check-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background-color: var(--success-color);
    color: white;
    border-radius: 50%;
    margin-right: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

#question-area {
    margin-bottom: 16px;
    background: var(--bg-primary);
    padding: 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.question-number {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
}

.question-text,
#question-text {
    font-size: 1.1em;
    margin-bottom: 14px;
    color: var(--text-dark);
    font-weight: 500;
    line-height: 1.5;
}

/* Option Buttons */
.options-container,
#options-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-button {
    display: flex;
    align-items: center;
    width: 100%;
    background-color: var(--bg-secondary);
    color: var(--text-dark);
    text-align: left;
    padding: 16px 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    font-size: 16px;
    cursor: pointer;
    position: relative;
    transform: translateX(0); /* Force initial position */
}

.option-button::before {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    margin-right: 15px;
    transition: border-color 0.3s ease, background-color 0.3s ease; /* Only animate colors */
    flex-shrink: 0;
}

.option-button:hover {
    border-color: var(--primary-color);
    background-color: var(--primary-light);
    transform: translateX(0) !important; /* Force no movement */
}

.option-button.selected {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-color: var(--primary-color);
    transform: translateX(0); /* Remove scale effect */
}

.option-button.selected::before {
    border-color: white;
    background-color: white;
    box-shadow: inset 0 0 0 4px var(--primary-color);
}

.option-button:disabled {
    cursor: not-allowed;
}

/* Navigation Buttons */
.button-container,
.submit-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 25px;
    gap: 10px;
}

.submit-container {
    background: var(--bg-primary);
    padding: 25px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

#submit-button {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 16px 48px;
    font-size: 18px;
    font-weight: 700;
}

#submit-button:hover {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
}

#next-button {
    margin-left: auto;
    background: linear-gradient(135deg, var(--primary-color), #15803d);
    padding: 14px 32px;
}

#next-button:hover {
    background: linear-gradient(135deg, #15803d, var(--primary-color));
}

/* Results Container */
#results-container {
    text-align: center;
}

.score-display {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 40px;
    border-radius: var(--radius-lg);
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
}

.score-display p {
    font-size: 1.4em;
    margin-bottom: 15px;
}

#score, #total-questions {
    font-weight: 700;
    font-size: 2.5em;
    display: inline-block;
}

.results-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

#review-answers-button {
    background: linear-gradient(135deg, var(--secondary-color), #0e7490);
}

#restart-button {
    background: linear-gradient(135deg, var(--primary-color), #15803d);
}

/* Feedback Area */
#feedback-area {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
    animation: fadeIn 0.5s ease-in;
}

#wrong-answers-list {
    list-style-type: none;
    padding: 0;
    text-align: left;
}

#wrong-answers-list li {
    background-color: #fef2f2;
    border-left: 4px solid var(--danger-color);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

#wrong-answers-list li:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(5px);
}

#wrong-answers-list li.correct-item {
    background-color: #f0fdf4;
    border-left-color: var(--secondary-color);
}

#wrong-answers-list p {
    margin-bottom: 10px;
    line-height: 1.6;
}

#wrong-answers-list p strong {
    color: var(--text-dark);
}

#wrong-answers-list .correct-answer {
    color: var(--secondary-color);
    font-weight: 600;
    background-color: #d1fae5;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-top: 5px;
}

#wrong-answers-list .user-answer {
    color: var(--danger-color);
    font-weight: 600;
    background-color: #fee2e2;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-top: 5px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 25px;
    }

    h1 {
        font-size: 2em;
    }

    h2 {
        font-size: 1.5em;
    }

    .week-button {
        min-width: 120px;
        margin: 5px;
        padding: 12px 20px;
        font-size: 14px;
    }

    #question-text {
        font-size: 1.1em;
    }

    .option-button {
        padding: 14px 16px;
        font-size: 15px;
    }

    button {
        padding: 12px 24px;
        font-size: 15px;
    }

    .score-display {
        padding: 30px 20px;
    }

    #score, #total-questions {
        font-size: 2em;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
    }

    h1 {
        font-size: 1.6em;
    }

    .week-button {
        min-width: 100%;
        margin: 5px 0;
    }

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

    .results-buttons button {
        width: 100%;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}