/* --- General Styling & Best Practices --- */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #34495e;
    --correct-color: #2ecc71;
    --incorrect-color: #e74c3c;
    --warning-color: #f1c40f;
    --border-radius: 12px;
    --box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* --- Main Quiz Container --- */
#quiz-container {
    width: 100%;
    max-width: 800px;
    background: #ffffff;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* --- Screens (Course Selection, Start, Quiz, Results) --- */
.screen {
    padding: 40px;
    text-align: center;
}

.hidden {
    display: none;
}

h1,
h2 {
    margin-bottom: 20px;
    color: var(--dark-color);
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 1.8rem;
    line-height: 1.4;
}

p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 30px;
}

/* --- Course Selection Screen --- */
#course-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.course-card {
    background: var(--light-color);
    border: 2px solid transparent;
    border-left: 5px solid var(--secondary-color);
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
}

.course-card:hover {
    border-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
}

.course-card h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.4rem;
}

.course-card .course-meta {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 10px;
    font-weight: 500;
}

.course-card .course-description {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 0;
    color: #333;
}

.start-btn,
.restart-btn,
.back-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    margin: 5px;
}

.start-btn:hover,
.restart-btn:hover,
.back-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}

.back-btn {
    background-color: var(--dark-color);
}

.back-btn:hover {
    background-color: var(--primary-color);
}

/* --- Progress Wizard --- */
#progress-wizard {
    display: flex;
    justify-content: space-around;
    padding: 20px 0;
    background-color: var(--light-color);
    border-bottom: 1px solid #bdc3c7;
}

.wizard-step {
    flex: 1;
    text-align: center;
    font-size: 0.8rem;
    color: #7f8c8d;
    position: relative;
    padding: 0 5px;
}

.wizard-step.active {
    color: var(--secondary-color);
    font-weight: 700;
}

.wizard-step.completed {
    color: var(--correct-color);
}

.wizard-step::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #bdc3c7;
}

.wizard-step.active::before {
    background-color: var(--secondary-color);
}

.wizard-step.completed::before {
    background-color: var(--correct-color);
}


/* --- Quiz Screen Specifics --- */
#quiz-screen {
    padding: 0;
}

#question-area {
    padding: 40px;
    text-align: center;
}

#question-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

#question-text {
    margin-bottom: 0;
}

#info-btn {
    background: none;
    border: 2px solid var(--secondary-color);
    color: var(--secondary-color);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#info-btn:hover {
    background: var(--secondary-color);
    color: white;
}

#question-counter {
    font-size: 1rem;
    color: #7f8c8d;
    margin-bottom: 25px;
}

#options-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 30px;
}

.option-btn {
    background-color: #ffffff;
    color: var(--primary-color);
    border: 2px solid var(--light-color);
    padding: 15px;
    font-size: 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--secondary-color);
    background-color: #f1f8fe;
}

.option-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.option-btn.correct {
    background-color: var(--correct-color);
    border-color: var(--correct-color);
    color: white;
}

.option-btn.incorrect {
    background-color: var(--incorrect-color);
    border-color: var(--incorrect-color);
    color: white;
}

#navigation {
    padding: 0 40px 40px 40px;
    text-align: right;
}

#next-btn {
    background-color: var(--dark-color);
    color: white;
    border: none;
    padding: 10px 25px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#next-btn:hover {
    background-color: var(--primary-color);
}

/* --- Results Screen --- */
#results-summary {
    list-style: none;
    padding: 0;
    margin-bottom: 30px;
    text-align: left;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    background-color: var(--light-color);
}

.result-item .topic-name {
    font-weight: 600;
}

.result-item .score {
    font-weight: 700;
    font-size: 1.2rem;
    padding: 5px 10px;
    border-radius: 5px;
    color: white;
}

.score.pass {
    background-color: var(--correct-color);
}

.score.warn {
    background-color: var(--warning-color);
}

.score.fail {
    background-color: var(--incorrect-color);
}

#overall-score {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 30px;
}

/* --- Info Modal --- */
#info-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#info-modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

#info-modal.visible .modal-content {
    transform: scale(1);
}

#close-modal-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #7f8c8d;
    cursor: pointer;
    line-height: 1;
}

#modal-explanation {
    font-size: 1rem;
    text-align: left;
}

/* --- Loading Indicator --- */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid var(--light-color);
    border-top: 4px solid var(--secondary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    #progress-wizard {
        flex-wrap: wrap;
        justify-content: flex-start;
        padding: 10px;
    }

    .wizard-step {
        flex-basis: 33.33%;
        margin-bottom: 10px;
        font-size: 0.7rem;
    }

    #options-container {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .screen {
        padding: 25px;
    }

    #question-area,
    #navigation {
        padding: 25px;
    }
}

/* --- Language Selector --- */
.language-selector {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
}

.lang-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-btn .flag-icon {
    width: 32px;
    height: 24px;
    display: block;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    opacity: 0.4;
    filter: grayscale(30%);
    transform: scale(0.9);
}

/* Active state - full visibility */
.lang-btn.active .flag-icon {
    opacity: 1;
    filter: grayscale(0%);
    transform: scale(1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Hover state - reveal inactive flags */
.lang-btn:hover .flag-icon {
    opacity: 1;
    filter: grayscale(0%);
    transform: scale(1.05);
}

/* Subtle lift effect on hover for all */
.lang-btn:hover {
    transform: translateY(-2px);
}

.lang-btn.active:hover .flag-icon {
    transform: scale(1.08);
}

/* --- Group Headers --- */
.group-header {
    color: white;
    padding: 12px 20px;
    border-radius: var(--border-radius);
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.group-header:first-child {
    margin-top: 0;
}