/* --- Variables & Reset --- */
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --bg-dark: #0f172a;
    --card-dark: #1e293b;
    --text-dark: #f1f5f9;
    --text-muted: #94a3b8;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
}

/* Prevent horizontal scrolling on mobile */
html, body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}
html {
    /* Simulates the 90% zoom look by reducing base scale */
    font-size: 14.5px; 
}
.mcq-study-center-card {
    text-align: center;
    background: linear-gradient(145deg, var(--card-dark), rgba(0, 0, 0, 0.2));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 24px;
    padding: 40px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3);

}
.reveal-mode .option-btn {
    cursor: default;
    pointer-events: none; /* Removes hover glow and clicking */
    opacity: 0.8;
}

/* Make sure the correct answer is fully visible and bright */
.reveal-mode .option-btn.correct {
    opacity: 1 !important;
    background: #059669 !important;
    border-color: #10b981 !important;
    color: white !important;
}

/* Spacing fix for the study center card */
.mcq-study-center-card {
    margin-bottom: 40px;
}
#mcqStudyTitle {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 30px; /* This creates the spacing you need */
background: linear-gradient(40deg, #4958f2, #b871ff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
/* --- MCQ Study Center Light Mode Fix --- */
.light .mcq-study-center-card {
    /* Uses a clean white-to-gray gradient for light mode */
    background: linear-gradient(145deg, #ffffff, #f1f5f9);
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}

.light #mcqStudyTitle {
    /* Adjusts gradient to be slightly deeper for better readability on white */
    background: linear-gradient(40deg, #3730a3, #7c3aed);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Ensure the Exam Button stays vibrant but fits the light theme */
.light .btn-start-exam {
    background: #4f46e5; /* Slightly deeper indigo */
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.15);
}

.light .btn-start-exam:hover {
    background: #6366f1;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.25);
}
/* Start Exam Button */
.btn-start-exam {
    background: #6366f1; /* Primary blue/purple */
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 16px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

/* Hover Glow Effect */
.btn-start-exam:hover {
    transform: translateY(-3px);
    background: #7477ff;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.6), 
                0 0 40px rgba(99, 102, 241, 0.3);
}

.btn-start-exam:active {
    transform: translateY(0);
}
.mistake-border {
    border-left: 6px solid #ef4444 !important; /* Red color */
    background-color: rgba(239, 68, 68, 0.05); /* Light red tint */
}
/* Ensure the list is hidden until started */
#mcqList.hidden {
    display: none;
}
body { 
    line-height: 1.6; 
    background: var(--bg-dark); 
    color: var(--text-dark);
    transition: background 0.3s ease;
    max-width: 2000px;
    margin: 0 auto;
}
header, .container {
    padding-top: 10px; /* Adjust this value (e.g., 20px to 60px) to your liking */
}
.progress-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 25px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    width: 0%; 
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

/* Ensure progress bar shows up in light mode too */
.light .progress-container { background: #e2e8f0; }
/* --- Layout Container --- */
.container { 
  width: 90%;
    max-width: 800px; /* Keeps the exam card focused and professional */
    margin: 0 auto;
}

/* --- Header Section --- */
.header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 40px; 
    gap: 20px;
}

#title { 
    font-size: 2.2rem; 
    font-weight: 800; 
    color: var(--primary-light); 
    line-height: 1.1;
}
.fade-slide-in {
    animation: fadeSlide 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeSlide {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure sections have a clean starting point */
#essaySection, #mcqSection {
    transition: opacity 0.8s ease;
}

#creation { 
    color: var(--text-muted); 
    font-size: 1rem; 
    font-weight: bold;
}
#subtitle { 
    color: var(--text-muted); 
    font-size: 0.95rem; 
}

.header-buttons { 
    display: flex; 
    gap: 12px; 
    flex-shrink: 0; 
}

.btn-modern {
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    background: var(--card-dark);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-modern:hover { 
    background: var(--primary); 
    color: #fff;
    transform: translateY(-2px); 
    /* This adds the purple glow effect */
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4), 0 0 30px rgba(99, 102, 241, 0.2);
    border-color: var(--primary-light);
}

/* --- Navigation Tabs --- */
.tabs { 
    display: flex; 
    gap: 10px; 
    background: rgba(255,255,255,0.05); 
    padding: 6px; 
    border-radius: 12px; 
    margin-bottom: 30px; 
}

.tab { 
    flex: 1; 
    padding: 12px; 
    border: none; 
    background: transparent; 
    cursor: pointer; 
    border-radius: 8px; 
    font-weight: 700; 
    color: var(--text-muted); 
    transition: 0.3s;
}

.tab:hover:not(.active) {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
}

.tab.active { 
    background: var(--primary); 
    color: white; 
    /* Glow for the active tab */
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}


/* --- Cards & Content --- */
.card { 
    background: var(--card-dark); 
    border-radius: 16px; 
    padding: 24px; 
    margin-bottom: 20px; 
    border: 1px solid rgba(255,255,255,0.05); 
    word-wrap: break-word; /* Prevents long words from breaking layout */
}
.mcq-card, 
.exam-mode-card {
    border-left: 3.5px solid #6366f1 !important; /* Thick purple accent */
    border-radius: 12px; /* Matches your card rounding */
    padding-left: 20px !important; /* Spacing between border and text */
}

/* Ensure Essay cards remain clean/standard */
#essaySection .card {
    border-left: none;
}
#modeLabel {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- MCQ Styling --- */
.question-text { 
    font-size: 1.2rem; 
    font-weight: 700; 
    margin-bottom: 20px; 
    display: block; 
}

.options-grid { 
    display: grid; 
    gap: 12px; 
}

.option-btn {
    width: 100%; 
    text-align: left; 
    padding: 16px 20px; 
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.05); 
    background: rgba(255,255,255,0.02);
    color: var(--text-dark); 
    cursor: pointer; 
    transition: all 0.2s;
}

[dir="rtl"] .option-btn { text-align: right; }

.option-btn.correct { background: #059669 !important; border-color: #10b981 !important; color: white; }
.option-btn.wrong { background: #991b1b !important; border-color: #ef4444 !important; color: white; }

.feedback-msg { margin-top: 15px; padding: 12px; border-radius: 10px; font-weight: 700; text-align: center; }
.correct-text { color: #10b981; border: 1px solid #10b981; }
.wrong-text { color: #ef4444; border: 1px solid #ef4444; }

/* --- Essay Styling --- */
.essay-row { display: flex; justify-content: space-between; cursor: pointer; align-items: center; }
.answer-container { max-height: 0; overflow: hidden; opacity: 0; transition: all 0.4s; }
.answer-container.show { max-height: 2000px; opacity: 1; margin-top: 15px; padding-top: 15px; border-top: 1px solid rgba(255,255,255,0.1); }
.essay-answer { 
    font-size: 1.05rem; 
    color: #cbd5e1; 
    line-height: 1.8; 
    white-space: pre-line; 
    padding: 10px 0;
}

/* --- Modal --- */
.modal-overlay { 
    position: fixed; 
    top: 0; left: 0; 
    width: 100%; height: 100%; 
    background: rgba(0,0,0,0.85); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 1000; 
    backdrop-filter: blur(10px); 
    padding: 20px;
}
#backToTop {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: none; /* Show/hide via JS */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 1000;
}
.modal-card { max-width: 400px; width: 100%; text-align: center; }
#scoreResult { font-size: 3.5rem; font-weight: 800; color: var(--primary-light); }

/* --- Utility Classes --- */
.hidden { display: none !important; }

/* --- Light Mode Overrides --- */
.light { background: #f8fafc; color: #1e293b; }
.light .card, .light .mode-switch { background: #fff; border: 1px solid #e2e8f0; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.light #modeLabel, .light .question-text, .light .essay-header { color: #1e293b !important; }
.light .btn-modern { background: #f1f5f9; color: #6366f1; border: 1px solid #cbd5e1; }
.light .btn-modern:hover { background: #6366f1; color: #fff; }
.light .option-btn { color: #000 !important; background: #f8fafc; border: 1px solid #e2e8f0; }
.light .essay-answer { color: #475569; }
.light .option-btn.correct, .light .option-btn.wrong { color: #fff !important; }

/* ------------------------------------------------ */
/* --- MOBILE RESPONSIVENESS (Media Queries) --- */
/* ------------------------------------------------ */

/* ------------------------------------------------ */
/* --- CONSOLIDATED MOBILE RESPONSIVENESS --- */
/* ------------------------------------------------ */

@media (max-width: 768px) {
    html {
        font-size: 14px; 
    }

    body {
        padding-top: 25px; /* Adds breathing room at the very top */
    }

    .container {
        width: 95%;
        padding: 5px;
    }

    /* Stack the Main Header (Title and Buttons) */
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        margin-bottom: 30px;
    }

    .header-buttons {
        width: 100%;
        justify-content: flex-start;
        gap: 10px;
    }

    /* Fix Exam Navigation (Reveal Mode Button & Shuffle Toggle) */
    .exam-header-nav {
        flex-direction: column-reverse; /* Put toggle above the button for better ergonomics */
        gap: 20px;
    }

    #exitExamBtn {
        width: 100% !important;
        max-width: none;
        padding: 12px !important;
    }

    .shuffle-container {
        width: 100%;
        justify-content: space-between; /* Pushes text to one side and switch to other */
        background: rgba(255, 255, 255, 0.03);
        padding: 10px 15px;
        border-radius: 12px;
    }

    /* Card & Options Adjustments */
    .card {
        padding: 18px;
        margin-bottom: 15px;
    }

    .mcq-card, .exam-mode-card {
        border-left-width: 5px !important;
        padding-left: 15px !important;
    }

    .options-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .option-btn {
        padding: 14px 16px;
        font-size: 1rem;
    }

    /* Navigation Tabs */
    .tabs {
        padding: 4px;
        gap: 5px;
    }

    .tab {
        padding: 10px 5px;
        font-size: 0.9rem;
    }

    /* Modal adjustments */
    .modal-card {
        width: 90%;
        padding: 30px 20px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    #title { 
        font-size: 1.8rem; 
    }
    
    #subtitle, #creation {
        font-size: 0.85rem;
    }

    .next-btn-container {
        justify-content: center !important; /* Center "Next" button on small phones */
    }
    
    [dir="rtl"] .next-btn-container {
        justify-content: center !important;
    }
}
/* --- FIX: Mistake Button Position --- */
#mistakeToggleBtn {
    display: block;
    margin: 0 auto 30px auto; /* Centered and adds space below */
}

#mistakeToggleBtn:hover {
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
    transform: translateY(-1px);
}

/* Light mode adjustment for mistake button */
.light #mistakeToggleBtn {
    border-color: var(--primary);
    color: var(--primary);
}

.shuffle-container {
    display: flex;
    align-items: center;
    gap: 12px;
}
#shuffleText {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* The Toggle Switch - Now only the switch is clickable */
.material-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    cursor: pointer;
}

/* Hide the default checkbox */
.material-switch input {
    display: none;
}
.material-switch:hover .slider {
    box-shadow: 0 0 10px rgba(99, 101, 241, 0.61);
}

/* --- Locked State Styling --- */
/* Makes the toggle look faded and changes the cursor */
.material-switch.locked {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.8);
}

.material-switch.locked .slider {
    pointer-events: none; /* Disables clicking visually */
}

/* Optional: Slight shake animation if they try to click while locked */
.shake {
    animation: shake 0.3s ease-in-out;
}

#nextQuestionBtn.final-score {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); /* Gold Gradient */
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
    border: 1px solid #fbbf24;
}

#nextQuestionBtn.final-score:hover {
    box-shadow: 0 0 30px rgba(245, 158, 11, 0.6);
    transform: translateY(-3px) scale(1.02);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* The Track */
.slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #475569; 
    border-radius: 20px;
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* The Knob */
.slider:before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* State: Checked */
input:checked + .slider {
    background-color: var(--primary); 
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* --- FIX: Reset Next Question to Right --- */
.next-btn-container {
    min-height: 60px; /* Adjust based on your button height */
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 20px;
    width: 100%;
}
[dir="rtl"] .next-btn-container {
    justify-content: flex-start; /* Aligns to left for Arabic */
}

#nextQuestionBtn {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.4s ease, visibility 0.4s;
    /* Ensure it uses your modern button styles */
}
#nextQuestionBtn.show {
    visibility: visible;
    opacity: 1;
}

/* Specific Gold for Final Score - Overriding purple hover */
#nextQuestionBtn.final-score {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    color: white !important;
    border: none !important;
}

#nextQuestionBtn.final-score:hover {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important;
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 8px 20px rgba(217, 119, 6, 0.4) !important;
}
#examUI {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-top: 20px;
}

/* 2. Group and Center the Header Buttons */
.exam-header-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    width: 100%;
}

/* 3. Lower the size of the Reveal Mode button */
.exit-btn-small {
    padding: 8px 20px !important; /* Smaller padding */
    font-size: 0.9rem !important;  /* Smaller text */
    border-radius: 10px !important;
    min-height: auto !important;
    width: auto !important;
}

/* 4. Center the Shuffle Toggle */
.shuffle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* 5. Acceptable width for Progress Bar and Question Card */
.exam-progress-width, #examQuestionContainer {
    width: 100%;
    max-width: 650px; /* Limits width to look better on desktop */
    margin: 0 auto;
}
.exam-progress-width {
    margin-bottom: 10px !important; /* Adjust this number to increase/decrease space */
}
/* Ensure the question card stays left-aligned (or right for Arabic) inside the centered container */
.exam-mode-card {
    text-align: left;
}
[dir="rtl"] .exam-mode-card {
    text-align: right;
}
/* Enable hover effects specifically for Exam Mode */
.exam-mode-card .option-btn {
    cursor: pointer;
    transition: all 0.2s ease;
}

.exam-mode-card .option-btn:hover:not(:disabled) {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    transform: translateX(5px); /* Subtle shift to the right */
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

/* Light mode specific hover */
.light .exam-mode-card .option-btn:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: var(--primary);
}

/* Ensure that once a button is disabled (after clicking), the hover stops */
.exam-mode-card .option-btn:disabled {
    cursor: default;
    transform: none;
}
#retakeBtn {
    background: var(--primary) !important;
    color: white !important;
    border: none !important;
    font-size: 1.1rem;
    padding: 14px;
}

#retakeBtn:hover {
    background: var(--primary-light) !important;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

/* Make the Close button slightly more subtle */
#modalClose {
    opacity: 0.8;
    font-size: 0.9rem;
}
/* Specific hover for the Final Score button to prevent it turning purple */
#nextQuestionBtn.final-score:hover {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important; /* Brighter Gold */
    box-shadow: 0 0 25px rgba(245, 158, 11, 0.6);
    border: 1px solid #fff; /* Slight white border to make it pop */
    color: white !important;
    transform: translateY(-2px) scale(1.02);
}

/* Ensure the active/click state also stays gold */
#nextQuestionBtn.final-score:active {
    background: #d97706 !important;
    transform: translateY(0);
}


