/* it-64 — navigation drawer + app shell; it-1270 (BPDGo#450) — ONE menu at every width: the drawer the header's menu
   button opens over the page, with a dimmed backdrop (the phone's, made the default). The always-on column and its
   72px rail are gone, so every page has the window's full width.
   Theme-aware via MD3 tokens; the only raw value is the drawer's width. */

:root {
  --nav-w: 264px;      /* the drawer */
}

.app-root { display: block; }

/* Header + shell stack vertically. The drawer is fixed (out of the flow), so main is the shell's one item and takes its
   whole width; min-height fills the viewport below the app bar. */
.app-shell {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - var(--app-bar-h));
}

/* --- Drawer ------------------------------------------------------------- */

/* The drawer: over the page from the app bar down, slid off to the left until the menu button opens it. Closed, it is
   also invisible — not just off-screen — so Tab and a screen reader never wander into a menu nobody can see; the
   visibility change waits for the slide-out to finish. It scrolls inside itself (a long menu on a short screen —
   several groups open — reaches its last item without scrolling the page behind the backdrop). z 1250 (it-1270): over
   everything that can reach the left edge — the contact quickview (45), a dialog's scrim (50), the bottom-right cluster
   (1200: the call box's expanded contact panel spans to the window's left edge now) — under the floating boxes
   (1300+), compose (1400) and the incoming-call popup (1500); it starts under the app bar (60), so never overlaps it.
   The backdrop stays at 46, under the cluster, so Messages and the call box stay usable beside an open menu (a click
   there closes it: nav-drawer.js). Ladder: static/css/components/quickview.css. */
.nav-drawer {
  position: fixed;
  top: var(--app-bar-h);
  left: 0;
  bottom: 0;
  z-index: 1250;
  box-sizing: border-box;
  width: var(--nav-w);
  max-width: calc(100vw - 3.5rem); /* a sliver of the page stays beside it on the narrowest phone, to tap away */
  /* A long un-wrappable label (an Artifacts report title in a folder group, it-120.7) truncates inside the width. */
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.75rem 0.6rem;
  background: var(--md-sys-color-surface-container-low);
  border-right: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-sys-elevation-level2);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized),
              visibility 0s linear var(--md-sys-motion-duration-medium2);
}
.app-shell.nav-open .nav-drawer {
  transform: translateX(0);
  visibility: visible;
  transition: transform var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized), visibility 0s;
}

.app-shell main {
  flex: 1 1 auto;
  min-width: 0; /* let wide tables / the email canvas shrink instead of blowing out the row */
  /* NOTE: main is deliberately NOT a stacking context here. The GrapesJS trap below
     scopes that to .main--bleed only — making EVERY page's main a context trapped a
     regular page's fixed overlays (e.g. the SMS-template editor drawer, z-index 1200)
     BELOW the z-index:60 app bar, so their top edge became unclickable under it. */
}

/* A full-bleed editor is a fixed-height pane (base.css: height 100vh - app-bar-h), pinned to the viewport below the
   sticky app bar (it-70: then so an always-on menu taller than one screen scrolled past it; since it-1270 the menu is
   fixed and scrolls itself, and the pin just keeps the pane in place). position:sticky makes
   the stacking context that TRAPS GrapesJS's internal z-indexes (up to ~9,999,994)
   inside main; z-index:1 keeps that context painting BELOW the z-index:60 app bar (and the menu).
   Scoped to .main--bleed so a regular page's main is NOT a context (its fixed
   overlays must be free to cover the app bar). */
.app-shell main.main--bleed {
  position: sticky;
  top: var(--app-bar-h);
  z-index: 1;
}

.nav-drawer__nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* Rows: leaf links, group headers and child links share one set of row metrics. */
.nav-item,
.nav-group__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  height: 44px;
  padding: 0 0.75rem;
  border: none;
  background: none;
  border-radius: var(--md-sys-shape-corner-full);
  color: var(--md-sys-color-on-surface-variant);
  font-family: var(--md-sys-typescale-label-large-font);
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard),
              color var(--md-sys-motion-duration-short2) var(--md-sys-motion-easing-standard);
}
.nav-item:hover,
.nav-group__header:hover {
  color: var(--md-sys-color-on-surface);
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
  text-decoration: none;
}

.nav-item__icon {
  font-size: 22px;
  flex: 0 0 auto;
}
.nav-item__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap; /* a long name (an Artifacts report title, it-120.7) truncates; it never widens the drawer */
}

/* Active row — matches the contact-type switcher's .is-active language. */
.nav-item.is-active {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 600;
}

/* Child rows sit under a group header — indented, no icon, slightly shorter. Class-driven (not x-show), so the
   pre-paint shim in base.html and Alpine agree on one class. */
.nav-group__items {
  display: none;
  flex-direction: column;
  gap: 0.1rem;
  margin: 0.1rem 0 0.25rem;
}
.nav-group.is-open > .nav-group__items { display: flex; }
.nav-item--child {
  height: 38px;
  padding-left: 2.9rem; /* align labels under the header label (icon + gap) */
}

/* Group header chevron rotates when open. */
.nav-group__chevron {
  font-size: 20px;
  flex: 0 0 auto;
  transition: transform var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.nav-group.is-open .nav-group__chevron { transform: rotate(180deg); }

/* The app bar's menu button opens and closes the drawer, at every width. */
.nav-menu-btn { display: inline-flex; color: var(--md-sys-color-on-surface); }

/* The backdrop behind the open drawer: a click on it closes the menu. */
.nav-backdrop { display: none; }
.app-shell.nav-open .nav-backdrop {
  display: block;
  position: fixed;
  inset: var(--app-bar-h) 0 0 0;
  z-index: 46; /* it-190: over the contact quickview (45), under the drawer (47) */
  background: var(--md-sys-color-scrim);
  opacity: 0.32;
}

/* it-80.8 — config-health counts in the nav. The component is the house .count-pill (floating.css);
 * only its PLACEMENT is a nav concern, which is all that belongs here. An earlier cut of this
 * iteration invented a .nav-badge with its own colours and radius — a fourth way to draw a small
 * tonal number, beside .count-pill and the .badge family. Deleted. */
.nav-item .count-pill,
.nav-group__header .count-pill { margin-left: auto; }
/* The chevron follows the count, so a count cannot push it off the row. */
.nav-group__header .count-pill + .nav-group__chevron { margin-left: 0.375rem; }

/* it-120.7 — an Artifacts folder group with nothing the viewer may see in it yet: a muted, non-link row. */
.nav-item--empty { color: var(--md-sys-color-on-surface-variant); font-style: italic; cursor: default; }
.nav-item--empty:hover { background: none; }
