/* ═══════════════════════════════════════════════════════════════════════════
   SBR Air — shared/ui/sbr-air.shell.css  (V2 application shell)
   Charcoal sidebar + white header for the Dashboard, per Visual Design System v1.1 §10 and the frozen Jobs
   Operations Board. Uses the V1 tokens (the sidebar and header carry class "sa-scope").
   Selectors are limited to the two shell containers (.sa-scope.sa-nav, .sa-scope.sa-topbar), the nav scrim and
   the Dashboard layout container (body.mode-admin #sbr-admin-app). Module screens inside .content are untouched.
   Responsive (v1.1 §10, §23): ≥ 1280 expanded 232 px (user may collapse to the 64 px rail, remembered);
   1024–1279 rail 64 px; < 1024 hidden — the header menu button opens the nav as a 280 px overlay.
   State classes are set by shared/ui/sbr-air.shell.js: is-rail, is-collapsed, is-overlay.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Sidebar (navigation) ───────────────────────────────────────────────── */
.sa-scope.sa-nav {
  width: var(--sa-nav-w); flex: none; height: 100vh; position: sticky; top: 0; z-index: var(--sa-z-nav);
  display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto; overflow-x: hidden;
  background: var(--sa-nav); color: var(--sa-nav-text);
}
.sa-scope.sa-nav .sa-nav__brand { flex: none; display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: var(--sa-nav-text-active); min-height: 44px; }
.sa-scope.sa-nav .sa-nav__mark { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: var(--sa-r-lg); background: var(--sa-brand); color: #0F2A22; font-size: 12px; font-weight: 700; letter-spacing: .3px; }
.sa-scope.sa-nav .sa-nav__brand-text { min-width: 0; line-height: 1.15; }
.sa-scope.sa-nav .sa-nav__brand-text b { display: block; font-size: var(--sa-text-md); font-weight: var(--sa-weight-semibold); white-space: nowrap; }
.sa-scope.sa-nav .sa-nav__brand-text small { display: block; font-size: var(--sa-text-xs); color: var(--sa-nav-section); white-space: nowrap; }
.sa-scope.sa-nav .sa-nav__section { flex: none; padding: 14px 10px 6px; font-size: 11px; font-weight: var(--sa-weight-semibold); letter-spacing: .6px; text-transform: uppercase; color: var(--sa-nav-section); white-space: nowrap; }
.sa-scope.sa-nav .sa-nav__group { display: flex; flex-direction: column; gap: 2px; }
.sa-scope.sa-nav .sa-nav__spacer { height: 10px; flex: none; }

/* Items: the existing .sb-item buttons (routing), the Estimator M1 preview entry (div.sb-item[role=button])
   and the footer utilities (.sa-nav__item). */
.sa-scope.sa-nav .sb-item, .sa-scope.sa-nav .sa-nav__item {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; flex: none; padding: 0 10px;
  border: 0; border-radius: var(--sa-r-md); background: none; color: var(--sa-nav-text);
  font: inherit; font-size: var(--sa-text-md); font-weight: var(--sa-weight-medium); text-align: left;
  white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background-color var(--sa-dur-fast) var(--sa-ease), color var(--sa-dur-fast) var(--sa-ease);
}
.sa-scope.sa-nav .sb-item svg, .sa-scope.sa-nav .sa-nav__item svg { width: 18px; height: 18px; flex: none; }
.sa-scope.sa-nav .sa-nav__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sa-scope.sa-nav .sb-item:hover, .sa-scope.sa-nav .sa-nav__item:hover { background: var(--sa-nav-hover); color: var(--sa-nav-text-active); }
.sa-scope.sa-nav .sb-item.active, .sa-scope.sa-nav .sb-item[aria-current="page"] { background: var(--sa-nav-active); color: var(--sa-nav-text-active); }
.sa-scope.sa-nav .sb-item.active::before, .sa-scope.sa-nav .sb-item[aria-current="page"]::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--sa-nav-indicator);
}
.sa-scope.sa-nav .sb-item:focus-visible, .sa-scope.sa-nav .sa-nav__item:focus-visible { outline: 2px solid var(--sa-nav-indicator); outline-offset: -2px; }

/* Count badges (existing ids and update code; restyled). Gray by default; amber where the count means
   "needs action" (approved V2-D5: Overview flags, Pending timesheets, Clock-In GPS missing). */
.sa-scope.sa-nav .sb-badge {
  margin-left: auto; display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 18px; padding: 0 6px;
  border-radius: var(--sa-r-full); background: var(--sa-nav-count-bg); color: var(--sa-nav-count-text);
  font-size: var(--sa-text-xs); font-weight: var(--sa-weight-medium); font-variant-numeric: tabular-nums; line-height: 1;
}
.sa-scope.sa-nav #ov-flag-badge, .sa-scope.sa-nav #ts-pending-badge, .sa-scope.sa-nav .sb-item[onclick*="clockin"] .sb-badge {
  background: var(--sa-amber-subtle); color: var(--sa-amber-text);
}

.sa-scope.sa-nav .sa-nav__foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--sa-nav-divider); display: flex; flex-direction: column; gap: 2px; }
.sa-scope.sa-nav .sa-nav__collapse { color: var(--sa-nav-section); }

/* Rail (64 px): icons only; labels stay in the accessible name; tooltip on hover / focus. */
.sa-scope.sa-nav.is-rail { width: var(--sa-nav-rail); padding: 14px 8px; }
.sa-scope.sa-nav.is-rail .sa-nav__brand { justify-content: center; padding: 4px 0 14px; }
.sa-scope.sa-nav.is-rail .sa-nav__brand-text,
.sa-scope.sa-nav.is-rail .sa-nav__label {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.sa-scope.sa-nav.is-rail .sa-nav__section { height: 10px; padding: 0; overflow: hidden; color: transparent; }
.sa-scope.sa-nav.is-rail .sb-item, .sa-scope.sa-nav.is-rail .sa-nav__item { justify-content: center; padding: 0; }
.sa-scope.sa-nav.is-rail .sb-item.active::before, .sa-scope.sa-nav.is-rail .sb-item[aria-current="page"]::before { left: -8px; }
.sa-scope.sa-nav.is-rail .sb-badge { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 11px; }
.sa-scope.sa-nav.is-rail .sb-item[data-sa-label]:hover::after, .sa-scope.sa-nav.is-rail .sb-item[data-sa-label]:focus-visible::after,
.sa-scope.sa-nav.is-rail .sa-nav__item[data-sa-label]:hover::after, .sa-scope.sa-nav.is-rail .sa-nav__item[data-sa-label]:focus-visible::after {
  content: attr(data-sa-label); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  padding: 6px 8px; border-radius: var(--sa-r-md); background: var(--sa-text); color: var(--sa-text-inverse);
  font-size: var(--sa-text-xs); line-height: var(--sa-lh-xs); font-weight: var(--sa-weight-medium); white-space: nowrap;
  box-shadow: var(--sa-shadow-md); pointer-events: none; z-index: var(--sa-z-popover);
}
.sa-scope.sa-nav.is-rail { overflow: visible; }

/* Overlay (below 1280 px when opened from the header menu button). */
.sa-scope.sa-nav.is-overlay {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sa-nav-overlay); height: auto; z-index: 9500;
  box-shadow: var(--sa-shadow-lg); overflow-y: auto;
}
.sa-scope.sa-nav-scrim { position: fixed; inset: 0; z-index: 9499; background: var(--sa-scrim); }
.sa-scope.sa-nav-scrim[hidden] { display: none; }
@media (max-width: 1023px) {
  .sa-scope.sa-nav:not(.is-overlay) { display: none; }
}
@media (max-width: 1279px) {
  .sa-scope.sa-nav .sa-nav__collapse { display: none; }
}

/* ── Header (top bar) ───────────────────────────────────────────────────── */
.sa-scope.sa-topbar {
  flex: none; height: 56px; display: flex; align-items: center; gap: var(--sa-space-3); padding: 0 var(--sa-space-5);
  background: var(--sa-surface); border-bottom: 1px solid var(--sa-border); color: var(--sa-text); position: relative; z-index: var(--sa-z-sticky);
}
.sa-scope.sa-topbar .sa-icon-btn svg { width: 20px; height: 20px; display: block; }
.sa-scope.sa-topbar .sa-account__menu .sa-btn svg { width: 16px; height: 16px; flex: none; }
.sa-scope.sa-topbar .sa-topbar__menu { display: none; margin-left: -6px; }
@media (max-width: 1279px) { .sa-scope.sa-topbar .sa-topbar__menu { display: inline-grid; } }
.sa-scope.sa-topbar .sa-topbar__title { flex: 1; min-width: 0; margin: 0; font-size: var(--sa-text-xl); line-height: var(--sa-lh-xl); font-weight: var(--sa-weight-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-scope.sa-topbar .sa-topbar__live { display: inline-flex; align-items: center; gap: 6px; font-size: var(--sa-text-xs); color: var(--sa-text-3); white-space: nowrap; }
.sa-scope.sa-topbar .sa-topbar__live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sa-green); }
.sa-scope.sa-topbar .sa-topbar__clock { font-size: var(--sa-text-xs); color: var(--sa-text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sa-scope.sa-topbar #tb-primary-btn:empty { display: none; }
.sa-scope.sa-topbar .sa-topbar__bell { position: relative; }
.sa-scope.sa-topbar .sa-topbar__bell .sa-count { position: absolute; top: -2px; right: -4px; min-width: 18px; height: 16px; padding: 0 5px; font-size: 11px; }
.sa-scope.sa-topbar .sa-account { position: relative; }
.sa-scope.sa-topbar .sa-account__btn { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 6px; border-radius: var(--sa-r-md); cursor: pointer; }
.sa-scope.sa-topbar .sa-account__btn:hover { background: var(--sa-surface-hover); }
.sa-scope.sa-topbar .sa-account__btn:focus-visible { outline: 2px solid var(--sa-focus); outline-offset: 2px; }
.sa-scope.sa-topbar .sa-account__avatar { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--sa-slate-subtle); color: var(--sa-slate-text); font-size: 11px; font-weight: var(--sa-weight-semibold); }
.sa-scope.sa-topbar .sa-account__who { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; max-width: 160px; }
.sa-scope.sa-topbar .sa-account__name { font-size: var(--sa-text-sm); font-weight: var(--sa-weight-medium); color: var(--sa-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-scope.sa-topbar .sa-account__role { font-size: var(--sa-text-xs); color: var(--sa-text-3); white-space: nowrap; }
.sa-scope.sa-topbar .sa-account__menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; padding: 6px; z-index: var(--sa-z-popover); background: var(--sa-surface); border: 1px solid var(--sa-border); border-radius: var(--sa-r-lg); box-shadow: var(--sa-shadow-md); }
.sa-scope.sa-topbar .sa-account__menu[hidden] { display: none; }
.sa-scope.sa-topbar .sa-account__meta { padding: 8px 10px 10px; border-bottom: 1px solid var(--sa-border); margin-bottom: 6px; font-size: var(--sa-text-xs); color: var(--sa-text-3); }
.sa-scope.sa-topbar .sa-account__menu .sa-btn { width: 100%; justify-content: flex-start; }
@media (max-width: 1023px) {
  .sa-scope.sa-topbar { padding: 0 var(--sa-space-4); gap: var(--sa-space-2); }
  .sa-scope.sa-topbar .sa-topbar__live, .sa-scope.sa-topbar .sa-topbar__clock, .sa-scope.sa-topbar .sa-account__who { display: none; }
}

/* ── Workspace canvas for migrated modules (VIEWS[id].sa === true; none in V2) ── */
body.mode-admin #sbr-admin-app .main.sa-workspace-migrated .content { background: #F6F5F2; }

/* ── SBR Air V8: page tabs for grouped navigation (Dispatch, Workforce). A white strip that continues the top bar,
   so it reads the same above migrated (warm canvas) and not-yet-migrated views. ── */
body.mode-admin #sbr-admin-app .sa-scope.sa-view-tabs {
  margin: -24px -24px 20px; padding: 0 var(--sa-space-5); background: var(--sa-surface); border-bottom: 1px solid var(--sa-border);
  position: sticky; top: -24px; z-index: 5;
}
body.mode-admin #sbr-admin-app .sa-scope.sa-view-tabs[hidden] { display: none; }
body.mode-admin #sbr-admin-app .sa-scope.sa-view-tabs .sa-tabs { border-bottom: 0; }
@media (max-width: 1023px) { body.mode-admin #sbr-admin-app .sa-scope.sa-view-tabs { padding: 0 var(--sa-space-4); } }
/* Workforce carries the Clock-In "GPS missing" count (needs action → amber, approved V2-D5). */
.sa-scope.sa-nav .sb-item[data-sa-group="workforce"] .sb-badge { background: var(--sa-amber-subtle); color: var(--sa-amber-text); }
/* G3 (Nov 6 2026): phone top bar — the page title keeps priority; a long primary-button label truncates instead
   of squeezing the title to one letter (e.g. "Export ADP Run CSV"). The full label stays available as its tooltip. */
@media (max-width: 767px) {
  .sa-scope.sa-topbar .sa-topbar__title { flex: 1 1 auto; min-width: 112px; font-size: var(--sa-text-lg); line-height: var(--sa-lh-lg); }
  .sa-scope.sa-topbar #tb-primary-btn { display: block; flex: 0 1 auto; min-width: 0; max-width: 46vw; padding: 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 42px; font-size: var(--sa-text-sm); }
  .sa-scope.sa-topbar #tb-primary-btn:empty, .sa-scope.sa-topbar #tb-primary-btn[hidden] { display: none; }
}
