/* ============================================================
   CBE Grading System — Modern UI 2026
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --sidebar-width:   250px;
    --topbar-height:   60px;

    /* Palette */
    --primary:         #6366f1;
    --primary-dark:    #4f46e5;
    --primary-light:   #e0e7ff;
    --accent:          #06b6d4;
    --success:         #10b981;
    --warning:         #f59e0b;
    --danger:          #ef4444;

    /* Sidebar */
    --sidebar-bg:      #0f172a;
    --sidebar-surface: #1e293b;
    --sidebar-text:    #94a3b8;
    --sidebar-active:  #6366f1;

    /* Layout */
    --bg:              #f1f5f9;
    --surface:         #ffffff;
    --border:          #e2e8f0;
    --text:            #0f172a;
    --text-muted:      #64748b;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg:  0 10px 30px rgba(0,0,0,.1),  0 4px 8px rgba(0,0,0,.05);

    /* Radius */
    --radius-sm:  6px;
    --radius:     10px;
    --radius-lg:  16px;
    --radius-xl:  20px;
}

/* ── Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: .9rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    left: 0; top: 0; bottom: 0;
    overflow-y: auto;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    padding: 0;
    transition: width .25s ease, transform .25s ease;
    scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1.25rem 1rem;
    min-height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem .75rem;
    margin-bottom: 1.5rem;
    text-decoration: none;
    border-radius: var(--radius);
    transition: background .15s;
}
.sidebar-brand:hover { background: rgba(255,255,255,.05); }
.sidebar-brand-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99,102,241,.4);
}
.sidebar-brand-text {
    font-weight: 700;
    font-size: .95rem;
    color: #fff;
    letter-spacing: -.01em;
}
.sidebar-brand-sub {
    font-size: .68rem;
    color: var(--sidebar-text);
    display: block;
    line-height: 1;
}

.sidebar .nav-section {
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #475569;
    padding: 1.25rem .75rem .4rem;
}
.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    font-size: .845rem;
    font-weight: 500;
    padding: .55rem .75rem;
    transition: all .15s;
    position: relative;
    margin-bottom: 2px;
    text-decoration: none;
}
.sidebar .nav-link i {
    font-size: 1rem;
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
    opacity: .7;
    transition: opacity .15s;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav-link:hover i { opacity: 1; }
.sidebar .nav-link.active {
    background: rgba(99,102,241,.18);
    color: #a5b4fc;
    font-weight: 600;
}
.sidebar .nav-link.active i { color: #818cf8; opacity: 1; }
.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem .75rem;
    border-radius: var(--radius-sm);
    margin-bottom: .5rem;
}
.sidebar-user-name { font-size: .82rem; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .7rem; color: var(--sidebar-text); text-transform: capitalize; }
.btn-logout {
    display: flex; align-items: center; justify-content: center; gap: .5rem;
    width: 100%; padding: .5rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(239,68,68,.3);
    background: rgba(239,68,68,.08);
    color: #fca5a5;
    font-size: .82rem; font-weight: 500;
    text-decoration: none;
    transition: all .15s;
}
.btn-logout:hover { background: rgba(239,68,68,.18); color: #fecaca; border-color: rgba(239,68,68,.5); }

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg);
    transition: margin-left .25s ease;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
}
.topbar-title { font-size: .9rem; font-weight: 600; color: var(--text); margin: 0; }
.topbar-toggle {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); cursor: pointer; transition: all .15s; flex-shrink: 0;
}
.topbar-toggle:hover { background: var(--bg); color: var(--text); }

.page-body { flex: 1; padding: 1.5rem; }

body.sidebar-collapsed .sidebar { width: 0; overflow: hidden; transform: translateX(-100%); }
body.sidebar-collapsed .main-content { margin-left: 0; }

/* ── Avatar ─────────────────────────────────────────────────── */
.avatar-circle {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; flex-shrink: 0;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm) !important;
    background: var(--surface);
}
.card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 1rem 1.25rem !important;
    font-weight: 600 !important;
    font-size: .875rem !important;
    color: var(--text) !important;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}
.card-footer {
    background: #f8fafc !important;
    border-top: 1px solid var(--border) !important;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg) !important;
}

/* ── Stat cards ─────────────────────────────────────────────── */
.stat-card {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    padding: 1.4rem 1.5rem;
    display: flex; align-items: center; gap: 1.1rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm) !important;
    transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md) !important; transform: translateY(-2px); }
.stat-card .stat-icon {
    width: 50px; height: 50px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat-card .stat-label { font-size: .75rem; color: var(--text-muted); font-weight: 500; margin-top: .15rem; }

/* ── Tables ─────────────────────────────────────────────────── */
.table { font-size: .855rem; border-collapse: separate; border-spacing: 0; }
.table thead th {
    background: #f8fafc;
    font-size: .72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border) !important;
    border-top: none !important;
    padding: .75rem 1rem;
    white-space: nowrap;
}
.table tbody td {
    padding: .75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9 !important;
    border-top: none !important;
}
.table tbody tr:last-child td { border-bottom: none !important; }
.table-hover tbody tr { transition: background .1s; }
.table-hover tbody tr:hover { background: #f8faff !important; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    font-weight: 500; font-size: .845rem;
    border-radius: var(--radius-sm); transition: all .15s;
    display: inline-flex; align-items: center; gap: .35rem;
}
.btn-primary { background: var(--primary); border-color: var(--primary); box-shadow: 0 2px 8px rgba(99,102,241,.25); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); box-shadow: 0 4px 14px rgba(99,102,241,.35); }
.btn-outline-secondary { border-color: var(--border); color: var(--text-muted); }
.btn-outline-secondary:hover { background: var(--bg); border-color: #cbd5e1; color: var(--text); }
.btn-sm { font-size: .8rem; padding: .35rem .75rem; }

/* ── Form controls ───────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: .855rem; color: var(--text); background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
    outline: none;
}
.form-label {
    font-size: .78rem; font-weight: 600; color: var(--text-muted);
    margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .04em;
}
.form-text { color: var(--text-muted); font-size: .75rem; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge { font-weight: 600; letter-spacing: .03em; font-size: .72rem; border-radius: 20px; padding: .3em .7em; }
.bg-success   { background: #dcfce7 !important; color: #166534 !important; }
.bg-primary   { background: #e0e7ff !important; color: #4338ca !important; }
.bg-danger    { background: #fee2e2 !important; color: #991b1b !important; }
.bg-warning   { background: #fef9c3 !important; color: #854d0e !important; }
.bg-secondary { background: #f1f5f9 !important; color: #475569 !important; }

/* ── Grade badges ────────────────────────────────────────────── */
.grade-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 48px; padding: .3rem .6rem;
    border-radius: 20px; font-weight: 700; font-size: .75rem; letter-spacing: .04em;
}

/* ── Alerts ──────────────────────────────────────────────────── */
.alert { border-radius: var(--radius); border: none; font-size: .855rem; padding: .75rem 1rem; }
.alert-success { background: #f0fdf4; color: #166534; border-left: 3px solid var(--success); }
.alert-danger  { background: #fef2f2; color: #991b1b; border-left: 3px solid var(--danger); }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 3px solid var(--warning); }
.alert-info    { background: #eff6ff; color: #1e40af; border-left: 3px solid var(--primary); }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-content { border: 1px solid var(--border) !important; border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-lg) !important; }
.modal-header  { border-bottom: 1px solid var(--border) !important; padding: 1.25rem 1.5rem !important; }
.modal-footer  { border-top: 1px solid var(--border) !important; padding: 1rem 1.5rem !important; background: #f8fafc; border-radius: 0 0 var(--radius-lg) var(--radius-lg) !important; }
.modal-title   { font-weight: 700; font-size: 1rem; }

/* ── Section heading ─────────────────────────────────────────── */
.section-heading { font-size: 1.15rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }

/* ── Code ────────────────────────────────────────────────────── */
code {
    background: #e0e7ff; color: #4338ca;
    border-radius: 4px; padding: .15em .45em;
    font-size: .82em; font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ── Page header ─────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.page-header-title { font-size: 1.2rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .6rem; }
.page-header-title i { color: var(--primary); font-size: 1.1rem; }

/* ── Marks inputs ────────────────────────────────────────────── */
.marks-input, .total-input {
    width: 90px; text-align: center; font-weight: 600;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    padding: .35rem .5rem; font-size: .845rem; transition: all .15s;
}
.marks-input:focus, .total-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); outline: none; }

/* ── Login ───────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
    display: flex; align-items: center; justify-content: center;
}
.login-card {
    background: rgba(255,255,255,.98);
    border-radius: var(--radius-xl); padding: 2.5rem 2.25rem;
    width: 100%; max-width: 430px;
    box-shadow: 0 25px 60px rgba(0,0,0,.4);
    border: 1px solid rgba(255,255,255,.15);
}
.login-logo {
    width: 58px; height: 58px; border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: #fff; font-size: 1.6rem;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto; box-shadow: 0 8px 24px rgba(99,102,241,.4);
}

/* ── Report card ─────────────────────────────────────────────── */
.report-card { max-width: 800px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.report-header { background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%); color: #fff; padding: 1.75rem 2rem; }
.report-school-name { font-size: 1.35rem; font-weight: 800; }
.report-subtitle    { font-size: .82rem; opacity: .7; margin-top: .2rem; }

/* ── Autosave ────────────────────────────────────────────────── */
#autosave-status { font-size: .8rem; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Text utilities ──────────────────────────────────────────── */
.text-muted { color: var(--text-muted) !important; }

/* ── Dropdown ────────────────────────────────────────────────── */
.dropdown-menu { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: .4rem; font-size: .845rem; }
.dropdown-item { border-radius: var(--radius-sm); padding: .45rem .75rem; }

/* ── Print ───────────────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .no-print, .btn { display: none !important; }
    .main-content { margin-left: 0 !important; }
    body { background: #fff !important; font-size: 12px; }
    table { font-size: 11px; }
    .grade-badge { border: 1px solid #333; color: #000 !important; background: transparent !important; }
}

/* ── Responsive ──────────────────────────────────────────────── */
.sidebar-backdrop { display: none; }
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .page-body { padding: 1rem; }
    
    /* Mobile Backdrop Overlay */
    .sidebar-backdrop {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(4px);
        z-index: 1035;
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s ease;
        display: block;
    }
    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ── Online Indicator Pulse ── */
@keyframes online-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    70% {
        box-shadow: 0 0 0 5px rgba(34, 197, 94, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}
.pulse-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #22c55e;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 4px;
    animation: online-pulse 2s infinite;
}