/*
 * App shell — CR-A116-16 (dashboard-r1.html §1 "Full desktop page", the
 * exemplar page: "Replaces client-portal.js renderShell() + renderDashboard()").
 *
 * SHELL ONLY: sidebar, brand lockup, nav, user chip, Powered-by, main pane
 * chrome. Dashboard CONTENT (metrics / next-delivery / recent orders /
 * quick links) is CR-A116-4 — out of scope here, see views/dashboard.js.
 *
 * Rules below are copied verbatim from dashboard-r1.html's <style> block
 * (selectors under "APP SHELL" / "main pane") — no values changed. Requires
 * tokens.css.
 */

.shell {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); overflow: hidden; display: flex; min-height: 100vh;
}

.sidebar {
  width: 236px; flex: 0 0 236px; background: var(--bg); border-right: 1px solid var(--line);
  padding: var(--sp-6) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-6);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-2); min-width: 0; }
.brand-text { min-width: 0; }

.brand-badge-york {
  width: 40px; height: 40px; border-radius: var(--r-md); background: var(--navy);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-badge-york .yk { color: #fff; font-weight: 800; font-size: 18px; }
.brand-name-york { font-weight: 800; font-size: 16px; color: var(--ink); line-height: 1.15; letter-spacing: .01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub-york { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.brand-badge-york img { width: 100%; height: 100%; object-fit: contain; border-radius: var(--r-md); }

.powered-by { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--faint); padding: 0 var(--sp-2); margin-top: 10px; }
.powered-by .pb-mark { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.powered-by .pb-badge { width: 14px; height: 14px; border-radius: 3px; background: var(--navy); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.powered-by .pb-badge .pb-yn { color: #fff; font-weight: 800; font-size: 7.5px; line-height: 1; }
.powered-by .pb-name { font-weight: 700; color: var(--navy); font-size: 11px; }
.powered-by .pb-name .pb-plus { color: var(--red); font-weight: 800; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 44px; padding: 0 var(--sp-3);
  border-radius: var(--r-md); color: var(--ink-soft); font-size: 14px; font-weight: 600;
  position: relative; text-decoration: none; border: none; background: none; width: 100%;
  text-align: left; cursor: pointer; font-family: var(--font);
}
.nav-item:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.nav-item .icon { color: var(--muted); }
.nav-item.active { background: var(--blue-soft); color: var(--blue-deep); }
.nav-item.active .icon { color: var(--blue); }
.nav-item.active::before {
  content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 3px; border-radius: var(--r-full); background: var(--blue);
}
.nav-item.soon { color: var(--faint); cursor: default; }
.nav-item.soon .icon { color: var(--faint); }
.nav-soon-pill {
  margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--muted); background: var(--field); border: 1px solid var(--line); padding: 2px 7px; border-radius: var(--r-full);
}
.nav-more-trigger { display: none; }

.nav-foot { margin-top: auto; padding-top: var(--sp-4); border-top: 1px solid var(--line-soft); }
/* min-width:0 on the flex row + its text wrapper — flex items default to
   min-width:auto, so unbounded text (a longer real name than "QA
   ClientTest") pushes the row past the sidebar's own width instead of
   truncating (nothing clips it, since .sidebar has no overflow:hidden).
   Caught in local QA: the sign-out button rendered OUTSIDE the sidebar's
   box, over the main pane, and swallowed its own clicks. */
.user-chip { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2); min-width: 0; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--band); color: var(--navy);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-chip-text { min-width: 0; flex: 1 1 auto; }
.user-name { font-size: 13px; font-weight: 700; color: var(--ink); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sign-out — not on the card explicitly (no "sign out" affordance drawn on
   dashboard-r1's sidebar), but the shell needs one to be a working app; kept
   inside the user chip footer, minimal and token-consistent. */
/* Drew's ruling, 2026-08-13: "۴۴ بمونه، همه جا یکدست بشه" ("44 stays, make it consistent everywhere") —
   min-height/min-width only, visual icon-button size unchanged. */
.user-chip-signout {
  margin-left: auto; border: none; background: none; color: var(--faint);
  cursor: pointer; padding: 6px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-family: inherit; min-height: 44px; min-width: 44px;
}
.user-chip-signout:hover { color: var(--ink-soft); background: var(--field); }
.user-chip-signout:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ---------- main pane ---------- */
.main { flex: 1; min-width: 0; padding: var(--sp-6); background: var(--bg-app); overflow-y: auto; }

/* ---------- shell-level header (CR-A126-1) ----------
 * Persistent header region, mounted once in app.js's renderShell() —
 * `mountShellHeader()` in shared/shell-header.js, same "written once,
 * never re-created" invariant as .sidebar/.nav above.
 *
 * Values below are byte-identical to the ratified
 * .page-head-row/.ph-left h1/.ph-left .ph-count/.ph-right rules
 * (client-table.css:22-26) — same canon, new selector names only, per the
 * CR-A126-1 card (Claude Design "YNET+ Client App",
 * preview/shell-header.html). This CR ships the mechanism dark (no view
 * consumes it yet) — zero pixel change to any existing page's own header.
 *
 * CR-A126-2: `.sh-sub b`/`.sh-sub b.num` added below — CR-A126-1 shipped
 * this mechanism dark (no view called `.set({ subtitle })` with real
 * content), so the nested-`<b>` rule client-table.css's `.ph-count` and
 * dashboard.css's `.dash-hello-sub` both carry was never mirrored here. Two
 * separate source rules, matched verbatim rather than merged, since they
 * style two different things: client-table.css:26's `<b class="num">`
 * (live order/invoice/etc. counts — mono, tabular-nums) and dashboard.css:34's
 * plain `<b>` (the client's bold company name — color only, no mono).
 */
.shell-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.sh-left h1 { margin: 0 0 4px; font-size: 24px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.sh-left .sh-sub { font-size: 13px; color: var(--muted); }
.sh-left .sh-sub b { color: var(--ink-soft); }
.sh-left .sh-sub b.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sh-right { display: flex; align-items: center; gap: var(--sp-3); }

/* Mobile stack — mirrors client-table.css:182-183's .page-head-row/.ph-right
 * phone reflow verbatim. */
@media (max-width: 480px) {
  .shell-header { flex-direction: column; align-items: stretch; }
  .sh-right { flex-direction: column; align-items: stretch; }
}

/* ---------- phone / narrow reflow (~390px): sidebar -> bottom tab bar ---------- */
@media (max-width: 480px) {
  .shell { flex-direction: column; min-height: 100vh; border-radius: 0; border: none; box-shadow: none; }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100%; flex: none;
    flex-direction: row; align-items: stretch; gap: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-right: none; border-top: 1px solid var(--line); z-index: 30;
  }
  .sidebar .brand,
  .sidebar .powered-by { display: none; }
  .nav { flex-direction: row; flex: 1; gap: 0; }
  .nav-item {
    flex-direction: column; justify-content: center; gap: 3px; min-height: 52px;
    font-size: 10px; font-weight: 600; text-align: center; padding: 4px;
  }
  .nav-item.active::before { left: 50%; top: 6px; bottom: auto; transform: translateX(-50%); width: 20px; height: 3px; }
  .nav-soon-pill { display: none; } /* no room in the tab bar; the item itself stays non-interactive */
  .nav-item-overflow { display: none; }
  .nav-more-trigger { display: flex; }
  .nav-foot { margin-top: 0; padding-top: 0; border-top: none; flex: 0 0 auto; display: flex; align-items: center; }
  .user-chip { padding: 4px; }
  .user-name, .user-role { display: none; }
  .user-chip-signout { margin-left: 0; }
  .main { padding: var(--sp-4); padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}

/* "More" overflow sheet — narrow width only. Not drawn on the card (the
   phone reflow shows only the closed tab bar with a "More" tab); this is a
   minimal, token-consistent affordance so the 4 nav items the tab bar has no
   room for are still reachable on a phone. */
.nav-more-sheet {
  position: fixed; left: 8px; right: 8px; bottom: calc(64px + env(safe-area-inset-bottom));
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); padding: var(--sp-2); z-index: 31; display: none;
  flex-direction: column; gap: 2px;
}
.nav-more-sheet.open { display: flex; }
.nav-more-backdrop {
  position: fixed; inset: 0; z-index: 29; background: rgba(17, 24, 39, .15); display: none;
}
.nav-more-backdrop.open { display: block; }
