/* --- THEME COLOR PALETTES --- */
:root {
    /* Light Theme (Default) */
    --primary-color: #4A90E2;
    --secondary-color: #50E3C2;
    --background-color: #F4F7FC; /* Very light gray/blue */
    --surface-color: #FFFFFF; /* White cards */
    --text-color: #4A4A4A; /* Dark Gray, not black */
    --heading-color: #0D2240; /* Very Dark Blue */
    --border-color: #E0E7FF;
    --danger-color: #D0021B;
    --shadow-color: rgba(74, 144, 226, 0.1);
}

body.dark-theme {
    /* Dark Theme Overrides */
    --primary-color: #50E3C2; /* Bright Teal becomes primary */
    --secondary-color: #4A90E2; /* Blue becomes secondary */
    --background-color: #121212; /* Off-black for background */
    --surface-color: #1E1E1E; /* Dark gray for cards */
    --text-color: #E0E0E0; /* Light gray for text */
    --heading-color: #FFFFFF; /* White for headings */
    --border-color: #333333;
    --danger-color: #FF5252;
    --shadow-color: rgba(0, 0, 0, 0.2);
}

/* In /css/style.css (at the bottom) */

/* ========================================= */
/* === QUIZ SELECTION FEEDBACK STYLES      === */
/* ========================================= */

/* This is the style for the initial, bright flash */
.option-btn.flash {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
    transition: background-color 0.1s, color 0.1s; /* Add a very quick transition */
}

/* Dark mode version of the flash */
body.dark-theme .option-btn.flash {
    color: #000 !important; /* Black text on bright background for contrast */
}
/* In /css/style.css (at the bottom) */

/* Style for the selection check mark */
.selection-check {
    font-size: 1rem; /* Match the font size of the button text */
    color: var(--success-color); /* Use the theme's success color */
}

body.dark-theme .selection-check {
    color: var(--success-color);
}

/* In /css/style.css */

.timer-display {
    display: flex; /* Use flexbox for alignment */
    justify-content: space-between; /* Pushes total time left and question time right */
    font-size: 1.1rem;
    font-weight: 600;
    width: 200px; /* Give it a fixed width to prevent layout shifts */
    color: var(--text-color);
}

.timer-display .question-timer {
    color: var(--primary-color); /* Highlight the countdown */
}
/* In /css/style.css (add to the navigation section) */

.nav-balance {
    font-weight: 600;
    color: var(--success-color);
    background-color: var(--success-background);
    padding: 5px 10px;
    border-radius: 20px;
    margin-right: 15px;
    font-size: 0.9rem;
}
.nav-balance i {
    margin-right: 5px;
}
/* This is the style for the persistent selected state (after the flash) */
.option-btn.selected {
    border-color: var(--primary-color) !important;
    background-color: #E9F2FC !important; /* Light blue background */
    color: var(--text-color) !important;
}

/* Dark mode version of the persistent selected state */
body.dark-theme .option-btn.selected {
    background-color: #2a3b50 !important; /* Dark blue background */
    color: var(--text-color) !important;
}
/* In /css/style.css (add to the very bottom) */

/* ========================================= */
/* === DARK THEME VISIBILITY FIXES         === */
/* ========================================= */

body.dark-theme {
    /* --- Force Text Colors --- */
    /* This is a powerful rule that sets the base text color for almost everything */
    color: var(--text-color);
}

body.dark-theme h1,
body.dark-theme h2,
body.dark-theme h3,
body.dark-theme h4,
body.dark-theme h5,
body.dark-theme h6 {
    /* Ensure all headings use the correct heading color */
    color: var(--heading-color);
}

/* --- Fix for Link Colors (Very Important) --- */
/* By default, links have their own color that doesn't follow the body text color. */
body.dark-theme a {
    color: var(--primary-color); /* Use the primary color (Bright Teal) for links */
    text-decoration: none;
}

body.dark-theme a:hover {
    color: var(--secondary-color); /* Use the secondary color (Blue) for hover */
}

/* --- Specific Component Fixes --- */

/* Ensure navigation links are correct */
body.dark-theme .nav-menu a {
    color: var(--text-color); /* Use the main text color for nav links */
}
body.dark-theme .nav-menu a:hover {
    color: var(--primary-color);
}
body.dark-theme .nav-logo {
    color: var(--heading-color);
}

/* Fix text inside buttons that might not be inheriting color */
body.dark-theme .btn-secondary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}
body.dark-theme .btn-secondary:hover {
    background-color: var(--primary-color);
    color: #000; /* Use black text on the bright teal background for contrast */
}

/* Ensure text in list items is correct */
body.dark-theme .list-item span {
    color: var(--text-color);
    opacity: 0.8; /* Make secondary text slightly less prominent */
}

/* Ensure form labels and input text are visible */
body.dark-theme .form-group label {
    color: var(--heading-color);
}
body.dark-theme .form-control {
    background-color: var(--background-color);
    border-color: var(--border-color);
    color: var(--text-color);
}

/* Ensure placeholder text is visible */
body.dark-theme .form-control::placeholder {
    color: #6c757d !important;
}
body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: 'Poppins', sans-serif;
    margin: 0;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

/* --- Cards & General Layout --- */
/* Find this rule in your CSS */
.card, .form-container, .list-item, .feature-card, .profile-container, .admin-card, .quiz-container {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    /* UPDATE THIS LINE */
    box-shadow: 0 4px 12px var(--shadow-color);
    padding: 30px;
    margin-bottom: 20px;
}

h1, h2, h3 { color: var(--heading-color); }
h1 { font-size: 2.5rem; margin-bottom: 1rem; }
h2 { font-size: 2rem; margin-bottom: 1rem; }

/* --- Navigation (Mobile First with Menu Button) --- */
.navbar {
    background-color: var(--surface-color);
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 auto;
    position: relative;
}

.nav-logo {
    font-size: 1.5rem; font-weight: 700; color: var(--heading-color);
    text-decoration: none; z-index: 10;
}

/* --- Mobile Toggle Buttons --- */
.mobile-toggles { display: flex; gap: 10px; }
.menu-toggle {
    display: block; /* Show buttons on mobile */
    background-color: transparent; border: 2px solid var(--border-color);
    padding: 5px 15px; border-radius: 8px; font-weight: 600;
    color: var(--heading-color); cursor: pointer; z-index: 10;
}
.user-avatar-toggle { width: 24px; height: 24px; border-radius: 50%; vertical-align: middle; }

/* --- Menu Containers (Hidden on Mobile by default) --- */
.nav-menu-container {
    position: absolute; top: calc(100% + 10px);
    width: 200px; background-color: var(--surface-color);
    border: 1px solid var(--border-color); border-radius: 8px;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.1);
    max-height: 0; overflow: hidden;
    transition: max-height 0.3s ease-in-out, opacity 0.3s; opacity: 0;
}
#main-menu-container { right: 0; }
#user-menu-container { right: 0; }

.nav-menu-container.active { max-height: 500px; opacity: 1; }

.nav-menu {
    list-style: none; padding: 10px; margin: 0;
    display: flex; flex-direction: column; gap: 5px;
}
.nav-menu a {
    color: var(--text-color); text-decoration: none; font-weight: 500;
    padding: 8px 12px; border-radius: 6px; display: block;
    transition: background-color 0.2s, color 0.2s;
}
.nav-menu a:hover { background-color: var(--background-color); color: var(--primary-color); }
.nav-menu .btn { text-align: center; }

/* Hide/Show specific links for mobile/desktop */
.profile-link-mobile { display: block; }
.profile-link-desktop { display: none; }
.user-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; margin-left: 10px; }


/* --- Desktop Styles (Breakpoint) --- */
@media (min-width: 992px) {
    .mobile-toggles { display: none; } /* Hide mobile buttons on desktop */

    .nav-menu-container {
        /* Reset all mobile positioning and styles */
        position: static; max-height: none; width: auto;
        border: none; box-shadow: none; opacity: 1;
        overflow: visible;
    }
        .nav-menu {
        flex-direction: row;
        align-items: center; /* Make sure this is present */
        padding: 0;
        gap: 25px;
    }

    /* --- ADD THIS NEW RULE --- */
    /* This ensures the toggle aligns nicely with other items on desktop */
    .theme-switch-wrapper {
        margin: 0;
    }
    
    /* We have two containers, so we need to merge them on desktop */
    .navbar .container {
        /* This is a trick to get all nav items in a row */
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
    }
    
    #main-menu-container { justify-self: start; margin-left: 40px; }
    #user-menu-container { justify-self: end; }
    
    .nav-menu {
        flex-direction: row; align-items: center;
        padding: 0; gap: 25px;
    }

    /* Hide/Show specific links for mobile/desktop */
    .profile-link-mobile { display: none; }
    .profile-link-desktop { display: flex; align-items: center; }
}
/* --- Buttons --- */
.btn { display: inline-block; padding: 10px 20px; border-radius: 8px; text-decoration: none; font-weight: 600; transition: all 0.3s ease; border: none; cursor: pointer; text-align: center; }
.btn-primary { background-color: var(--primary-color); color: #fff; }
.btn-primary:hover { background-color: #357ABD; }
.btn-secondary { background-color: transparent; color: var(--primary-color); border: 2px solid var(--primary-color); padding: 8px 18px;}
.btn-secondary:hover { background-color: var(--primary-color); color: #fff; }
.btn-danger { background-color: var(--danger-color); color: white;}
.btn-large { padding: 15px 30px; font-size: 1.1rem; }
.btn-small { padding: 5px 10px; font-size: 0.8rem; }

/* --- Forms --- */
.form-container { max-width: 500px; margin: 40px auto; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: var(--heading-color); }
.form-control { width: 100%; padding: 12px; border: 1px solid var(--border-color); border-radius: 8px; color: var(--text-color); font-size: 1rem; box-sizing: border-box; }
textarea.form-control { min-height: 150px; resize: vertical; }
.form-container p { text-align: center; }
.form-container a { color: var(--primary-color); text-decoration: none; font-weight: 600; }

/* --- Messages --- */
.message { padding: 15px; margin-bottom: 20px; border-radius: 8px; text-align: center; font-weight: 500; }
.message.success { background-color: #E4F8F0; color: #00B074; border: 1px solid #50E3C2;}
.message.error { background-color: #FDEDED; color: var(--danger-color); border: 1px solid var(--danger-color); }

/* --- Profile Page --- */
.profile-container { display: flex; align-items: flex-start; gap: 40px; }
.profile-avatar img { width: 120px; height: 120px; border-radius: 50%; border: 4px solid var(--primary-color); object-fit: cover; }
.profile-details { flex-grow: 1; }

/* --- Dashboard --- */
.list-item { display: flex; justify-content: space-between; align-items: center; }
.list-item-content { flex-grow: 1; }
.list-item-actions { display: flex; gap: 10px; }

/* --- Dynamic Quiz --- */
.quiz-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.progress-container { width: 80%; height: 10px; background-color: var(--border-color); border-radius: 5px; }
.progress-bar { height: 100%; width: 0%; background-color: var(--primary-color); border-radius: 5px; transition: width 0.4s ease; }
.timer-display { font-size: 1.1rem; font-weight: 600; color: var(--primary-color); }
#question-text { font-size: 1.8rem; margin-bottom: 2rem; text-align: center; }
.options-list { list-style:none; padding:0; display: grid; grid-template-columns: 1fr; gap: 15px; margin-bottom: 2rem; }
.option-btn { width: 100%; padding: 15px; background: var(--surface-color); border: 2px solid var(--border-color); color: var(--text-color); font-size: 1rem; border-radius: 8px; cursor: pointer; text-align: left; transition: all 0.3s; }
.option-btn:hover:not(:disabled) { border-color: var(--primary-color); background-color: #F4F7FC; }
.option-btn.correct { background-color: var(--secondary-color) !important; border-color: var(--secondary-color) !important; color: #fff; }
.option-btn:disabled { cursor: not-allowed; opacity: 0.7; }

/* --- Admin --- */
.admin-container { max-width: 1400px; }
.admin-nav { background-color: var(--heading-color); padding: 1rem; border-radius: 12px; margin-bottom: 20px; }
.admin-nav ul { list-style: none; padding: 0; margin: 0; display: flex; justify-content: center; gap: 30px; }
.admin-nav a { color: white; text-decoration: none; font-weight: 600; font-size: 1.1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
th { color: var(--heading-color); }
.avatar-small { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }

/* --- Footer --- */
.site-footer { text-align: center; padding: 2rem 0; margin-top: 40px; border-top: 1px solid var(--border-color); color: #aaa; }





/* --- THEME TOGGLE SWITCH STYLES --- */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    margin-left: 15px; /* Give it some space on desktop */
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider .sun-icon, .slider .moon-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    opacity: 1;
    transition: opacity 0.4s;
}

.slider .sun-icon { left: 8px; }
.slider .moon-icon { right: 8px; }

/* Hide the icon that is not active */
input:not(:checked) + .slider .moon-icon { opacity: 0; }
input:checked + .slider .sun-icon { opacity: 0; }






/* --- GOOGLE TRANSLATE WIDGET STYLES --- */
/* This container will hold the dropdown */
#google_translate_element_desktop {
    display: none; /* Hidden on mobile */
}

#google_translate_element_mobile {
    display: block; /* Shown on mobile */
    padding: 8px 12px;
}

.goog-te-combo {
    /* Style the dropdown itself */
    background-color: var(--surface-color);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
}

/* Hide the top banner and original Google branding */
body { top: 0 !important; }
.skiptranslate { display: none !important; }
#goog-gt-tt { display: none !important; }

/* Desktop styles */
@media (min-width: 992px) {
    #google_translate_element_desktop {
        display: block; /* Show on desktop */
    }
    #google_translate_element_mobile {
        display: none; /* Hide mobile container */
    }
    /* Adjust the grid to add a new column for the translator */
    .navbar .container {
        grid-template-columns: auto 1fr auto auto auto; /* Logo | Main | Translate | Theme | User */
    }
    #google_translate_element_desktop { grid-column: 3 / 4; justify-self: end; }
    .theme-switch-wrapper-desktop { grid-column: 4 / 5; justify-self: end; }
    #user-menu-container { grid-column: 5 / 6; justify-self: end; }
}




/* --- QUIZ ANSWER KEY STYLES --- */
.answer-key-list {
    list-style: none;
    padding: 0;
    margin-top: 10px;
}

.answer-key-list li {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    background-color: var(--surface-color);
}

.answer-key-list li.correct-answer {
    background-color: #E4F8F0; /* Light green */
    border-color: var(--secondary-color);
    color: #00B074;
    font-weight: 600;
}

body.dark-theme .answer-key-list li.correct-answer {
    background-color: #1A3E36; /* Dark green for dark mode */
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* In /css/style.css (at the bottom) */

/* ========================================= */
/* === ACTIONS DROPDOWN MENU STYLES        === */
/* ========================================= */

.list-item-actions {
    /* This container needs to be relative so we can position the menu inside it. */
    position: relative;
}

.actions-dropdown {
    display: inline-block;
}

.actions-menu {
    /* THIS IS THE CRITICAL RULE THAT HIDES THE MENU BY DEFAULT */
    display: none;

    /* Positioning styles */
    position: absolute;
    right: 0;
    top: 110%; /* Position it just below the "Actions" button */
    z-index: 100;

    /* Appearance styles */
    background-color: var(--surface-color);
    min-width: 180px;
    box-shadow: 0 8px 16px var(--shadow-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden; /* Important for the border-radius on children */
    padding: 5px 0; /* Add some vertical padding */
}

/* THIS IS THE RULE THAT SHOWS THE MENU WHEN JAVASCRIPT ADDS THE 'active' CLASS */
.actions-menu.active {
    display: block;
}

.actions-menu-item {
    color: var(--text-color);
    padding: 10px 15px; /* Adjust padding for a cleaner look */
    text-decoration: none;
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    display: flex; /* Use flex to align icon and text */
    align-items: center;
    gap: 10px; /* Space between icon and text */
}

.actions-menu-item:hover {
    background-color: var(--background-color);
    color: var(--primary-color);
}

body.dark-theme .actions-menu-item:hover {
    background-color: #2c2c2c; /* Slightly lighter gray for hover in dark mode */
}

.actions-menu-item.danger-item {
    color: var(--danger-color);
}

.actions-menu-item.danger-item:hover {
    background-color: #FDEDED;
    color: #a00014;
}

body.dark-theme .actions-menu-item.danger-item:hover {
    background-color: #4d1a1f;
    color: #ff8a80;
}


/* Make sure the form inside the dropdown doesn't add extra space */
.actions-menu form {
    margin: 0;
}

/* Style for icons inside the menu items */
.actions-menu-item i {
    width: 16px; /* Give icons a fixed width for alignment */
    text-align: center;
}


