/* BioRadius app frame (docs/TODO.md A1): the left sidebar (brand, menu, account at the foot), the top bar and the
   content column. base.css imports it (the LIMS, PK, Calls and Project management); the eCRF loads it on its own,
   after /ui/tokens.css. Markup: .shell > nav.side#side (.brand, a.nav[.on], hr, .side-foot) + .main > header.top +
   the content. Colours come from the app's tokens (--accent*, --hover, --line, --ink*, --surface; --shell-bg for
   the phone drawer, else --paper). */

.shell { display: flex; min-height: 100vh; }
.side-scrim { display: none; }
.side { width: 232px; flex-shrink: 0; padding: 20px 14px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
/* the visible height: on a phone 100vh includes what the browser's address bar covers, which hid the account at the
   foot (owner, 14 Nov); dvh follows the bar; older browsers keep 100vh */
@supports (height: 100dvh) { .side { height: 100dvh; } }
/* A strip across the top (a test copy's "TEST COPY", Calls' "BETA · TEST MODE"; owner, 15 Nov: "the test mode banner
   makes the top scroll a little funny"): it stays pinned at the top, one line high, and the menu and top bar sit
   under it, so the menu's foot (the account) is never pushed below the screen and nothing jumps when scrolling.
   Screening pins its strip its own way (theme.css), with the same --ui-strip. */
body:has(> .test-copy-banner), body:has(> .beta-strip) { --ui-strip: 34px; }
body > .test-copy-banner, body > .beta-strip { position: sticky; top: 0; z-index: 70; box-sizing: border-box; height: 34px;
  padding-block: 0; line-height: 33px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell > .side { top: var(--ui-strip, 0px); height: calc(100vh - var(--ui-strip, 0px)); }
@supports (height: 100dvh) { .shell > .side { height: calc(100dvh - var(--ui-strip, 0px)); } }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 26px; color: var(--ink); }
/* the app's name with the app switcher (nine dots, the assistant package) on its right (owner, 14 Nov) */
.side-head { display: flex; align-items: center; gap: 4px; padding-bottom: 20px; }
.side-head .brand { flex: 1; min-width: 0; padding-bottom: 6px; }
/* the same space above and below the name in every app (Screening's and the HR Portal's own .brand rules add 24 px
   below), so the grid beside it sits on the name's middle (owner, 14 Nov: "center consistently so it looks symmetric") */
.side .side-head .brand { padding-top: 6px; padding-bottom: 6px; }
.side-head .side-apps { flex: none; margin: 0 2px 0 0; }
.brand-name { font-family: var(--ui-font-display); font-size: 23px; line-height: 1; }
.brand .eyebrow { font-size: 10px; margin-top: 4px; }
.nav { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px; border-radius: 8px; color: var(--ink-2); font-size: 14px; }
.nav:hover { background: var(--hover); color: var(--ink); }
.nav.on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.nav .pill { margin-left: auto; height: 20px; padding: 0 7px; }
.side hr { border: 0; height: 1px; background: var(--line); margin: 12px 10px; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; position: relative; }
/* People / who has access and the audit trail sit at the foot of the menu, just above the account (owner, 15 Nov:
   "audit trail ... just above the username ... move people and similar things down") */
.side-end { margin-top: auto; padding-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.side-end + .side-foot { margin-top: 0; }
.me { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.me:hover { background: var(--hover); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-soft-ink); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.me-sub { font-size: 12px; color: var(--muted); line-height: 1.3; }
.menu { position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: none; z-index: 20; }
.menu.open { display: block; }
.menu a, .menu button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.menu a:hover, .menu button:hover { background: var(--hover); }
/* the theme switch (Light / Dark / System): in the account menu and on every app's Settings page */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.seg button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 10px;
  font: inherit; font-size: 13px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; }
.seg button:hover { background: var(--hover); color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-soft-ink); border-color: transparent; }
.menu .seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px 4px; }
.menu .seg button { justify-content: center; font-size: 12px; padding: 6px 4px; border: 1px solid var(--line); }
.menu .seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-soft-ink); border-color: transparent; }
.main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line); min-height: 100vh; }
.top { height: 64px; flex-shrink: 0; padding: 0 40px; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 10px; width: 440px; max-width: 100%; height: 40px; padding: 0 12px 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex-grow: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; color: var(--ink); }
.kbd { font: 11px "IBM Plex Mono", monospace; padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); }
.content { padding: 32px 40px 48px; display: flex; flex-direction: column; gap: 24px; max-width: 1400px; width: 100%; }
.btn.menu-toggle { display: none; }

/* Phones: the sidebar becomes a drawer (the menu button in the top bar opens it: [data-toggle-side]). The LIMS-style
   apps still carry their own copy of these lines; the eCRF uses these. */
@media (max-width: 820px) {
  .side { position: fixed; z-index: 60; left: 0; top: 0; overflow-y: auto; background: var(--shell-bg, var(--paper)); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
          padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .side.open { transform: none; }
  /* behind the open menu (drawer.js, owner 14 Nov): a very slight dark fade over the page; a tap on it only closes the
     menu, it never reaches a button underneath */
  .side-scrim { display: block; position: fixed; inset: 0; z-index: 59; background: var(--ui-scrim); opacity: 0;
    pointer-events: none; transition: opacity .2s; -webkit-tap-highlight-color: transparent; }
  .side-scrim.on { opacity: 1; pointer-events: auto; }
  .shell > .side.open { z-index: 61; }               /* the open menu above its fade (an app's .side may set less) */
  /* the open menu is pinned to the top and the bottom of the screen, not given the screen's height: a fast flick
     moves a phone browser's address bar and the screen's height catches up late, which showed a gap under the
     account (owner, 15 Nov); while it is open the page under it doesn't scroll (drawer.js: html.br-side-open) */
  .shell > .side { top: var(--ui-strip, 0px); bottom: 0; height: auto; overscroll-behavior: contain; }
  html.br-side-open { overflow: hidden; }          /* (not body: that would unpin the strip above) */
  .btn.menu-toggle { display: inline-flex; }
  .main { border-left: 0; }
  .top { padding: 0 16px; gap: 10px; }
  /* the top bar stays at the top while the page scrolls (owner, 14 Nov: "so we can click on the side menu / AI button
     even when scrolled down"); under the open menu and its fade (z 59-61), over the page */
  .main > .top { position: sticky; top: var(--ui-strip, 0px); z-index: 40; background: var(--shell-bg, var(--paper)); }
  .search { min-width: 0; }
  .content { padding: 20px 16px 40px; }
  .hide-sm { display: none; }
}
@media print {
  .side, .top { display: none !important; }
  .main { border-left: 0; }
}
