:root {
    /* Base Colors - Optimized for Warm/Friendly Aesthetic (sbackimg.png) */
    --bg-color: #FFF9F2; /* Soft Cream */
    --text-color: #5D4037; /* Warm Brown */
    --primary-color: #FFB74D; /* Warm Orange */
    --secondary-color: #4DB6AC; /* Soft Teal */
    
    /* Layout */
    --header-bg: #FFB74D;
    --header-text: #ffffff;
    --sidebar-bg: #ffffff;
    --sidebar-border: #FFE0B2;
    
    /* Components */
    --card-bg: #ffffff;
    --card-border: #FFCC80;
    --card-shadow: rgba(93, 64, 55, 0.1);
    
    /* Inputs */
    --input-bg: #ffffff;
    --input-border: #BCAAA4;
    --input-focus: #FFB74D;
    
    /* Menu Items (Themed Colors) */
    --menu-home: #FFB74D;
    --menu-notice: #FF8A65;
    --menu-read: #81C784;
    --menu-makeup: #F06292;
    --menu-history: #9575CD;
    --menu-rank: #FFD54F;
    --menu-profile: #4DB6AC;
    
    --header-height: 60px;
    --sidebar-width: 250px;
    --border-radius: 16px; /* More rounded for friendly feel */
}

[data-theme="night"] {
    --bg-color: #2D2420; /* Dark Warm Brown */
    --text-color: #EFEBE9;
    --primary-color: #FF9800;
    
    --header-bg: #3E2723;
    --header-text: #EFEBE9;
    --sidebar-bg: #3E2723;
    --sidebar-border: #4E342E;
    
    --card-bg: #3E2723;
    --card-border: #5D4037;
    --card-shadow: rgba(0,0,0,0.4);
    
    --input-bg: #4E342E;
    --input-border: #6D4C41;
    --input-focus: #FF9800;

    --menu-home: #FFB74D;
    --menu-notice: #FFAB91;
    --menu-read: #A5D6A7;
    --menu-makeup: #F48FB1;
    --menu-history: #B39DDB;
    --menu-rank: #FFE082;
    --menu-profile: #80CBC4;
}

[data-theme="future"] {
    /* Softer, readable Space Theme */
    --bg-color: #0f172a; /* Deep Slate Blue */
    --text-color: #e2e8f0; /* Soft White */
    --primary-color: #38bdf8; /* Sky Blue */
    
    --header-bg: #1e293b; /* Dark Slate */
    --header-text: #f1f5f9;
    --sidebar-bg: #1e293b;
    --sidebar-border: #334155; /* Muted Blue-Grey */
    
    --card-bg: #1e293b;
    --card-border: #334155;
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    
    --input-bg: #0f172a;
    --input-border: #475569;
    --input-focus: #38bdf8;

    /* Menu Colors - Softened for dark background */
    --menu-home: #60a5fa;
    --menu-notice: #fbbf24;
    --menu-read: #4ade80;
    --menu-makeup: #f87171;
    --menu-history: #c084fc;
    --menu-rank: #facc15;
    --menu-profile: #2dd4bf;
}

body {
    margin: 0;
    font-family: 'Comic Sans MS', 'Chalkboard SE', 'Microsoft JhengHei', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

/* Header */
.student-header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 0 20px;
    height: var(--header-height);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background 0.3s, color 0.3s;
}

.site-title {
    font-size: 24px;
    font-weight: bold;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--header-text);
    font-size: 24px;
    cursor: pointer;
}

/* PC Info in Header */
.header-info {
    display: flex;
    gap: 15px;
    font-size: 14px;
}

.header-info div {
    background: rgba(255,255,255,0.2);
    padding: 5px 10px;
    border-radius: 15px;
}

/* Layout */
.student-wrapper {
    display: flex;
    flex: 1;
}

/* Sidebar */
.student-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 2px solid var(--sidebar-border);
    padding: 20px;
    box-sizing: border-box;
    transition: transform 0.3s ease, background 0.3s, border-color 0.3s;
}

.student-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.student-menu li {
    margin-bottom: 10px;
}

/* Menu Buttons Style */
.student-menu li a {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 12px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 16px;
    border-radius: 15px;
    background: var(--card-bg);
    border: 2px solid transparent;
    box-shadow: 0 2px 5px var(--card-shadow);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-weight: bold;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.student-menu li a i {
    margin-right: 12px;
    font-size: 1.2em;
    width: 25px;
    text-align: center;
    transition: color 0.3s;
}

/* Hover & Active Effects */
.student-menu li a:hover, .student-menu li a.active {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 5px 15px var(--card-shadow);
    color: white; /* Keep white for hover text on colored bg */
}

/* Specific Theme Overrides for Menu Text Color on Hover */
[data-theme="future"] .student-menu li a:hover, 
[data-theme="future"] .student-menu li a.active {
    color: #000;
}


.student-menu li a:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 2px 5px var(--card-shadow);
}

/* Distinct Colors for Each Menu Item using Variables */
/* Home */
.menu-home { border-color: var(--menu-home) !important; color: var(--menu-home) !important; }
.menu-home i { color: var(--menu-home); }
.menu-home:hover, .menu-home.active { background: var(--menu-home) !important; color: white !important; }
.menu-home:hover i, .menu-home.active i { color: white; }

/* Notice */
.menu-notice { border-color: var(--menu-notice) !important; color: var(--menu-notice) !important; }
.menu-notice i { color: var(--menu-notice); }
.menu-notice:hover, .menu-notice.active { background: var(--menu-notice) !important; color: white !important; }
.menu-notice:hover i, .menu-notice.active i { color: white; }

/* Read */
.menu-read { border-color: var(--menu-read) !important; color: var(--menu-read) !important; }
.menu-read i { color: var(--menu-read); }
.menu-read:hover, .menu-read.active { background: var(--menu-read) !important; color: white !important; }
.menu-read:hover i, .menu-read.active i { color: white; }

/* Makeup */
.menu-makeup { border-color: var(--menu-makeup) !important; color: var(--menu-makeup) !important; }
.menu-makeup i { color: var(--menu-makeup); }
.menu-makeup:hover, .menu-makeup.active { background: var(--menu-makeup) !important; color: white !important; }
.menu-makeup:hover i, .menu-makeup.active i { color: white; }

/* History */
.menu-history { border-color: var(--menu-history) !important; color: var(--menu-history) !important; }
.menu-history i { color: var(--menu-history); }
.menu-history:hover, .menu-history.active { background: var(--menu-history) !important; color: white !important; }
.menu-history:hover i, .menu-history.active i { color: white; }

/* Rank */
.menu-rank { border-color: var(--menu-rank) !important; color: var(--menu-rank) !important; }
.menu-rank i { color: var(--menu-rank); }
.menu-rank:hover, .menu-rank.active { background: var(--menu-rank) !important; color: white !important; }
.menu-rank:hover i, .menu-rank.active i { color: white; }

/* Profile */
.menu-profile { border-color: var(--menu-profile) !important; color: var(--menu-profile) !important; }
.menu-profile i { color: var(--menu-profile); }
.menu-profile:hover, .menu-profile.active { background: var(--menu-profile) !important; color: white !important; }
.menu-profile:hover i, .menu-profile.active i { color: white; }

/* Removed Future Theme Text Color Override - Now using white text on soft colors */


/* Mobile Info in Sidebar */
.sidebar-info {
    display: none;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px dashed var(--sidebar-border);
}

.sidebar-info div {
    margin-bottom: 5px;
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.8;
}

/* Content */
.student-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    min-width: 0; /* Prevent flex items from overflowing */
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.content-card {
    background: var(--card-bg);
    border: 3px solid var(--card-border);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 5px 15px var(--card-shadow);
    margin-bottom: 25px;
    transition: background 0.3s, border-color 0.3s;
}

.content-card h2 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--sidebar-border);
    padding-bottom: 10px;
    margin-top: 0;
}

/* Forms */
form {
    border: 2px solid var(--input-border);
    padding: 20px;
    border-radius: 15px;
    background: var(--card-bg);
    margin-bottom: 20px;
}

input[type="text"], input[type="password"], input[type="number"], select, textarea {
    border: 2px solid var(--input-border); 
    border-radius: 8px;
    padding: 10px;
    font-size: 16px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.3s;
    background: var(--input-bg);
    color: var(--text-color);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--input-focus);
    outline: none;
    box-shadow: 0 0 5px rgba(74, 180, 245, 0.5); /* Maybe variable-ize shadow too? */
}

[data-theme="future"] input:focus, [data-theme="future"] select:focus, [data-theme="future"] textarea:focus {
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

/* Theme Switcher */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    margin-left: 15px;
}

.theme-switch-select {
    padding: 5px 10px;
    border-radius: 15px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: var(--header-text);
    font-size: 14px;
    cursor: pointer;
    outline: none;
}
.theme-switch-select option {
    background: var(--bg-color);
    color: var(--text-color);
}

/* Login Page Refactor */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: url('/uploads/images/kidback.png') no-repeat center center fixed;
    background-size: cover;
    padding: 20px;
}
/* Note: Login page might not use theme variables if it doesn't include header/theme logic yet,
   but it likely shares this CSS. For now, leaving login hardcoded or lightly adapted.
   Ideally, login should also support themes if user preference is stored, but usually login is default. */

.login-wrapper {
    display: flex;
    /* background: white; */
    border-radius: 20px;
    /* box-shadow: 0 10px 30px rgba(0,0,0,0.1); */
    overflow: hidden;
    max-width: 600px;
    width: 100%;
    transform: translateX(-150px);
}

.login-left-panel {
    /* background: #f0f0f0; */
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 15px;
    /* border-right: 2px solid #ddd; */
}

.side-btn {
    width: 120px;
    height: 120px;
    border: none;
    border-radius: 15px;
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
}

.side-btn:hover { transform: scale(1.05); }

.btn-red { background: #ff7043; }
.btn-orange { background: #ffa726; }
.btn-yellow { background: #ffee58; color: #555; }
.btn-green { background: #66bb6a; }

.login-box {
    flex: 1;
    padding: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-box h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 40px;
}

.login-input {
    width: 80% !important;
    margin: 0 auto 15px auto;
    display: block;
}

.login-btn {
    width: 50% !important;
    margin: 10px auto 0 auto;
    display: block;
}

.login-logo {
    text-align: center;
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    margin-top: 10px;
}

/* Article Page Styles */
.article-title {
    text-align: center;
    color: var(--text-color);
    margin-bottom: 5px;
}

.article-meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-color);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--sidebar-border);
    padding-bottom: 10px;
    opacity: 0.8;
}

.article-content {
    font-size: 18px;
    line-height: 1.8;
    color: var(--text-color);
    margin-bottom: 30px;
}

.audio-section {
    background: rgba(0,0,0,0.05);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 30px;
}

[data-theme="night"] .audio-section,
[data-theme="future"] .audio-section {
    background: rgba(255,255,255,0.05);
}

.section-title {
    margin-top: 0;
    color: var(--text-color);
}

.audio-player {
    width: 100%;
    margin-bottom: 10px;
}

.audio-playlist {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.audio-btn {
    background: var(--sidebar-border);
    color: var(--text-color);
    padding: 5px 10px;
    font-size: 12px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.audio-btn:hover {
    filter: brightness(0.9);
}

.questions-section {
    margin-bottom: 30px;
}

.question-item {
    margin-bottom: 20px;
    background: var(--card-bg);
    border: 1px solid var(--sidebar-border);
    padding: 15px;
    border-radius: 8px;
}

.question-text {
    font-weight: bold;
    margin-top: 0;
    color: var(--text-color);
}

.option-label {
    display: block;
    margin-bottom: 5px;
    cursor: pointer;
    color: var(--text-color);
}

.submit-btn {
    background: #28a745;
    color: white;
    width: 100%;
    padding: 15px;
    font-size: 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.submit-btn:hover {
    background: #218838;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 998;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .menu-toggle { display: block; }
    
    .header-info { display: none; } 
    
    .student-sidebar {
        position: fixed;
        left: 0;
        top: var(--header-height);
        height: calc(100vh - var(--header-height));
        width: 80%;
        max-width: 300px;
        transform: translateX(-100%); 
        opacity: 0; 
        z-index: 999;
        box-shadow: 2px 0 5px var(--card-shadow);
        transition: transform 0.3s ease, opacity 0.3s ease, background 0.3s; 
    }
    
    .student-sidebar.active {
        transform: translateX(0); 
        opacity: 1; 
    }
    
    .sidebar-info { display: block; }
    
    .sidebar-overlay { display: none; }
    .student-sidebar.active ~ .sidebar-overlay { display: block; }
    
    .student-content {
        padding: 15px;
        width: 100%;
        box-sizing: border-box;
    }

    .content-card {
        padding: 15px;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    table {
        min-width: 500px !important; /* Ensure table doesn't squash too much */
    }
    
    /* Login Mobile */
    .login-container {
        align-items: flex-start; 
        padding-top: 50px;
        flex-direction: column;
    }
    
    .login-wrapper {
        flex-direction: column;
        max-width: 400px;
        background: transparent;
        box-shadow: none;
    }
    
    .login-left-panel {
        display: none; 
    }
    
    .login-box {
        /* background: white; */
        border-radius: 20px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        padding: 30px;
        width: 90%;
        margin: 0 auto;
    }
    
    .login-box h1 { margin-bottom: 20px; }

    .login-container {
        background: url('/uploads/images/kidmobloginback.png') no-repeat center center fixed;
        background-size: cover;
        align-items: center;
        padding-top: 0;
    }

    .login-wrapper {
        transform: none;
        align-items: center;
        justify-content: center;
    }

    .login-logo {
        margin: 0 auto 20px auto;
    }
}
