/* ═══════════════════════════════════════════════════════════════════════════
   SchoolSyntaxERP — Main Stylesheet  v2.0
   Light / Dark mode — professional enterprise UI
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens (Light) ─────────────────────────────────────────────── */
:root {
    --sidebar-width: 268px;
    --sidebar-collapsed-width: 70px;
    --navbar-height: 64px;

    /* Brand */
    --primary:       #1a237e;
    --primary-light: #3949ab;
    --primary-glow:  rgba(57,73,171,.18);

    /* Sidebar — light mode: deep charcoal + emerald accent */
    --sb-bg:         #18181b;
    --sb-border:     rgba(255,255,255,.07);
    --sb-text:       #a1a1aa;
    --sb-text-hover: #fafafa;
    --sb-active-bg:  rgba(34,197,94,.14);
    --sb-active-txt: #22c55e;
    --sb-section:    #52525b;
    --sb-sublink:    #71717a;

    /* Navbar */
    --nav-bg:        #ffffff;
    --nav-border:    #e2e8f0;
    --nav-text:      #374151;
    --nav-sub:       #64748b;

    /* Content */
    --body-bg:       #f1f4f9;
    --card-bg:       #ffffff;
    --card-border:   #e8ecf3;
    --text-main:     #111827;
    --text-muted:    #6b7280;

    /* Footer */
    --footer-bg:     #ffffff;
    --footer-border: #e2e8f0;

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: all 0.22s ease;
}

/* ─── Dark Mode Tokens ───────────────────────────────────────────────────── */
[data-bs-theme="dark"] {
    /* Sidebar — dark mode: pure black + amber accent */
    --sb-bg:         #09090b;
    --sb-border:     rgba(255,255,255,.06);
    --sb-text:       #71717a;
    --sb-text-hover: #e4e4e7;
    --sb-active-bg:  rgba(245,158,11,.14);
    --sb-active-txt: #f59e0b;
    --sb-section:    #3f3f46;

    --nav-bg:        #111827;
    --nav-border:    #1f2937;
    --nav-text:      #d1d5db;
    --nav-sub:       #9ca3af;

    --body-bg:       #0f172a;
    --card-bg:       #1e2433;
    --card-border:   #283040;
    --text-main:     #f1f5f9;
    --text-muted:    #94a3b8;

    --footer-bg:     #111827;
    --footer-border: #1f2937;
}

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

body.sidebar-layout {
    background-color: var(--body-bg);
    margin: 0;
    overflow-x: hidden;
    color: var(--text-main);
}

/* ══════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════════════════════ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--sb-bg);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: #1e293b transparent;
    border-right: 1px solid var(--sb-border);
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 2px; }

/* ── Sidebar Header ────────────────────────────────────────────────────── */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.1rem 1.1rem 1.25rem;
    border-bottom: 1px solid var(--sb-border);
    min-height: var(--navbar-height);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    text-decoration: none;
}

.brand-logo {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #3f3f46, #27272a);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f4f4f5;
    font-size: 0.85rem;
    flex-shrink: 0;
    box-shadow: 0 3px 8px rgba(0,0,0,.4);
}

.brand-logo-img {
    background: #fff;
    padding: 2px;
    overflow: hidden;
}

.sb-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 8px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1; }

.brand-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.3px;
}

.brand-sub {
    font-size: 0.67rem;
    color: var(--sb-section);
    margin-top: 3px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-toggle {
    background: transparent;
    border: 1px solid var(--sb-border);
    color: var(--sb-text);
    padding: 0.25rem 0.4rem;
    border-radius: 6px;
    line-height: 1;
    display: none;
}

.sidebar-toggle:hover { background: var(--sb-active-bg); color: #fff; }

/* ── Sidebar Impersonation Banner ──────────────────────────────────────── */
.sidebar-impersonation-banner {
    margin: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: rgba(234, 179, 8, 0.12);
    border: 1px solid rgba(234, 179, 8, 0.3);
    font-size: 0.72rem;
    color: #fbbf24;
    line-height: 1.4;
}
.sidebar-impersonation-banner a { color: #fbbf24; font-weight: 700; }
.sidebar-impersonation-banner a:hover { color: #fff; }

/* ── Sidebar User ──────────────────────────────────────────────────────── */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--sb-border);
    flex-shrink: 0;
    background: rgba(255,255,255,.02);
}

.sidebar-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,.12);
}

.sidebar-user-info { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }

.sidebar-user-name {
    font-size: 0.83rem;
    font-weight: 700;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Sidebar Menu ──────────────────────────────────────────────────────── */
.sidebar-menu-wrapper { padding: 0.5rem 0 2rem; flex: 1; }
.sidebar-menu { margin: 0; }

.sidebar-section-header {
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--sb-section);
    padding: 1.1rem 1.3rem 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sidebar-section-header::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 1px;
    background: var(--sb-section);
    flex-shrink: 0;
}

.sidebar-item { margin: 0; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.58rem 1.25rem;
    color: var(--sb-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: rgba(255,255,255,.05);
    color: var(--sb-text-hover);
    border-left-color: rgba(255,255,255,.2);
}

.sidebar-item.active > .sidebar-link {
    background: var(--sb-active-bg);
    color: var(--sb-active-txt);
    border-left-color: var(--sb-active-txt);
    font-weight: 700;
}

.sidebar-link:not(.collapsed) {
    color: var(--sb-text-hover);
}

.sidebar-link i:first-child {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    opacity: .85;
}

.sidebar-item.active > .sidebar-link i:first-child { opacity: 1; }

.sidebar-arrow { font-size: 0.68rem; transition: transform 0.2s; }
.sidebar-link:not(.collapsed) .sidebar-arrow { transform: rotate(-180deg); }

.sidebar-submenu { background: rgba(0,0,0,.18); }

.sidebar-sublink {
    display: block;
    padding: 0.42rem 1.25rem 0.42rem 3.4rem;
    color: var(--sb-sublink);
    text-decoration: none;
    font-size: 0.825rem;
    font-weight: 600;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-sublink:hover {
    color: var(--sb-text-hover);
    background: rgba(255,255,255,.03);
    border-left-color: rgba(255,255,255,.15);
}

.sidebar-sublink-header {
    padding: 0.4rem 1.25rem 0.1rem 3.4rem;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--sb-section);
    pointer-events: none;
}

.sidebar-item-locked > .sidebar-link {
    opacity: .35;
    cursor: not-allowed;
    pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════════════════
   TOP NAVBAR
   ══════════════════════════════════════════════════════════════════════════ */

.top-navbar {
    height: var(--navbar-height);
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 1px 8px rgba(0,0,0,.06);
    gap: 1rem;
}

.navbar-left { display: flex; align-items: center; gap: 0.75rem; }

.navbar-school-name {
    font-weight: 700;
    color: var(--nav-text);
    font-size: 0.925rem;
    letter-spacing: .1px;
}

.navbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--nav-sub);
}

.navbar-breadcrumb a { color: var(--nav-sub); text-decoration: none; }
.navbar-breadcrumb a:hover { color: var(--primary); }

.navbar-icon-btn {
    background: transparent;
    border: 1px solid var(--nav-border);
    border-radius: 8px;
    padding: 0.38rem 0.65rem;
    color: var(--nav-text);
    transition: var(--transition);
    line-height: 1;
}

.navbar-icon-btn:hover {
    background: var(--body-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.navbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--nav-border);
}

.navbar-user-btn {
    background: transparent;
    border: 1px solid var(--nav-border);
    border-radius: 10px;
    padding: 0.32rem 0.8rem;
    color: var(--nav-text);
    font-weight: 600;
    font-size: .875rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.navbar-user-btn:hover { background: var(--body-bg); border-color: var(--primary); }

.navbar-search { position: relative; }
.navbar-search-input {
    background: var(--body-bg);
    border: 1px solid var(--nav-border);
    border-radius: 8px;
    padding: 0.38rem 0.75rem 0.38rem 2.2rem;
    font-size: 0.85rem;
    color: var(--nav-text);
    width: 220px;
    transition: var(--transition);
    outline: none;
}
.navbar-search-input::placeholder { color: var(--text-muted); }
.navbar-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    width: 260px;
}
.navbar-search-icon {
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: .85rem;
    pointer-events: none;
}

/* Dark mode toggle pill */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--body-bg);
    border: 1px solid var(--nav-border);
    border-radius: 20px;
    padding: 0.3rem 0.65rem;
    font-size: .8rem;
    color: var(--nav-sub);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); }
.theme-toggle i { font-size: .95rem; }

/* ══════════════════════════════════════════════════════════════════════════
   MAIN LAYOUT
   ══════════════════════════════════════════════════════════════════════════ */

.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.main-content {
    flex: 1;
    padding: 1.5rem 1.75rem;
    max-width: 100%;
}

/* ── Page Header ────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--card-border);
}

.page-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: .15rem;
    letter-spacing: -.02em;
    line-height: 1.2;
}

[data-bs-theme="dark"] .page-title { color: #818cf8; }

.breadcrumb-sm { font-size: 0.78rem; margin: 0; }
.breadcrumb-sm .breadcrumb-item + .breadcrumb-item::before { font-size: 0.72rem; }
.breadcrumb-sm .breadcrumb-item a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color .15s;
}
.breadcrumb-sm .breadcrumb-item a:hover { color: var(--primary); }
.breadcrumb-sm .breadcrumb-item.active { color: var(--text-muted); }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
    border-radius: 12px;
    background-color: var(--card-bg);
    border-color: var(--card-border);
    transition: box-shadow .2s;
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
    padding: 0.9rem 1.25rem;
    background-color: var(--card-bg);
    border-color: var(--card-border);
    font-weight: 600;
}

[data-bs-theme="dark"] .table { color: var(--text-main); }
[data-bs-theme="dark"] .table-light { --bs-table-bg: #242d3c; color: var(--text-muted); }
[data-bs-theme="dark"] .list-group-item { background-color: var(--card-bg); border-color: var(--card-border); color: var(--text-main); }
[data-bs-theme="dark"] .dropdown-menu { background-color: #1e2433; border-color: var(--card-border); }
[data-bs-theme="dark"] .dropdown-item { color: var(--text-main); }
[data-bs-theme="dark"] .dropdown-item:hover { background-color: rgba(255,255,255,.06); }
[data-bs-theme="dark"] .modal-content { background-color: #1e2433; border-color: var(--card-border); }
[data-bs-theme="dark"] .alert { border-color: transparent; }
[data-bs-theme="dark"] .input-group-text { background-color: #242d3c; border-color: #334155; color: var(--text-main); }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select { background-color: #242d3c; border-color: #334155; color: var(--text-main); }
[data-bs-theme="dark"] .form-control:focus, [data-bs-theme="dark"] .form-select:focus { background-color: #283040; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.2); }
[data-bs-theme="dark"] .nav-tabs { border-color: #334155; }
[data-bs-theme="dark"] .nav-tabs .nav-link { color: var(--text-muted); }
[data-bs-theme="dark"] .nav-tabs .nav-link.active { background-color: var(--card-bg); border-color: #334155 #334155 var(--card-bg); color: var(--text-main); }
[data-bs-theme="dark"] .breadcrumb-item a { color: #94a3b8; }
[data-bs-theme="dark"] .text-muted { color: #94a3b8 !important; }
[data-bs-theme="dark"] .badge.bg-light { background-color: #334155 !important; color: #cbd5e1 !important; }
[data-bs-theme="dark"] .table-warning { --bs-table-bg: rgba(255,193,7,.12); }
[data-bs-theme="dark"] .table-primary { --bs-table-bg: rgba(99,102,241,.12); }
[data-bs-theme="dark"] .border { border-color: var(--card-border) !important; }
[data-bs-theme="dark"] .bg-light, [data-bs-theme="dark"] .bg-light-subtle { background-color: #1a2234 !important; }
[data-bs-theme="dark"] hr { border-color: var(--card-border); }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table { font-size: 0.875rem; color: var(--text-main); }
.table thead th {
    font-weight: 700;
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom-width: 1px;
}

/* ── Stat Icon ───────────────────────────────────────────────────────────── */
.stat-icon {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

/* ── Notification Dropdown ───────────────────────────────────────────────── */
.notification-dropdown { border-radius: 12px; overflow: hidden; }

/* ══════════════════════════════════════════════════════════════════════════
   FOOTER  — slim single-line bar
   ══════════════════════════════════════════════════════════════════════════ */

.main-footer {
    background: var(--footer-bg);
    border-top: 1px solid var(--footer-border);
    margin-top: auto;
    height: 38px;
    flex-shrink: 0;
}

.footer-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    font-size: 0.75rem;
    gap: 1rem;
}

.footer-left {
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    flex-shrink: 0;
}

.footer-centre {
    font-size: 0.73rem;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
}

.footer-right {
    display: flex;
    align-items: center;
    font-size: 0.73rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); box-shadow: 8px 0 32px rgba(0,0,0,.3); }
    .main-wrapper { margin-left: 0; }
    .sidebar-toggle-btn { display: flex !important; }
    .main-content { padding: 1rem; }
    .footer-inner { flex-direction: column; text-align: center; gap: .75rem; }
}

@media (min-width: 992px) {
    .sidebar-toggle-btn { display: none; }
    body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }
    body.sidebar-collapsed .main-wrapper { margin-left: var(--sidebar-collapsed-width); }
    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .sidebar-user-info,
    body.sidebar-collapsed .sidebar-link span,
    body.sidebar-collapsed .sidebar-section-header,
    body.sidebar-collapsed .sidebar-arrow { display: none; }
    body.sidebar-collapsed .sidebar-user { justify-content: center; }
    body.sidebar-collapsed .sidebar-link { justify-content: center; padding: 0.72rem; border-left: none; }
    body.sidebar-collapsed .sidebar-sublink { display: none; }
    body.sidebar-collapsed .sidebar-header { padding: 1rem 0.75rem; justify-content: center; }
    body.sidebar-collapsed .brand-logo { margin: 0 auto; }
}

/* ══════════════════════════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════════════════════════ */

.overlay-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1039;
}

.sidebar.show ~ .main-wrapper .overlay-backdrop { display: block; }
