/* Font Definitions */
@font-face {
    font-family: 'KhmerOS_battambang';
    src: url('/assets/fonts/KhmerOS_battambang.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'KhmerOS_muollight';
    src: url('/assets/fonts/KhmerOS_muollight.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Times New Roman';
    src: url('/assets/fonts/Times New Roman.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
}

/* Global Language Based Font Application */

/* Khmer Language - /km */
html[lang="km"] body, html[lang="kh"] body {
    font-family: 'KhmerOS_battambang', sans !important;
}

html[lang="km"] h1, html[lang="km"] h2, html[lang="km"] h3, html[lang="km"] h4, html[lang="km"] h5, html[lang="km"] h6,
html[lang="kh"] h1, html[lang="kh"] h2, html[lang="kh"] h3, html[lang="kh"] h4, html[lang="kh"] h5, html[lang="kh"] h6 {
    font-family: 'KhmerOS_muollight', serif !important;
}

/* English and others - /en, /cn, /ja, etc. */
html[lang="en"] body, html[lang="cn"] body, html[lang="ja"] body, html[lang="zh"] body, html[lang="jp"] body {
    font-family: 'Times New Roman', serif !important;
}

html[lang="en"] h1, html[lang="en"] h2, html[lang="en"] h3, html[lang="en"] h4, html[lang="en"] h5, html[lang="en"] h6 {
    font-family: 'Times New Roman', serif !important;
}

:root {
    /* Color Palette */
    --primary: #0066cc;
    --primary-light: #e6f0ff;
    --secondary: #00c6ff;
    --accent: #6225e6;
    --success: #10b981;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    
    /* UI Colors */
    --dark: #1e293b;
    --gray: #64748b;
    --light: #f8fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    
    /* Dimensions */
    --sidebar-width: 280px;
    --header-height: 70px;
    
    /* Effects */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --bg-body: #f1f5f9;
    --text-main: #1e293b;
}

/* --- DARK MODE OVERRIDES --- */
body.dark-mode {
    --light: #0f172a;
    --white: #1e293b;
    --border: #334155;
    --text-main: #f1f5f9;
    --gray: #94a3b8;
    --bg-body: #020617;
}

body.dark-mode .sidebar, 
body.dark-mode header, 
body.dark-mode .card, 
body.dark-mode .modal, 
body.dark-mode .module-card, 
body.dark-mode .login-card {
    background-color: var(--white);
    border-color: var(--border);
    color: var(--text-main);
}
body.dark-mode .submenu { background: #131c2e; }
body.dark-mode th { background: #0f172a; color: var(--gray); }
body.dark-mode input, body.dark-mode select, body.dark-mode textarea { 
    background: #0f172a; 
    border-color: var(--border); 
    color: white; 
}
body.dark-mode .sub-nav-item:hover { background: #0f172a; color: white; }
body.dark-mode .nav-header:hover { color: var(--secondary); }

/* --- RESET & BASE --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background-color: var(--bg-body); color: var(--text-main); height: 100vh; overflow: hidden; transition: background-color 0.3s, color 0.3s; }

/* --- UTILITIES --- */
.glass {
    background: rgba(255, 255, 255, 0.45) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07) !important;
}

body.dark-mode .glass {
    background: rgba(15, 23, 42, 0.65) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.glass-card {
    background: rgba(255, 255, 255, 0.6) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: 12px;
}

body.dark-mode .glass-card {
    background: rgba(30, 41, 59, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.text-sm { font-size: 0.875rem; }
.font-bold { font-weight: 700; }
.text-gray { color: var(--gray); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.justify-center { justify-content: center; }

/* --- BUTTONS --- */
.btn {
    padding: 8px 14px; border-radius: 6px; border: none; cursor: pointer;
    font-weight: 500; font-size: 12px; display: inline-flex; align-items: center; gap: 6px;
    transition: all 0.2s; text-decoration: none; border: 1px solid transparent;
    white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white; box-shadow: 0 4px 6px rgba(0,102,204,0.2);
}
.btn-primary:hover { transform: translateY(-1px); opacity: 0.95; box-shadow: 0 6px 8px rgba(0,102,204,0.3); }
.btn-outline { border-color: var(--border); background: transparent; color: var(--text-main); }
.btn-outline:hover { background: var(--light); border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background-color: #dc2626; }
.btn-icon { padding: 8px; border-radius: 6px; color: var(--gray); background: transparent; border: none; }
.btn-icon:hover { background: var(--light); color: var(--primary); }

/* Toolbar Group */
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.toolbar-actions .btn {
    font-size: 11px;
    padding: 6px 12px;
}

/* --- LOGIN PAGE STYLES --- */
#landing-page {
    height: 100vh; display: flex; align-items: center; justify-content: center;
    background: white; position: relative; overflow: hidden; z-index: 50;
}
.blob {
    position: absolute; border-radius: 50%; filter: blur(80px); z-index: 1; opacity: 0.4;
}
.blob-1 { width: 400px; height: 400px; background: var(--primary); top: -100px; left: -100px; }
.blob-2 { width: 300px; height: 300px; background: var(--secondary); bottom: -50px; right: -50px; }

.login-card {
    width: 100%; max-width: 420px;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    padding: 40px;
    z-index: 10;
    text-align: center;
    border: 1px solid var(--border);
    animation: slideUp 0.5s ease-out;
}
.login-logo {
    width: 64px; height: 64px; background: var(--primary-light);
    border-radius: 50%; color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; margin: 0 auto 24px; border: 2px solid rgba(0,102,204,0.1);
}
.login-title { font-size: 24px; font-weight: 700; color: var(--text-main); margin-bottom: 8px; }
.login-subtitle { color: var(--gray); font-size: 14px; margin-bottom: 30px; }
.login-btn { width: 100%; padding: 12px; font-size: 15px; justify-content: center; margin-top: 10px; }
.login-footer { margin-top: 24px; font-size: 12px; color: var(--gray); }
.login-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }
.login-footer a:hover { text-decoration: underline; }

/* --- DASHBOARD LAYOUT --- */
#app-dashboard { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width); background: var(--white) !important; border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 10; transition: background 0.3s, width 0.3s; overflow-y: auto;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--white);
}
.sidebar a {
    text-decoration: none !important;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: var(--white); }
.sidebar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; transition: 0.3s; }
.sidebar:hover::-webkit-scrollbar-thumb { background: var(--primary); }
.sidebar::-webkit-scrollbar-thumb:hover { background: #005bb5; }
.brand {
    height: var(--header-height); display: flex; align-items: center; padding: 0 24px;
    font-size: 18px; font-weight: 800; color: var(--primary); border-bottom: 1px solid var(--border);
    background: var(--white) !important; position: sticky; top: 0; z-index: 20;
}
.nav-list { list-style: none; padding: 10px 0; }
.nav-list a { text-decoration: none !important; }
.nav-item-group { margin-bottom: 2px; }
.nav-header {
    padding: 12px 24px; display: flex; align-items: center; gap: 12px;
    color: var(--gray); cursor: pointer; transition: 0.2s; font-weight: 600; font-size: 13px; user-select: none;
    text-decoration: none !important;
    margin-left: 8px;
}
.nav-header:hover { background: var(--light); color: var(--primary); }
.nav-header.active { color: var(--primary); background: var(--primary-light); border-right: 3px solid var(--primary); }
.nav-header i.main-icon { width: 20px; text-align: left; }
.nav-header i.chevron { margin-left: auto; font-size: 10px; transition: transform 0.3s; }
.nav-item-group.open > .nav-header { color: var(--primary); background: var(--primary-light); }
.nav-item-group.open > .nav-header i.chevron { transform: rotate(180deg); }
.submenu {
    list-style: none; background: transparent !important; max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out;
}
.nav-item-group.open .submenu { max-height: 1000px; transition: max-height 0.5s ease-in; }
.sub-nav-item {
    padding: 10px 24px 10px 54px; font-size: 13px; color: var(--gray); cursor: pointer;
    display: flex; align-items: center; gap: 8px; transition: 0.2s; border-left: 3px solid transparent;
    text-decoration: none !important;
}
.nav-header {
    padding: 12px 24px; display: flex; align-items: center; gap: 12px;
    color: var(--gray); cursor: pointer; transition: 0.2s; font-weight: 600; font-size: 13px; user-select: none;
    margin-left: 8px;
}
.nav-header:hover { background: var(--light); color: var(--primary); }
.nav-header.active { color: var(--primary); background: var(--primary-light); border-right: 3px solid var(--primary); }
.nav-header i.main-icon { width: 20px; text-align: left; }
.nav-header i.chevron { margin-left: auto; font-size: 10px; transition: transform 0.3s; }
.nav-item-group.open > .nav-header { color: var(--primary); background: var(--primary-light); }
.nav-item-group.open > .nav-header i.chevron { transform: rotate(180deg); }
.submenu {
    list-style: none; background: rgba(0,0,0,0.02); max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out;
}
.nav-item-group.open .submenu { max-height: 1000px; transition: max-height 0.5s ease-in; }
.sub-nav-item {
    padding: 10px 24px 10px 54px; font-size: 13px; color: var(--gray); cursor: pointer;
    display: flex; align-items: center; gap: 8px; transition: 0.2s; border-left: 3px solid transparent;
}
.sub-nav-item:hover { background: var(--light); color: var(--primary); }
.sub-nav-item.active { background: var(--white); color: var(--primary); border-left-color: var(--primary); font-weight: 600; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.user-info {
    margin-top: auto; padding: 20px; border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px; font-size: 13px; background: var(--white); position: sticky; bottom: 0;
}

/* Main Content */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-body); transition: background 0.3s; position: relative; }
header {
    height: var(--header-height); background: var(--white); border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; padding: 0 32px; transition: background 0.3s;
}
.content-scroll { flex: 1; overflow-y: auto; padding: 32px; scroll-behavior: smooth; }

/* --- WIDGETS --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; margin-bottom: 32px; }
.stat-card {
    background: var(--white); padding: 24px; border-radius: 12px; box-shadow: var(--shadow);
    border: 1px solid var(--border); position: relative; overflow: hidden; transition: transform 0.2s, background 0.3s;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-card::after { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--primary); }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text-main); margin: 8px 0; }
.stat-label { font-size: 13px; color: var(--gray); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* --- CARDS & TABLES --- */
.card { background: var(--white); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; margin-bottom: 24px; transition: background 0.3s; }
.card-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; min-height: 70px; background: var(--white); }
.card-title { font-size: 16px; font-weight: 700; color: var(--text-main); }

table { width: 100%; border-collapse: collapse; }
th { background: var(--light); text-align: left; padding: 14px 24px; font-size: 11px; font-weight: 700; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
td { padding: 16px 24px; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-main); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,0.015); }

.status-badge { padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; cursor: default; display: inline-block;}
.status-active { background: var(--success-bg); color: var(--success-text); border: 1px solid rgba(16, 185, 129, 0.2); }
.status-inactive { background: var(--danger-bg); color: var(--danger-text); border: 1px solid rgba(239, 68, 68, 0.2); }
.status-pending { background: var(--warning-bg); color: var(--warning-text); border: 1px solid rgba(245, 158, 11, 0.2); }

/* --- TIMETABLE GRID --- */
.timetable-grid { display: grid; grid-template-columns: 80px repeat(6, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); }
.tt-cell { background: var(--white); padding: 12px; font-size: 13px; min-height: 90px; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--text-main); }
.tt-header { background: var(--light); font-weight: bold; color: var(--gray); min-height: 50px; }

/* --- MODAL --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(4px); opacity: 0; transition: opacity 0.3s; }
.modal-overlay.active { display: flex; opacity: 1; }
.modal { background: var(--white); width: 500px; max-width: 90%; border-radius: 12px; padding: 24px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); transform: scale(0.95); transition: transform 0.3s; max-height: 90vh; overflow-y: auto; }
.modal-overlay.active .modal { transform: scale(1); }

/* Checkbox Group for Custom Columns */
.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.checkbox-item { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; color: var(--text-main); }
.checkbox-item input { width: auto; margin: 0; }

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- INPUTS --- */
input, select, textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 6px; outline: none; color: var(--text-main); background: var(--white); font-size: 14px; margin-bottom: 12px; transition: border-color 0.2s, box-shadow 0.2s;}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,102,204,0.1); }
.form-group { margin-bottom: 16px; text-align: left; }
.form-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--gray); }

/* --- TOGGLE SWITCH --- */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-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: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* --- PRINT --- */
@media print {
    .sidebar, header, .blob, .hero-content, .btn, .modal-overlay, .toolbar-actions { display: none !important; }
    #landing-page { display: none; }
    #app-dashboard, .main-content, .content-scroll, .card { display: block !important; width: 100%; height: auto; overflow: visible; background: white; box-shadow: none; border: none; }
    .card-header { border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 20px; }
    table { width: 100%; border: 1px solid #000; }
    th, td { border: 1px solid #000; color: #000; padding: 8px; }
    body { background: white; color: black; height: auto; overflow: visible; }
    .stat-card { border: 1px solid #ccc; box-shadow: none; }
}
