/* Background Styles - School Themed */
:root {
    --bg-image-light: url('../images/bg_school.png');
    --bg-image-dark: url('../images/bg_classroom.png');
}

/* Hide the old animated gradient background to show our image */
.app-background {
    display: none !important;
}

/* Dark Theme: Classroom Background */
body.theme-dark {
    background-image: var(--bg-image-dark);
}

/* ==============================
   LIGHT MODE: GLOBAL VARIABLE OVERRIDE
   ============================== */
body.theme-light {
    /* Overwrite global variables from main.css */
    --primary-hue: 260;
    --bg-dark: #f8fafc;
    /* main.css: #0a0a0f */
    --bg-card: #ffffff;
    /* main.css: rgba(20, 20, 35, 0.8) */
    --text-light: #1a202c;
    /* main.css: #ffffff -> NOW DARK TEXT */
    --text-dim: #4a5568;
    /* main.css: #a0a0b0 */
    --text-muted: #718096;
    /* main.css: #606070 */

    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.1);

    /* Helper vars for specific overrides */
    --shadow-color: rgba(0, 0, 0, 0.1);
}

/* Apply image to light theme */
body.theme-light {
    background-image: var(--bg-image-light);
    color: var(--text-light);
    /* Enforce new text color */
}

/* Light Theme: School Campus Background */
body.theme-light {
    background-image: var(--bg-image-light);
    color: #1a202c;
}

/* Dark Theme: Classroom Background */
body.theme-dark {
    background-image: var(--bg-image-dark);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Light Theme: School Campus Background */
body.theme-light {
    background-image: var(--bg-image-light);
    color: #1a202c;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* ==============================
   LIGHT MODE: STRICT WHITE UI
   ============================== */
.theme-light .glass-container,
.theme-light .glass-panel,
.theme-light .glass-card,
.theme-light .main-header,
.theme-light .exam-footer {
    background: rgba(255, 255, 255, 0.95) !important;
    /* Almost solid white */
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    backdrop-filter: none;
    /* Remove glass blur for cleaner white look or keep it subtle */
}

/* Overrides for specific light mode elements text visibility */
.theme-light .grade-card h3,
.theme-light .title-gradient {
    /* Ensure text is readable/dark */
}

/* Fix Grade Card in Light Mode */
.theme-light .grade-card {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    color: #1a202c !important;
}

.theme-light .grade-card h3 {
    color: #2d3748 !important;
    /* Dark grey */
}

.theme-light .grade-card p {
    color: #4a5568 !important;
}

.theme-light .grade-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
    transform: translateY(-5px);
}

/* Fix Main Header in Light Mode */
.theme-light .main-header {
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0;
}

/* Fix Exam Number Cards */
.theme-light .exam-number-card {
    background: #f8fafc !important;
    border: 1px solid #cbd5e0 !important;
    color: #1a202c !important;
}

.theme-light .exam-number-card:hover {
    background: #edf2f7 !important;
    border-color: var(--primary-color) !important;
}

/* Fix Inputs */
.theme-light input,
.theme-light textarea {
    background: #ffffff !important;
    border: 1px solid #cbd5e0 !important;
    color: #1a202c !important;
}

/* ==============================
   ENHANCED THEME TOGGLE BUTTON
   ============================== */
#theme-toggle-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50px;
    backdrop-filter: blur(15px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.theme-light .theme-toggle {
    background: #ffffff;
    border-color: #e2e8f0;
}

/* ... keep previous toggle track styles but simplified ... */
/* ... keep previous toggle track styles but simplified ... */
.toggle-track {
    width: 50px;
    height: 26px;
    background: #1a202c;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
    position: relative;
    transition: all 0.3s ease;
}

.theme-light .toggle-track {
    background: #e2e8f0;
}

.toggle-thumb {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    top: 3px;
    left: 4px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-light .toggle-thumb {
    transform: translateX(22px);
    background: #f59e0b;
    /* Orange sun */
}

/* ==============================
   LIGHT MODE TEXT & LAYOUT FIXES
   ============================== */

/* Fix Header Buttons */
.theme-light .nav-btn {
    color: #4a5568 !important;
    border-color: transparent;
}

.theme-light .nav-btn:hover,
.theme-light .nav-btn.active {
    color: #1a202c !important;
    background: rgba(0, 0, 0, 0.05) !important;
}

/* Fix Welcome & Title */
.theme-light .welcome-section .subtitle {
    color: #4a5568 !important;
    font-weight: 500;
}

.theme-light .title-gradient {
    /* Darker gradient for white background */
    background: linear-gradient(135deg,
            #2d3748 0%,
            #6b46c1 40%,
            #d53f8c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: none !important;
    /* Remove glow to improve readability */
}

/* Fix Grade Grid Layout */
.grade-grid {
    justify-content: center;
    /* Center items if they don't fill row */
}

.theme-light .grade-grid {
    /* Ensure proper spacing in light mode */
}

/* Fix Grade Card Content */
.theme-light .grade-card .icon,
/* If icon is class name */
.theme-light .card-icon {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Fix Input Text Color - CRITICAL */
.theme-light input,
.theme-light textarea,
.theme-light select {
    color: #1a202c !important;
    background-color: #ffffff !important;
}

.theme-light ::placeholder {
    color: #a0aec0 !important;
}

/* Fix Admin/User Greeting */
.theme-light .user-welcome {
    color: #2d3748 !important;
}

.theme-light .box-title {
    color: #2d3748 !important;
}

/* Fix Exam Grid & Cards */
.theme-light .exam-number-card {
    color: #2d3748 !important;
    font-weight: 700;
}

.theme-light .exam-number-card span {
    color: #718096 !important;
}

/* Mobile Responsive Media Queries - Keep existing logic */
@media (max-width: 768px) {

    /* ... reuse existing mobile styles ... */
    #theme-toggle-container {
        top: auto;
        bottom: 1rem;
        right: 1rem;
    }
}