/* ================================================================
   Ghana School Management System - App Shell Layout
   Sidebar / topbar / main-content shell shared by every page via
   views/shared/header.php. Split out of that file into its own
   stylesheet so it isn't re-parsed as an inline <style> block on
   every single request.
   ================================================================ */

/* ═══════════════════════════════════════════════════════════════
   DESIGN TOKENS  (aligned with the Enterprise POS design system)
═══════════════════════════════════════════════════════════════ */
:root {
  --sidebar-w:           262px;
  --sidebar-collapsed-w: 72px;
  --header-h:            64px;

  /* Brand / accent colour — the single source of truth every other
     "primary" token in the app (app.css's --primary family, Bootstrap's
     own --bs-primary*) derives from via var(). This is the DEFAULT
     accent ("Ocean") when the user hasn't picked one — see
     assets/css/themes.css's [data-accent="..."] blocks, which override
     these same 4 custom properties for every other named colour. */
  --brand-500: #2563eb;
  --brand-600: #1d4ed8;
  --brand-700: #1e40af;
  --brand-500-rgb: 37, 99, 235;
  /* Light, glow-able tint of the accent for text/icons that sit on the
     dark sidebar/topbar surfaces (where --brand-500 itself would be too
     dark to read against --nav-bg) — computed once here so every accent
     theme gets a correctly-lightened version for free, no per-theme
     tint value needed in themes.css. */
  --brand-tint: color-mix(in srgb, var(--brand-500) 55%, white);

  /* Sidebar / topbar base — a dark tone of the CHOSEN accent, not a fixed
     neutral navy. Previously this was a flat independent colour with
     only a faint 25% accent wash layered on top of it (see #sidebar
     below), so switching themes barely moved the sidebar; now the base
     itself is derived from --brand-700, so the whole rail visibly reads
     as "dark navy" only for Ocean (the default, since brand-700 there
     already IS a navy) and a genuinely dark SHADE OF the picked colour
     for every other theme — matching how saturated DrillCost's own
     dark-green chrome is, not muted down toward grey. */
  --nav-bg:      color-mix(in srgb, var(--brand-700) 62%, #05080f);
  --nav-surface: #1e293b;
  --nav-hover:   rgba(255,255,255,.06);
  --nav-active:  rgba(var(--brand-500-rgb), .18);
  /* White-based (not a fixed grey hex) so it reads crisply against ANY
     accent — a cool grey like the old #94a3b8 looked muddy/low-contrast
     on a warm background (Copper/Gold/Sandstone especially), since grey
     fights the underlying hue instead of just sitting on top of it as
     a translucent white does regardless of what's beneath. */
  --nav-text:    rgba(255,255,255,.78);
  --nav-text-hi: #ffffff;
  --nav-muted:   rgba(255,255,255,.55);
  --nav-border:  rgba(255,255,255,.06);
  --group-bg:    rgba(0,0,0,.15);

  --ease: .22s ease;
}

/* ── SIDEBAR SHELL ─────────────────────────────────────────────── */
#sidebar {
  position: fixed; top: 0; left: 0;
  height: 100vh; width: var(--sidebar-w);
  /* A distinctly darker, near-black band concentrated at the very top
     (brand/logo row) that resolves quickly into --nav-bg (itself
     already a dark tone of the accent — see :root above), rather than
     a slow 45%-tall fade — the previous gradient was too gradual to
     read as a separate band once accent hue and --nav-bg were close in
     value (Indigo/Amethyst-family themes especially). */
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand-700) 55%, black) 0%, var(--nav-bg) 18%, var(--nav-bg) 100%);
  display: flex; flex-direction: column;
  z-index: 1050; transition: width var(--ease), transform .3s ease;
  overflow: hidden;
}
#sidebar:hover { overflow-y: auto; }
#sidebar::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }
#sidebar.collapsed { width: var(--sidebar-collapsed-w); }

/* ── BRAND ──────────────────────────────────────────────────────── */
.sb-brand {
  padding: 15px 14px;
  border-bottom: 1px solid var(--nav-border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0; text-decoration: none;
}
.sb-brand-icon {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--brand-500);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 16px; flex-shrink: 0;
}
.sb-brand-name { color: #fff; font-weight: 700; font-size: 13px; line-height: 1.2; }
.sb-brand-sub  { color: var(--nav-muted); font-size: 10px; }
#sidebar.collapsed .sb-brand-name,
#sidebar.collapsed .sb-brand-sub { display: none; }
/* Collapsed: icon + toggle no longer fit side-by-side in the 72px rail
   (was overflowing past #sidebar's overflow:hidden, making the toggle
   unclickable — the fold could never be undone). Stack them instead. */
#sidebar.collapsed .sb-brand {
  flex-direction: column;
  padding: 12px 8px;
  gap: 8px;
}

/* ── SIDEBAR COLLAPSE TOGGLE ──────────────────────────────────────── */
.sb-collapse-btn {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.8);
  width: 26px; height: 26px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--ease); font-size: 11px;
  flex-shrink: 0; margin-left: auto;
}
.sb-collapse-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
#sidebar.collapsed .sb-collapse-btn i { transform: rotate(180deg); }
#sidebar.collapsed .sb-collapse-btn { margin-left: 0; }

/* ── NAV BODY ───────────────────────────────────────────────────── */
.sb-nav { flex: 1; padding: 8px 0 12px; }

/* ── GROUP TOGGLE BUTTON ────────────────────────────────────────── */
.sb-group-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 14px 8px 13px;
  background: none; border: none; cursor: pointer;
  color: var(--nav-muted);
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .7px;
  font-family: inherit;
  transition: color .2s;
  user-select: none;
}
.sb-group-btn:hover { color: var(--nav-text-hi); }
.sb-group-btn .sb-group-icon {
  width: 18px; height: 18px; border-radius: 5px;
  background: rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; flex-shrink: 0;
}
.sb-group-btn .sb-chevron {
  margin-left: auto; font-size: 10px;
  transition: transform .25s ease;
  color: var(--nav-muted);
}
.sb-group-btn[aria-expanded="true"] .sb-chevron { transform: rotate(90deg); }
.sb-group-btn[aria-expanded="true"] { color: var(--nav-text-hi); }
#sidebar.collapsed .sb-group-btn .sb-group-icon,
#sidebar.collapsed .sb-group-btn { justify-content: center; }
#sidebar.collapsed .sb-group-label,
#sidebar.collapsed .sb-group-btn .sb-chevron { display: none; }
#sidebar.collapsed .sb-group-items { display: none; }

/* ── GROUP COLLAPSE AREA ────────────────────────────────────────── */
.sb-group-items {
  background: var(--group-bg);
  border-left: 2px solid var(--nav-border);
  margin: 0 10px 2px 12px;
  border-radius: 0 0 7px 7px;
  overflow: hidden;
}

/* ── NAV ITEM ───────────────────────────────────────────────────── */
.sb-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 12px;
  color: var(--nav-text);
  text-decoration: none;
  font-size: 13px; font-weight: 600;
  border-radius: 7px;
  margin: 1px 6px;
  transition: background .15s, color .15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-item i { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; opacity: .8; }
.sb-item:hover  { background: var(--nav-hover); color: var(--nav-text-hi); }
.sb-item:hover i { opacity: 1; }
.sb-item.active {
  background: linear-gradient(135deg, rgba(var(--brand-500-rgb, 37,99,235),.4), rgba(var(--brand-500-rgb, 37,99,235),.18));
  color: var(--brand-tint);
  font-weight: 600;
  /* Dark drop-shadow leads (not a coloured glow) — a shadow reads as
     genuine depth/lift against a dark, already-saturated sidebar in a
     way a colour-on-colour glow doesn't; the coloured shadow underneath
     is kept only as a faint secondary cue. Inset top highlight for a
     bevelled edge, plus a slight upward nudge. */
  box-shadow:
    0 8px 20px rgba(0,0,0,.5),
    0 3px 6px rgba(0,0,0,.4),
    0 2px 10px rgba(var(--brand-500-rgb, 37,99,235),.25),
    inset 0 1px 0 rgba(255,255,255,.25);
  transform: translateY(-1px);
}
.sb-item.active i { opacity: 1; color: var(--brand-tint); }

/* Items inside a group get slightly tighter padding */
.sb-group-items .sb-item {
  margin: 1px 4px;
  padding: 6px 10px;
  font-size: 12.5px;
  border-radius: 6px;
}

/* ── STANDALONE ITEM (not in a group) ───────────────────────────── */
.sb-standalone { padding: 0 6px; margin-bottom: 1px; }
#sidebar.collapsed .sb-item-text { display: none; }
#sidebar.collapsed .sb-item { justify-content: center; margin: 1px 10px; }

/* ── BADGE ──────────────────────────────────────────────────────── */
.sb-badge {
  margin-left: auto; background: var(--brand-500); color: #fff;
  font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px; flex-shrink: 0;
}
#sidebar.collapsed .sb-badge { display: none; }

/* ── DIVIDER ────────────────────────────────────────────────────── */
.sb-divider {
  height: 1px; background: var(--nav-border);
  margin: 6px 14px;
}

/* ── USER FOOTER ────────────────────────────────────────────────── */
.sb-footer {
  border-top: 1px solid var(--nav-border);
  padding: 11px 13px; flex-shrink: 0;
}
.sb-user {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none; margin-bottom: 6px;
}
.sb-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.sb-user-name  { color: #fff; font-size: 12.5px; font-weight: 600; }
.sb-user-role  { color: var(--nav-muted); font-size: 10.5px; text-transform: capitalize; }
.sb-logout {
  display: flex; align-items: center; gap: 7px;
  color: rgba(255,255,255,.35); text-decoration: none;
  font-size: 12px; transition: color .2s;
}
.sb-logout:hover { color: rgba(255,255,255,.7); }
#sidebar.collapsed .sb-user-name,
#sidebar.collapsed .sb-user-role,
#sidebar.collapsed .sb-logout span { display: none; }
#sidebar.collapsed .sb-footer { display: flex; flex-direction: column; align-items: center; }

/* ── TOPBAR ─────────────────────────────────────────────────────── */
#topbar {
  position: fixed; top: 0;
  left: var(--sidebar-w); right: 0;
  height: var(--header-h);
  /* Same idea as DrillCost's .fixed-header — a diagonal dark-to-accent
     sweep instead of one flat panel colour, so the topbar visibly
     carries the chosen theme too, not just active-state highlights. */
  background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-600) 55%, var(--brand-500) 100%);
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
  z-index: 1040;
  box-shadow: 0 1px 0 rgba(0,0,0,.2), 0 4px 12px rgba(0,0,0,.08);
  transition: left var(--ease);
}
#sidebar.collapsed ~ #topbar,
body.sb-collapsed #topbar { left: var(--sidebar-collapsed-w); }
.topbar-page-title { font-size: 15px; font-weight: 700; flex: 1; min-width: 0; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── TOPBAR ICON BUTTONS (toggle / theme / notif) ───────────────── */
.tb-icon-btn {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.8);
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--ease); font-size: 14px;
  text-decoration: none; position: relative;
}
.tb-icon-btn:hover { background: rgba(255,255,255,.14); color: #fff; }

/* ── USER PILL (topbar) ──────────────────────────────────────────── */
.tb-user-pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 40px; height: 34px;
  padding: 0 12px 0 4px;
  color: rgba(255,255,255,.9);
  text-decoration: none; cursor: pointer;
  transition: all var(--ease);
}
.tb-user-pill:hover { background: rgba(255,255,255,.13); color: #fff; }

/* ── TERM PILL (topbar) ────────────────────────────────────────────
   Shows the current academic year/term everywhere in the app. Hidden
   below md — the topbar is already tight on mobile (hamburger + title +
   theme + bell + user pill), and this is supplementary context, not a
   control, so it's the first thing to give up space. */
.tb-term-pill {
  align-items: center; gap: 7px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 40px; height: 34px;
  padding: 0 14px;
  color: rgba(255,255,255,.85);
  font-size: 12.5px; font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}
a.tb-term-pill:hover { background: rgba(255,255,255,.13); color: #fff; }
.tb-term-pill i { font-size: 13px; opacity: .75; }

/* ── MAIN ───────────────────────────────────────────────────────── */
#main {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 22px;
  min-height: calc(100vh - var(--header-h));
  background: var(--bg, #f0f4f8);
  transition: margin-left var(--ease);
}
#sidebar.collapsed ~ #main,
body.sb-collapsed #main { margin-left: var(--sidebar-collapsed-w); }

/* ── MOBILE ─────────────────────────────────────────────────────── */
.mobile-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 1039;
}
.mobile-overlay.show { display: block; }

@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  #sidebar.open { transform: none; overflow-y: auto; }
  #topbar, #main { margin-left: 0 !important; left: 0 !important; }
  .sb-collapse-btn { display: none; }
  #main { padding: 14px; }
  #topbar { padding: 0 12px; gap: 8px; }
  .topbar-page-title { font-size: 14px; }
}
