/* School Result System - shared theme */

:root {
    --brand: #2f5be7;
    --brand-dark: #2147b8;
    --brand-rgb: 47, 91, 231;
    --brand-soft: #e8eefe;
    --accent: #8aa4ff;
    --sidebar-bg: #0f172a;
    --sidebar-text: #a9b4c9;
    --sidebar-hover: rgba(255, 255, 255, .06);
    --sidebar-active: rgba(255, 255, 255, .11);
    --ink: #1e293b;
    --muted: #64748b;
    --line: #e4e8f1;
    --surface: #ffffff;
    --page: #f3f5fa;
    --radius: .75rem;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-md: 0 6px 18px rgba(16, 24, 40, .10);

    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --bs-body-bg: #f3f5fa;
    --bs-body-color: #1e293b;
    --bs-border-color: #e4e8f1;
    --bs-primary: #2f5be7;
    --bs-primary-rgb: 47, 91, 231;
    --bs-link-color: #2f5be7;
    --bs-link-color-rgb: 47, 91, 231;
    --bs-link-hover-color: #2147b8;
    --bs-link-hover-color-rgb: 33, 71, 184;
}

/* Super Admin gets its own colour identity */
body.theme-super {
    --brand: #6a3fd1;
    --brand-dark: #512ea8;
    --brand-rgb: 106, 63, 209;
    --brand-soft: #efe9fc;
    --accent: #c0a8ff;
    --sidebar-bg: #1a1233;
    --bs-primary: #6a3fd1;
    --bs-primary-rgb: 106, 63, 209;
    --bs-link-color: #6a3fd1;
    --bs-link-color-rgb: 106, 63, 209;
    --bs-link-hover-color: #512ea8;
    --bs-link-hover-color-rgb: 81, 46, 168;
}

html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--bs-body-font-family);
    background: var(--page);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    font-size: .94rem;
}
h4 { font-size: 1.35rem; letter-spacing: -.015em; }
h5 { font-size: 1.1rem; letter-spacing: -.01em; }
a { text-decoration: none; }
.text-muted { color: var(--muted) !important; }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 264px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transform: translateX(-100%);
    transition: transform .22s ease;
}
.sidebar.open { transform: translateX(0); }
.sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 1035;
    display: none;
}
.sidebar-overlay.show { display: block; }

.main-area { min-height: 100vh; display: flex; flex-direction: column; }

@media (min-width: 992px) {
    .sidebar { transform: none; }
    .main-area { margin-left: 264px; }
    .sidebar-overlay { display: none !important; }
    #sidebarToggle { display: none; }
}

.sidebar-brand {
    display: flex; align-items: center; gap: .75rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand-mark {
    width: 40px; height: 40px; flex-shrink: 0;
    border-radius: .65rem;
    background: var(--brand);
    color: #fff; font-weight: 700; font-size: 1.05rem;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 2px; }
.brand-text { min-width: 0; }
.brand-name {
    color: #fff; font-weight: 600; font-size: .95rem; line-height: 1.25;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.brand-sub { font-size: .72rem; color: var(--sidebar-text); }

.side-nav { flex: 1; overflow-y: auto; padding: .9rem .75rem 1.5rem; }
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .15); border-radius: 3px; }

.side-link {
    display: flex; align-items: center; gap: .75rem;
    width: 100%;
    padding: .62rem .8rem; margin-bottom: .15rem;
    border: 0; background: transparent;
    color: var(--sidebar-text);
    font-size: .9rem; font-weight: 500; text-align: left;
    border-radius: .55rem;
    cursor: pointer;
}
.side-link > .bi:first-child { font-size: 1.05rem; width: 1.25rem; text-align: center; }
.side-link:hover { background: var(--sidebar-hover); color: #fff; }
.side-link.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.side-toggle .chevron { margin-left: auto; font-size: .72rem; transition: transform .2s; }
.side-toggle:not(.collapsed) { color: #fff; }
.side-toggle:not(.collapsed) .chevron { transform: rotate(180deg); }

.side-sub {
    margin: .1rem 0 .55rem 1.6rem;
    padding-left: .55rem;
    border-left: 1px solid rgba(255, 255, 255, .12);
}
.side-sublink {
    display: flex; align-items: center; justify-content: space-between;
    padding: .45rem .75rem; margin-bottom: .1rem;
    color: var(--sidebar-text);
    font-size: .86rem;
    border-radius: .45rem;
}
.side-sublink:hover { color: #fff; background: var(--sidebar-hover); }
.side-sublink.active { color: #fff; font-weight: 600; background: var(--sidebar-active); }

.side-badge {
    margin-left: auto;
    background: #ef4444; color: #fff;
    font-size: .7rem; font-weight: 700;
    padding: .1rem .5rem; border-radius: 999px;
}

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 1020;
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.5rem;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.topbar-btn {
    position: relative;
    width: 40px; height: 40px;
    border-radius: .65rem;
    border: 1px solid var(--line);
    background: #fff; color: var(--muted);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.topbar-btn:hover { background: var(--page); color: var(--ink); }
.notif-dot {
    position: absolute; top: -6px; right: -6px;
    min-width: 19px; height: 19px; padding: 0 5px;
    border-radius: 999px;
    background: #ef4444; color: #fff;
    font-size: .66rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
}
.period-pill {
    display: inline-flex; align-items: center; gap: .45rem;
    background: var(--brand-soft); color: var(--brand-dark);
    font-size: .8rem; font-weight: 600;
    padding: .38rem .8rem; border-radius: 999px;
}
.user-btn {
    display: flex; align-items: center; gap: .65rem;
    border: 1px solid var(--line); background: #fff;
    border-radius: .75rem;
    padding: .3rem .7rem .3rem .35rem;
}
.user-btn:hover { background: var(--page); }
.avatar {
    width: 34px; height: 34px; flex-shrink: 0;
    border-radius: .6rem;
    background: var(--brand); color: #fff;
    font-weight: 600; font-size: .8rem;
    display: flex; align-items: center; justify-content: center;
}
.user-meta { text-align: left; line-height: 1.2; }
.user-name { font-size: .85rem; font-weight: 600; color: var(--ink); }
.user-role { font-size: .72rem; color: var(--muted); }

.content { padding: 1.75rem 1.5rem 3rem; flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; }
@media (max-width: 575px) { .content { padding: 1.25rem 1rem 2.5rem; } .topbar { padding: 0 1rem; } }

/* ---------- Cards, tables, forms ---------- */
.card {
    --bs-card-border-radius: .75rem;
    --bs-card-border-color: var(--line);
    --bs-card-cap-bg: transparent;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}
.card.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.card-header { font-weight: 600; padding: .9rem 1.15rem; border-bottom: 1px solid var(--line); }
.card-body { padding: 1.15rem; }
.card-footer { background: #fafbfe; border-top: 1px solid var(--line); }
.card > .table-responsive { border-radius: var(--radius); }

.table { --bs-table-bg: transparent; --bs-table-hover-bg: #f6f8fd; margin-bottom: 0; }
.table > thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); font-weight: 600;
    background: #f8f9fd;
    border-bottom: 1px solid var(--line);
    padding: .8rem 1rem; white-space: nowrap;
}
.table > tbody td { padding: .8rem 1rem; border-color: var(--line); vertical-align: middle; }
.table-sm > thead th { padding: .65rem .85rem; }
.table-sm > tbody td { padding: .6rem .85rem; }

.form-control, .form-select {
    border-radius: .55rem; border-color: #d5dbe8;
    padding: .55rem .8rem; font-size: .92rem;
}
.form-control-sm, .form-select-sm { padding: .35rem .65rem; font-size: .85rem; border-radius: .5rem; }
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .15);
}
.form-label { font-weight: 500; font-size: .85rem; color: #334155; margin-bottom: .35rem; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

.btn { border-radius: .55rem; font-weight: 500; font-size: .88rem; padding: .5rem 1rem; }
.btn-sm { padding: .35rem .75rem; font-size: .82rem; border-radius: .5rem; }
.btn-primary {
    --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark);
    --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: var(--brand-rgb);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand); --bs-btn-active-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: var(--brand-rgb);
}
.btn-outline-secondary { --bs-btn-color: #475569; --bs-btn-border-color: #cfd6e4; }

.badge { font-weight: 600; letter-spacing: .01em; padding: .4em .7em; border-radius: .45rem; }

.alert {
    border: 0; border-left: 4px solid; border-radius: .6rem;
    box-shadow: var(--shadow-sm); font-size: .9rem;
}
.alert-success { background: #ecfdf3; color: #067647; border-left-color: #12b76a; }
.alert-danger  { background: #fef3f2; color: #b42318; border-left-color: #f04438; }
.alert-warning { background: #fffaeb; color: #b54708; border-left-color: #f79009; }
.alert-info    { background: #eff8ff; color: #175cd3; border-left-color: #2e90fa; }

.page-link { color: var(--brand); border-color: var(--line); }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); }

.dropdown-menu {
    border: 1px solid var(--line); border-radius: .75rem;
    box-shadow: var(--shadow-md); padding: .4rem;
}
.dropdown-item { border-radius: .45rem; font-size: .88rem; padding: .5rem .75rem; }
.dropdown-item:active { background: var(--brand); }

.accordion-button:not(.collapsed) { background: var(--brand-soft); color: var(--brand-dark); box-shadow: none; }
.accordion-button:focus { box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .15); }

/* ---------- Dashboard pieces ---------- */
.welcome {
    background: linear-gradient(120deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #fff; border-radius: var(--radius);
    padding: 1.5rem 1.75rem; box-shadow: var(--shadow-md);
}
.welcome h4 { color: #fff; margin-bottom: .25rem; }
.welcome p { color: rgba(255, 255, 255, .85); margin: 0; }
.welcome-pill {
    background: rgba(255, 255, 255, .16);
    padding: .4rem .85rem; border-radius: 999px;
    font-size: .82rem; font-weight: 600;
}

.stat-card { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.2rem; }
.stat-icon {
    width: 46px; height: 46px; flex-shrink: 0;
    border-radius: .8rem; font-size: 1.3rem;
    display: flex; align-items: center; justify-content: center;
}
.stat-icon.blue   { background: #e8eefe; color: #2f5be7; }
.stat-icon.green  { background: #e7f8ef; color: #12a150; }
.stat-icon.amber  { background: #fff4e0; color: #d97706; }
.stat-icon.violet { background: #f1eafe; color: #7c3aed; }
.stat-icon.rose   { background: #fdecef; color: #e11d48; }
.stat-icon.slate  { background: #eef1f6; color: #475569; }
.stat-icon.cyan   { background: #e0f6fb; color: #0891b2; }
.stat-value { font-size: 1.65rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 500; }

.action-tile {
    display: flex; flex-direction: column; align-items: flex-start; gap: .65rem;
    height: 100%; padding: 1rem;
    background: #fff; border: 1px solid var(--line); border-radius: .8rem;
    color: var(--ink);
    transition: all .15s ease;
}
.action-tile:hover {
    border-color: var(--brand); box-shadow: var(--shadow-md);
    transform: translateY(-2px); color: var(--ink);
}
.action-tile .stat-icon { width: 40px; height: 40px; font-size: 1.1rem; }
.action-title { font-weight: 600; font-size: .9rem; }
.action-desc { font-size: .78rem; color: var(--muted); }

/* ---------- Sign-in and public pages ---------- */
.auth-page { min-height: 100vh; display: flex; background: var(--page); }
.auth-side {
    display: none; flex: 1 1 45%;
    flex-direction: column; justify-content: space-between;
    padding: 3rem; color: #fff;
    background: linear-gradient(150deg, #0b1230 0%, #1b2f8a 55%, #2f5be7 100%);
    position: relative; overflow: hidden;
}
.auth-side::before {
    content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%;
    background: rgba(255, 255, 255, .06); top: -140px; right: -120px;
}
.auth-side::after {
    content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%;
    background: rgba(255, 255, 255, .05); bottom: -110px; left: -90px;
}
.auth-side > * { position: relative; z-index: 1; }
.auth-brand { display: flex; align-items: center; gap: .75rem; font-weight: 600; font-size: 1.05rem; }
.auth-headline { font-size: 2.1rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-bottom: 1rem; color: #fff; }
.auth-sub { color: rgba(255, 255, 255, .8); max-width: 30rem; }
.auth-points { list-style: none; padding: 0; margin: 1.75rem 0 0; display: grid; gap: .9rem; }
.auth-points li { display: flex; gap: .75rem; align-items: flex-start; color: rgba(255, 255, 255, .92); font-size: .92rem; }
.auth-points .pt {
    width: 32px; height: 32px; flex-shrink: 0;
    border-radius: .55rem; background: rgba(255, 255, 255, .14);
    display: flex; align-items: center; justify-content: center;
}
.auth-main { flex: 1 1 55%; display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-box { width: 100%; max-width: 410px; }
.auth-single {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 2rem 1rem;
    background: linear-gradient(150deg, #0b1230 0%, #1b2f8a 55%, #2f5be7 100%);
}
.auth-card {
    width: 100%; max-width: 430px; background: #fff;
    border-radius: 1rem; padding: 2rem;
    box-shadow: 0 24px 60px rgba(8, 15, 40, .35);
}
@media (min-width: 992px) { .auth-side { display: flex; } }

/* ---------- Printing ---------- */
@media print {
    .sidebar, .topbar, .sidebar-overlay { display: none !important; }
    .main-area { margin-left: 0 !important; }
    .content { padding: 0; max-width: none; }
    body { background: #fff; }
}