/* ==========================================================================
   JMatrix360 left sidebar navigation chrome.

   Applies only to authenticated, non-investor users (see templates/base.html)
   — investor-portal and unauthenticated visitors keep the pre-existing top
   nav in .app-header/.app-nav, which this file does not touch.

   Palette: dark ink navy sidebar with the app's own existing brand blue
   (--brand in design-system.css, #2a78d6) and gold accent (already used by
   the idle-timeout modal, #cfa53a) — deliberately not the sibling product's
   blue/green finance palette.
   ========================================================================== */
:root{
  --sbg-ink:        #0d1526;
  --sbg-ink-2:      #16223a;
  --sbg-line:       #1f2f4d;
  --sbg-text:       #dbe6f5;
  --sbg-muted:      #7e93ac;
  --sbg-label:      #66809f;
  --sbg-accent-1:   #2a78d6;
  --sbg-accent-2:   #cfa53a;
  --sbg-critical:   #ffb4a8;
  --sbg-dot:        #cfa53a;
}

/* ---- Sidebar shell ----
   The sidebar used to pin the clock/brand/quicklinks in their own
   non-scrolling region, with only the navgroups below scrolling in
   their own box. On shorter/zoomed-in viewports — and manufacturing's
   workspace adds a 5th quicklink (Executive360) that others don't have
   — that pinned region could eat enough height that an expanded
   accordion group had nowhere left to show its own links: the group
   LOOKED frozen because the only thing that could scroll was a sliver
   below it. The sidebar now scrolls as ONE unit (quicklinks + navgroups
   together) so an opened dropdown is always reachable by scrolling the
   whole rail, regardless of how many quicklinks or open groups there
   are. Only the footer stays visually pinned, via sticky (not a second
   independent scroll box), so it never blocks content above it. ---- */
.sidebar{
  position:fixed;inset:0 auto 0 0;width:255px;
  background:var(--sbg-ink);color:var(--sbg-text);
  display:flex;flex-direction:column;
  z-index:10;overflow-y:auto;overflow-x:hidden;
}
.sidebar::-webkit-scrollbar{width:5px}
.sidebar::-webkit-scrollbar-thumb{background:#2a3c5c;border-radius:10px}

.sidebar-pinned-top{flex:0 0 auto;padding:24px 17px 6px}
.sidebar-scroll{flex:0 0 auto;padding:2px 17px 10px}

.sideclock{margin-bottom:16px;padding-bottom:14px;border-bottom:1px solid var(--sbg-line)}
.sideclock strong{display:block;font-size:19px;font-weight:700;color:#eaf1fb;font-variant-numeric:tabular-nums}
.sideclock span{display:block;font-size:10px;color:var(--sbg-muted);margin-top:2px;text-transform:uppercase;letter-spacing:.5px}

.brand{display:flex;gap:12px;align-items:center}
.brand .mark{
  width:44px;height:44px;border-radius:13px;flex:0 0 auto;
  background:linear-gradient(145deg,var(--sbg-accent-1),var(--sbg-accent-2));
  display:grid;place-items:center;font-weight:800;color:#0d1526;letter-spacing:.5px;
}
.brand strong{display:block;font-size:14px;color:inherit}
.brand span{display:block;font-size:11px;color:var(--sbg-muted);margin-top:3px}

.quicklinks{margin-top:18px}
.navgroups{padding-bottom:10px}

/* Each group is its own rounded surface so the open/closed state reads
   as a real toggle, not just a rotating arrow. */
.navgroup{margin-bottom:3px;border-radius:11px;overflow:hidden}
.navlabel{
  cursor:pointer;list-style:none;font-size:10px;letter-spacing:1.3px;font-weight:700;
  color:var(--sbg-label);padding:11px 13px;display:flex;align-items:center;gap:8px;
  border-radius:10px;transition:background .12s,color .12s;
}
.navlabel::-webkit-details-marker{display:none}
.navlabel .navlabel-dot{
  width:6px;height:6px;border-radius:50%;flex:0 0 auto;background:var(--sbg-label);
  transition:background .15s,box-shadow .15s;
}
.navlabel span{flex:1;min-width:0}
.navlabel::after{
  content:'';flex:0 0 auto;width:7px;height:7px;
  border-right:1.6px solid var(--sbg-label);border-bottom:1.6px solid var(--sbg-label);
  transform:rotate(-45deg);transition:transform .2s ease,border-color .15s;
}
.navgroup[open]>.navlabel::after{transform:rotate(45deg)}
.navgroup:hover .navlabel{background:var(--sbg-ink-2);color:#c7d7ec}
.navgroup[open]>.navlabel{background:var(--sbg-ink-2);color:#eaf1fb}
.navgroup[open]>.navlabel .navlabel-dot{background:var(--sbg-accent-1);box-shadow:0 0 0 3px rgba(42,120,214,.22)}
.navgroup[open]>.navlabel::after{border-color:var(--sbg-accent-1)}

/* Smooth expand/collapse of each group's link list (grid-rows trick —
   no JS height measuring, no layout thrash while it animates). */
.navgroup .navbody{display:grid;grid-template-rows:0fr;transition:grid-template-rows .22s ease}
.navgroup[open]>.navbody{grid-template-rows:1fr}
.navgroup .navbody>div{overflow:hidden;padding-left:6px}

/* A group inside a group (e.g. School → Classes & results): a smaller heading, indented under its parent. */
.navsubgroup{margin:2px 0 2px 6px;border-left:1px solid rgba(160,190,230,.16);border-radius:0 10px 10px 0}
.navsubgroup>.navlabel{font-size:12px;letter-spacing:.2px;font-weight:600;text-transform:none;padding:9px 11px}
.navsubgroup>.navbody>div{padding-left:4px}

.navitem{
  display:flex;align-items:center;gap:12px;padding:11px 13px;border-radius:10px;
  color:#a9b8cc;font-size:13px;margin:3px 0;text-decoration:none;transition:background .12s,color .12s;
}
.navitem:hover{background:var(--sbg-ink-2);color:#fff}
.navitem b{width:20px;text-align:center;font-style:normal;flex:0 0 auto;display:inline-flex;justify-content:center}
.navitem.critical{color:var(--sbg-critical)}
.navitem.critical:hover{color:#fff}

.sidefoot{
  flex:0 0 auto;border-top:1px solid var(--sbg-line);padding:15px 17px;font-size:12px;color:var(--sbg-muted);
  position:sticky;bottom:0;background:var(--sbg-ink);
}
.dot{display:inline-block;width:7px;height:7px;background:var(--sbg-dot);border-radius:50%;margin-right:7px}

/* ---- Right column: topbar + page content ----
   The topbar now continues the sidebar's dark ink theme (previously a
   plain white bar with almost nothing in it at desktop width — the
   "blank white" the tenant name now fills) plus a thin brand-to-gold
   gradient line under it, matching the sidebar's own accent. Only the
   chrome darkens; .app-main / page content underneath stays light. */
.main{margin-left:255px;min-height:100vh;display:flex;flex-direction:column}
.topbar{
  height:74px;background:var(--sbg-ink);border-bottom:1px solid var(--sbg-line);
  display:flex;align-items:center;justify-content:space-between;padding:0 30px;
  position:sticky;top:0;z-index:8;
}
.topbar::after{
  content:'';position:absolute;left:0;right:0;bottom:-1px;height:2px;
  background:linear-gradient(90deg,var(--sbg-accent-1),var(--sbg-accent-2) 55%,transparent);
}
.topbar-actions{display:flex;align-items:center;gap:14px;margin-left:auto}
.mobilebrand{display:none;color:#eaf1fb}
.navtoggle{display:none}

/* Tenant identity strip: fills the space that used to sit empty on the
   left of the topbar with the company's own name, icon and industry
   edition — same one block of markup renders correctly for every
   industry since it reads from the existing workspace_edition context
   processor rather than anything hospital-specific. */
.topbar-brand{display:flex;align-items:center;gap:11px;min-width:0}
.topbar-brand .tb-mark{
  width:34px;height:34px;border-radius:10px;flex:0 0 auto;
  background:linear-gradient(135deg,var(--sbg-accent-1),var(--sbg-accent-2));
  display:grid;place-items:center;color:#0d1526;font-size:15px;
  box-shadow:0 2px 6px rgba(0,0,0,.35);
}
.topbar-brand .tb-text{min-width:0;line-height:1.3}
.topbar-brand .tb-text strong{
  display:block;font-size:13px;font-weight:700;color:#eaf1fb;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:280px;
}
.topbar-brand .tb-text .tb-sub{
  display:flex;align-items:center;gap:5px;font-size:10px;color:var(--sbg-muted);
  text-transform:uppercase;letter-spacing:.04em;margin-top:2px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:280px;
}
.topbar-brand .tb-sub .tb-dot{width:4px;height:4px;border-radius:50%;background:var(--sbg-accent-2);flex:0 0 auto}

/* The greeting/sign-out chip on the right was styled for a white bar —
   repoint its text/icon colors for the dark one. Scoped under .topbar
   so design-system.css's original (white-bar) rules never have to
   change for the pages that don't use this chrome. */
.topbar .header-greeting strong{color:#eaf1fb}
.topbar .header-greeting small{color:var(--sbg-muted)}
.topbar .header-icon-link{color:#9fb3cc}
.topbar .header-icon-link:hover{background:#1f2f4d}

/* design-system.css hides .header-user-zone below 1420px — a rule
   written for the OLD top-nav (.app-header/.app-nav) layout to make
   room for its nav links, before this sidebar+topbar existed. It shares
   the .header-user-zone class name, so it was also hiding the greeting/
   avatar/sign-out chip in THIS topbar at any ordinary window width
   below 1420px CSS px (most laptops, or a maximized window under
   Windows display scaling). The sidebar layout has its own breakpoints
   (1050px icon rail, 760px drawer) that already free up plenty of room,
   so this chip stays visible here at every width. */
.topbar .header-user-zone{display:flex!important;min-width:0}

/* ---- ≤1050px: icon-only rail. ---- */
@media(max-width:1050px){
  .sidebar{width:75px}
  .sidebar-pinned-top{padding:22px 8px 6px}
  .sidebar-scroll{padding:2px 8px 10px}
  .sidebar .brand>div:last-child,.navitem span,.navlabel span,.sidefoot,.sideclock{display:none}
  .navlabel::after,.navlabel-dot{display:none}
  .navitem{justify-content:center}
  .main{margin-left:75px}
}

/* Between 761px and 1050px there's no room for a summary/click affordance,
   so every group's routes stay reachable as icons regardless of its
   open/closed state (matches the icon rail's job: every route, always
   one tap away). Below 761px the sidebar becomes the full-width drawer
   instead, where there IS room, so the real accordion behavior applies
   there too — scoped out of this rule with the min-width guard. */
@media(max-width:1050px) and (min-width:761px){
  .navgroup .navbody{grid-template-rows:1fr}
}

/* ---- ≤760px: sidebar becomes a full off-canvas drawer ---- */
@media(max-width:760px){
  .sidebar{display:none}
  .main{margin:0}
  .topbar{padding:0 16px}
  .mobilebrand{display:block;font-weight:800}
  .topbar-brand{display:none}
  .navtoggle{
    display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;
    border:0;background:#f4f7fb;color:#122033;border-radius:10px;font-size:17px;
    margin-right:12px;cursor:pointer;
  }
  .sidebar.show{display:flex;width:250px;z-index:60;box-shadow:0 20px 60px rgba(5,15,30,.35)}
  .sidebar.show .sidebar-pinned-top{padding:24px 17px 6px}
  .sidebar.show .sidebar-scroll{padding:2px 17px 10px}
  .sidebar.show .brand>div:last-child,.sidebar.show .navitem span,.sidebar.show .navlabel span,.sidebar.show .navlabel-dot,.sidebar.show .sidefoot,.sidebar.show .sideclock{display:block}
  .sidebar.show .navlabel{display:flex}
  .sidebar.show .navlabel::after{display:block}
  .navbackdrop{display:none}
  .navbackdrop.show{display:block;position:fixed;inset:0;background:rgba(6,14,28,.55);z-index:50}
}

/* Keep the sidebar/topbar out of printed output, same as the old
   .app-header was excluded on print-oriented templates (receipts,
   invoices, offer letters, ...). */
@media print{
  .sidebar,.topbar,.navbackdrop{display:none !important}
  .main{margin-left:0 !important}
}
