:root {
    --font-primary: 'Roboto', sans-serif;
    --font-display: 'Orbitron', sans-serif;

    /* Default Theme */
    --bg-color: #f0f4f8;
    --container-bg: #ffffff;
    --text-color: #333;
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --secondary-color: #6c757d;
    --secondary-hover: #545b62;
    --correct-color: #28a745;
    --correct-border-color: #1e7e34;
    --incorrect-color: #dc3545;
    --incorrect-border-color: #b21f2d;
    --option-bg: #e9ecef;
    --option-hover-bg: #d3d9df;
    --border-color: #dee2e6;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --pass-bg-color: #d4edda;
    --fail-bg-color: #f8d7da;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align to top for longer content */
    min-height: 100vh;
    transition: background-color 0.5s, color 0.5s;
    overflow-y: auto; /* Allow scrolling if content overflows */
}

/* Dark Theme */
body.theme-dark {
    --bg-color: #1a1a2e;
    --container-bg: #16213e;
    --text-color: #e0e0e0;
    --primary-color: #0f3460;
    --primary-hover: #1f5F8B;
    --secondary-color: #53728c;
    --secondary-hover: #769fcd;
    --correct-color: #33cc66; /* Adjusted for dark theme visibility */
    --correct-border-color: #28a351;
    --incorrect-color: #ff6666; /* Adjusted for dark theme visibility */
    --incorrect-border-color: #cc5151;
    --option-bg: #2c3e50;
    --option-hover-bg: #34495e;
    --border-color: #4b6580;
    --shadow-color: rgba(255, 255, 255, 0.05);
    --pass-bg-color: rgba(51, 204, 102, 0.2);
    --fail-bg-color: rgba(255, 102, 102, 0.2);
}

/* Neon Theme */
body.theme-neon {
    --bg-color: #000000;
    --container-bg: #111;
    --text-color: #00ffcc;
    --primary-color: #ff00ff; /* Magenta */
    --primary-hover: #cc00cc;
    --secondary-color: #00ffff; /* Cyan */
    --secondary-hover: #00cccc;
    --correct-color: #00ff00; /* Green */
    --correct-border-color: #00cc00;
    --incorrect-color: #ff3300; /* Red-Orange */
    --incorrect-border-color: #cc2200;
    --option-bg: #222;
    --option-hover-bg: #333;
    --border-color: #00ffcc;
    --shadow-color: rgba(0, 255, 204, 0.3);
    --pass-bg-color: rgba(0, 255, 0, 0.15);
    --fail-bg-color: rgba(255, 51, 0, 0.2);
    text-shadow: 0 0 3px var(--text-color);
}
body.theme-neon .quiz-header h1,
body.theme-neon .question-header h2,
body.theme-neon .results-area h2 {
    text-shadow: 0 0 5px var(--primary-color), 0 0 10px var(--primary-color);
}
body.theme-neon .option-btn,
body.theme-neon .nav-btn {
    border: 1px solid var(--secondary-color);
    box-shadow: 0 0 5px var(--secondary-color), inset 0 0 3px var(--secondary-color);
}
body.theme-neon .option-btn:hover {
    box-shadow: 0 0 10px var(--primary-color), inset 0 0 5px var(--primary-color);
}

/* Ocean Theme */
body.theme-ocean {
    --bg-color: #e0f7fa; /* Light cyan */
    --container-bg: #ffffff;
    --text-color: #004d40; /* Dark teal */
    --primary-color: #00796b; /* Teal */
    --primary-hover: #004d40;
    --secondary-color: #4db6ac; /* Medium teal */
    --secondary-hover: #26a69a;
    --correct-color: #388e3c; /* Green */
    --correct-border-color: #2e7d32;
    --incorrect-color: #d32f2f; /* Red */
    --incorrect-border-color: #c62828;
    --option-bg: #b2ebf2; /* Lighter cyan */
    --option-hover-bg: #80deea;
    --border-color: #4dd0e1;
    --shadow-color: rgba(0, 77, 64, 0.15);
    --pass-bg-color: rgba(56, 142, 60, 0.2);
    --fail-bg-color: rgba(211, 47, 47, 0.2);
}


.quiz-container {
    background-color: var(--container-bg);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px var(--shadow-color);
    width: 100%;
    max-width: 800px;
    text-align: center;
    transition: background-color 0.5s;
    animation: fadeIn 0.7s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
}

.quiz-header h1 {
    font-family: var(--font-display);
    color: var(--primary-color);
    font-size: 1.8em;
    margin: 0;
    animation: slideInFromLeft 0.5s ease-out;
}

@keyframes slideInFromLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

.theme-switcher {
    display: flex;
    gap: 8px;
}

.theme-btn {
    background-color: var(--option-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s;
    font-size: 1.2em;
}

.theme-btn:hover {
    background-color: var(--option-hover-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
}
.theme-btn.active {
    background-color: var(--primary-color);
    color: var(--container-bg); /* Ensure text is visible on active button */
    border-color: var(--primary-hover);
}
body.theme-dark .theme-btn.active { /* Specific fix for dark theme active button text */
    color: #e0e0e0;
}
body.theme-neon .theme-btn.active {
    color: #000; /* Or another contrasting color for Neon active */
}


.question-header {
    margin-bottom: 25px;
}

#question-text {
    font-size: 1.5em;
    margin-bottom: 20px;
    min-height: 60px; /* Ensure space for question */
    line-height: 1.6;
    animation: textAppear 0.6s ease-in-out;
}

@keyframes textAppear {
    from { opacity: 0; }
    to { opacity: 1; }
}

#progress-bar-container {
    width: 100%;
    background-color: var(--option-bg);
    border-radius: 5px;
    height: 10px;
    margin-bottom: 10px;
    overflow: hidden;
}

#progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 5px;
    transition: width 0.4s ease-in-out;
}

#question-counter {
    font-size: 0.9em;
    color: var(--secondary-color);
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.option-btn {
    background-color: var(--option-bg);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    padding: 15px;
    font-size: 1.1em;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.3s, border-color 0.3s, transform 0.2s, box-shadow 0.3s;
    animation: optionPopIn 0.3s ease-out backwards;
}
/* Staggered animation for options */
.options-grid .option-btn:nth-child(1) { animation-delay: 0.1s; }
.options-grid .option-btn:nth-child(2) { animation-delay: 0.2s; }
.options-grid .option-btn:nth-child(3) { animation-delay: 0.3s; }
.options-grid .option-btn:nth-child(4) { animation-delay: 0.4s; }


.option-btn:hover:not(:disabled) { /* Only apply hover effects if not disabled */
    background-color: var(--option-hover-bg);
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px var(--shadow-color);
}

.option-btn.correct {
    background-color: var(--correct-color) !important;
    color: white !important;
    border-color: var(--correct-border-color) !important;
    animation: pulseCorrect 0.5s;
}

.option-btn.incorrect {
    background-color: var(--incorrect-color) !important;
    color: white !important;
    border-color: var(--incorrect-border-color) !important;
    animation: shakeIncorrect 0.5s;
}

.option-btn:disabled {
    cursor: default;
    opacity: 0.8; /* Slightly fade disabled buttons */
}
.option-btn.correct:disabled, .option-btn.incorrect:disabled {
    opacity: 1; /* Keep full opacity for answered buttons */
}


@keyframes optionPopIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulseCorrect {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes shakeIncorrect {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

#explanation-area {
    background-color: var(--option-bg);
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    text-align: left;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.5s;
}

#explanation-area h3 {
    margin-top: 0;
    color: var(--primary-color);
}
#selected-option-text {
    font-weight: bold;
}
#arabic-explanation {
    font-size: 1.1em;
    line-height: 1.7;
    direction: rtl; /* Right-to-left for Arabic */
    text-align: right;
}

.navigation-buttons {
    margin-top: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 1.1em;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s;
    min-width: 120px; /* Ensure buttons have a decent size */
}

.nav-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--shadow-color);
}
.nav-btn:disabled {
    background-color: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.7;
}
#prev-btn {
    background-color: var(--secondary-color);
}
#prev-btn:hover {
    background-color: var(--secondary-hover);
}


#results-area {
    padding: 20px;
    animation: fadeIn 0.5s;
}
#results-area h2 {
    font-family: var(--font-display);
    color: var(--primary-color);
    margin-bottom: 20px;
}
.results-summary p {
    font-size: 1.2em;
    margin: 10px 0;
}
.results-summary strong {
    font-size: 1.3em;
    color: var(--primary-color);
}
#result-message {
    font-size: 1.2em;
    font-weight: bold;
    margin: 20px 0;
    padding: 15px;
    border-radius: 8px;
}
#result-message.pass {
    color: var(--correct-color);
    background-color: var(--pass-bg-color);
    border: 1px solid var(--correct-color);
}
#result-message.fail {
    color: var(--incorrect-color);
    background-color: var(--fail-bg-color);
    border: 1px solid var(--incorrect-color);
}

footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    animation: slideInFromBottom 0.5s ease-out 0.5s backwards;
    text-align: center; /* Crucial for centering the inline-flex container */
}

@keyframes slideInFromBottom {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.footer-author-container {
    display: inline-flex; /* Allows centering via text-align on parent and wraps image/text */
    align-items: center; /* Vertically aligns the image and text */
    gap: 10px; /* Adds a small space between your photo and your name */
}

.author-photo {
    width: 45px;  /* Adjust size if you want it bigger or smaller */
    height: 45px;
    border-radius: 50%; /* Makes the photo circular */
    object-fit: cover; /* Ensures your photo covers the area without distortion, cropping if necessary */
    border: 2px solid var(--primary-color); /* Adds a nice border using your theme's primary color */
    box-shadow: 0 2px 4px var(--shadow-color); /* Optional: adds a subtle shadow */
}

.footer-credit {
    font-size: 1em;
    color: var(--secondary-color);
    margin: 0; /* Removes default paragraph margin which can interfere with flex alignment */
}

.footer-credit .heart {
    display: inline-block;
    color: #e0245e; /* Twitter heart color or a general red */
    animation: heartBeat 1.5s infinite ease-in-out;
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.3); }
    28% { transform: scale(1); }
    42% { transform: scale(1.3); }
    70% { transform: scale(1); }
}


/* Utility for hiding elements */
.hidden {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .quiz-container {
        padding: 20px;
    }
    .quiz-header {
        flex-direction: column;
        gap: 15px;
    }
    .quiz-header h1 {
        font-size: 1.4em;
        text-align: center;
    }
    .theme-switcher {
        justify-content: center;
    }
    .options-grid {
        grid-template-columns: 1fr; /* Stack options on smaller screens */
    }
    .nav-btn {
        padding: 10px 18px;
        font-size: 1em;
        min-width: 100px;
    }
    #question-text {
        font-size: 1.3em;
    }
    /* .footer-author-container { Optional: stack on very small screens if needed */
        /* flex-direction: column; */
        /* gap: 5px; */
    /* } */
}
/* Add these new styles, preferably near the existing footer styles */

.footer-author-container {
    display: inline-flex; /* Allows centering via text-align on parent and wraps image/text */
    align-items: center; /* Vertically aligns the image and text */
    justify-content: center; /* Centers content if it was a block flex, but inline-flex handles this with parent's text-align */
    gap: 10px; /* Adds a small space between your photo and your name */
}

.author-photo {
    width: 60px;  /* تم تغييرها من 45px */
    height: 60px; /* تم تغييرها من 45px */
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
    box-shadow: 0 2px 4px var(--shadow-color);
}
/* .author-photo {
    width: 45px;  /* Adjust size if you want it bigger or smaller */
    /* height: 45px; */
    /* border-radius: 50%; Makes the photo circular */
    /* object-fit: cover; Ensures your photo covers the area without distortion, cropping if necessary */
    /* border: 2px solid var(--primary-color); Adds a nice border using your theme's primary color */
    /* box-shadow: 0 2px 4px var(--shadow-color); /* Optional: adds a subtle shadow   */
/* */

/* Adjust existing footer-credit style to ensure proper alignment as a flex item */
.footer-credit {
    font-size: 1em;
    color: var(--secondary-color);
    margin: 0; /* Removes default paragraph margin which can interfere with flex alignment */
}

/* Ensure the footer itself is still set up to center its content */
footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    animation: slideInFromBottom 0.5s ease-out 0.5s backwards;
    text-align: center; /* This is important for centering the inline-flex container */
}

/* The heart animation and other footer styles remain the same */
.footer-credit .heart {
    display: inline-block;
    color: #e0245e; /* Twitter heart color or a general red */
    animation: heartBeat 1.5s infinite ease-in-out;
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.3); }
    28% { transform: scale(1); }
    42% { transform: scale(1.3); }
    70% { transform: scale(1); }
}