/* ============================================================
   Arbah v3 — application shell chrome (navy sidebar + topbar)
   ============================================================
   Source: design/arbah-v3/project/arbah.css (SIDEBAR + TOPBAR) and
   shell.css (mobile chrome: hamburger, bottom-tabs, more-toggle,
   drawer). Scoped under `.av3-shell` (the shell root Layout renders
   only when .arbah-v3 is active), so the design's generic class names
   (.sidebar/.topbar/.nav/.brand) never collide with the legacy shell.
   Responsiveness is VIEWPORT media-query based (the shell is the
   top-level frame), switching at the app's 1024px `lg` breakpoint —
   desktop sidebar ⇄ mobile hamburger + drawer + bottom-tabs.
   ============================================================ */

/* Hard fallbacks on the shell's load-bearing color tokens: even if the token
   stylesheet fails to load (404 / cache drift) or the scope ever regresses, the
   shell must never paint with empty (transparent / unset) colors. Fallbacks
   equal the canonical v3 token values. */
.av3-shell { display:flex; height:100vh; min-height:100vh; overflow:hidden; background:var(--app-bg, #F6F8FB); font-family:var(--font-sans, "IBM Plex Sans", system-ui, sans-serif); color:var(--arbah-ink, #0F172A); }
[dir="rtl"] .av3-shell { font-family:var(--font-sans-ar); }
.av3-shell .main-col { flex:1; min-width:0; display:flex; flex-direction:column; }
.av3-shell .scroll-area { flex:1; min-width:0; overflow-x:hidden; overflow-y:auto; }

/* ---------- SIDEBAR (240px navy-700) ---------- */
.av3-shell .sidebar { width:240px; flex-shrink:0; background:var(--arbah-navy-700, #102A43); color:rgba(255,255,255,.72); display:flex; flex-direction:column; border-inline-end:1px solid rgba(255,255,255,.06); height:100%; }
.av3-shell .brand { display:flex; align-items:center; gap:12px; padding:18px 18px 16px; }
.av3-shell .brand-logo { flex-shrink:0; display:flex; align-items:center; justify-content:center; color:#fff; }
.av3-shell .brand-name { font-family:var(--font-serif); font-size:19px; font-weight:600; color:#fff; line-height:1; letter-spacing:.2px; }
.av3-shell .brand-sub { font-family:var(--font-mono); font-size:9.5px; letter-spacing:2.5px; color:var(--arbah-bronze-200); margin-top:4px; }

.av3-shell .nav { flex:1; overflow-y:auto; padding:6px 12px 12px; }
.av3-shell .nav-section { margin-top:14px; }
.av3-shell .nav-section:first-child { margin-top:4px; }
.av3-shell .nav-header { font-family:var(--font-mono); font-size:10px; letter-spacing:1.5px; text-transform:uppercase; color:rgba(255,255,255,.40); padding:8px 12px 6px; }
.av3-shell .nav-item { position:relative; display:flex; align-items:center; gap:11px; padding:9px 12px; margin:1px 0; border-radius:var(--r-6); color:rgba(255,255,255,.70); font-size:13.5px; font-weight:500; cursor:pointer; user-select:none; min-height:38px; transition:background .12s, color .12s; border:none; background:transparent; width:100%; text-align:start; }
.av3-shell .nav-item:hover { background:rgba(255,255,255,.05); color:rgba(255,255,255,.92); }
.av3-shell .nav-item:focus-visible { outline:none; box-shadow:0 0 0 2px rgba(255,255,255,.5); }
.av3-shell .nav-item .nav-ico { width:18px; height:18px; flex-shrink:0; opacity:.85; display:flex; }
.av3-shell .nav-item .nav-label { flex:1; min-width:0; }
.av3-shell .nav-item.active { background:rgba(255,255,255,.08); color:#fff; }
.av3-shell .nav-item.active::before { content:""; position:absolute; inset-inline-start:-12px; top:6px; bottom:6px; width:3px; border-radius:3px; background:var(--arbah-bronze-500, #A06A2C); }
.av3-shell .nav-item.active .nav-ico { opacity:1; }

/* count badges */
.av3-shell .count { font-family:var(--font-mono); font-size:10.5px; font-weight:600; min-width:20px; height:18px; padding:0 6px; border-radius:9px; display:inline-flex; align-items:center; justify-content:center; color:#fff; font-variant-numeric:tabular-nums; flex-shrink:0; }
.av3-shell .count--neutral { background:rgba(255,255,255,.10); color:rgba(255,255,255,.85); }
.av3-shell .count--attn { background:var(--arbah-bronze-500); }
.av3-shell .count--urgent { background:var(--arbah-danger); }

/* More toggle */
.av3-shell .more-toggle { display:flex; align-items:center; justify-content:space-between; gap:8px; width:100%; margin-top:8px; padding:10px 12px; border-radius:var(--r-6); background:rgba(255,255,255,.05); border:1px solid rgba(255,255,255,.08); color:rgba(255,255,255,.78); font-family:var(--font-sans); font-size:12.5px; font-weight:600; cursor:pointer; min-height:40px; }
[dir="rtl"] .av3-shell .more-toggle { font-family:var(--font-sans-ar); }
.av3-shell .more-toggle:hover { background:rgba(255,255,255,.09); color:#fff; }
.av3-shell .more-toggle .mt-chev { display:flex; transition:transform .18s; transform:rotate(0deg); }
.av3-shell .more-toggle.open .mt-chev { transform:rotate(180deg); }

/* side footer */
.av3-shell .side-footer { border-top:1px solid rgba(255,255,255,.07); padding:10px 12px 14px; }
.av3-shell .user-row { display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:var(--r-8); cursor:pointer; border:none; background:transparent; width:100%; text-align:start; }
.av3-shell .user-row:hover { background:rgba(255,255,255,.05); }
.av3-shell .user-avatar { width:32px; height:32px; border-radius:50%; flex-shrink:0; background:linear-gradient(150deg,var(--arbah-bronze-500),var(--arbah-bronze-700)); display:flex; align-items:center; justify-content:center; font-family:var(--font-mono); font-size:11px; font-weight:600; color:#fff; letter-spacing:.5px; }
.av3-shell .user-meta { min-width:0; max-width:100%; overflow:hidden; }
.av3-shell .user-name { display:block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px; font-weight:600; color:#fff; line-height:1.2; }
.av3-shell .user-role { font-size:11px; color:rgba(255,255,255,.55); }
.av3-shell .signout-btn { display:flex; align-items:center; justify-content:center; gap:8px; width:100%; min-height:38px; margin-top:6px; padding:8px 10px; border:1px solid rgba(255,255,255,.14); border-radius:var(--r-8); background:rgba(255,255,255,.04); color:rgba(255,255,255,.78); font-size:12px; font-weight:600; cursor:pointer; }
.av3-shell .signout-btn:hover { background:rgba(255,255,255,.10); color:#fff; border-color:rgba(255,255,255,.24); }
.av3-shell .signout-btn:focus-visible { outline:2px solid var(--arbah-bronze-500); outline-offset:2px; }

/* Appearance selector — compact enough for the fixed sidebar footer, with
   clear previews and radio semantics for keyboard/screen-reader users. */
.av3-shell .appearance-control { margin-top:6px; padding:8px 8px 7px; border-top:1px solid rgba(255,255,255,.07); }
.av3-shell .appearance-label { margin-bottom:7px; color:rgba(255,255,255,.62); font-size:10px; font-weight:600; letter-spacing:.04em; text-transform:uppercase; }
.av3-shell .appearance-options { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; }
.av3-shell .appearance-option { min-width:0; padding:5px 3px 4px; border:1px solid rgba(255,255,255,.10); border-radius:var(--r-6); background:rgba(255,255,255,.035); color:rgba(255,255,255,.62); cursor:pointer; font:600 9.5px/1.2 var(--font-sans); }
[dir="rtl"] .av3-shell .appearance-option { font-family:var(--font-sans-ar); }
.av3-shell .appearance-option:hover { background:rgba(255,255,255,.08); color:#fff; }
.av3-shell .appearance-option.active { border-color:var(--arbah-bronze-200); background:rgba(217,194,138,.12); color:#fff; box-shadow:0 0 0 1px rgba(217,194,138,.2); }
.av3-shell .appearance-preview { position:relative; display:block; width:100%; height:19px; margin-bottom:4px; overflow:hidden; border:1px solid rgba(255,255,255,.22); border-radius:4px; background:#F8FAFC; }
.av3-shell .appearance-preview::before { content:""; position:absolute; inset:4px auto auto 4px; width:13px; height:2px; border-radius:2px; background:#64748B; box-shadow:0 4px 0 #94A3B8; }
.av3-shell .appearance-preview i { position:absolute; width:5px; height:5px; right:4px; bottom:3px; border-radius:50%; background:#A06A2C; }
.av3-shell .appearance-preview--dark { background:#172331; }
.av3-shell .appearance-preview--dark::before { background:#CBD5E1; box-shadow:0 4px 0 #94A3B8; }
.av3-shell .appearance-preview--system { background:linear-gradient(145deg,#F8FAFC 0 49%,#172331 50% 100%); }

/* ---------- TOPBAR (64px white) ---------- */
.av3-shell .topbar { height:64px; flex-shrink:0; background:var(--arbah-surface); border-bottom:1px solid var(--arbah-border); display:flex; align-items:center; gap:18px; padding:0 24px; }
.av3-shell .search { flex:1; max-width:420px; height:40px; display:flex; align-items:center; gap:9px; background:var(--arbah-surface-sunken); border:1px solid var(--arbah-border); border-radius:var(--r-8); padding:0 12px; color:var(--arbah-ink-subtle); cursor:pointer; }
.av3-shell .search input { flex:1; border:none; background:transparent; outline:none; font-family:var(--font-sans); font-size:13.5px; color:var(--arbah-ink); cursor:pointer; }
.av3-shell .search input::placeholder { color:var(--arbah-ink-subtle); }
.av3-shell .search .search-ph { flex:1; text-align:start; font-size:13.5px; color:var(--arbah-ink-subtle); }
.av3-shell .kbd { font-family:var(--font-mono); font-size:11px; color:var(--arbah-ink-muted); background:var(--arbah-surface); border:1px solid var(--arbah-border-strong); border-radius:var(--r-4); padding:2px 6px; box-shadow:0 1px 0 var(--arbah-border-strong); }
.av3-shell .topbar-spacer { flex:1; }
.av3-shell .topbar-right { display:flex; align-items:center; gap:14px; }
.av3-shell .top-date { font-family:var(--font-mono); font-size:12.5px; color:var(--arbah-ink-muted); font-variant-numeric:tabular-nums; white-space:nowrap; }
.av3-shell .seg { display:inline-flex; background:var(--arbah-surface-sunken); border:1px solid var(--arbah-border); border-radius:999px; padding:3px; gap:2px; }
.av3-shell .seg button { font-family:var(--font-mono); font-size:11.5px; font-weight:600; letter-spacing:.5px; border:none; background:transparent; color:var(--arbah-ink-muted); padding:5px 12px; border-radius:999px; cursor:pointer; min-height:30px; }
.av3-shell .seg button.on { background:var(--arbah-navy-700); color:#fff; }
.av3-shell .bell { position:relative; width:40px; height:40px; border-radius:var(--r-8); border:1px solid var(--arbah-border); background:var(--arbah-surface); display:flex; align-items:center; justify-content:center; cursor:pointer; color:var(--arbah-ink-muted); flex-shrink:0; }
.av3-shell .bell:hover { background:var(--arbah-surface-sunken); }
.av3-shell .bell .count { position:absolute; top:-6px; inset-inline-end:-6px; border:2px solid var(--arbah-surface); }

/* mobile-only chrome (hidden on desktop) */
.av3-shell .hamburger, .av3-shell .topbar-brand, .av3-shell .bottom-tabs, .av3-shell .drawer-overlay { display:none; }
.av3-shell .hamburger { width:40px; height:40px; border-radius:var(--r-8); border:1px solid var(--arbah-border); background:var(--arbah-surface); color:var(--arbah-ink-muted); align-items:center; justify-content:center; cursor:pointer; flex-shrink:0; }
.av3-shell .topbar-brand { align-items:center; gap:9px; color:var(--arbah-navy-700); }
.av3-shell .topbar-brand .brand-name { font-family:var(--font-serif); font-size:17px; font-weight:600; color:var(--arbah-navy-700); line-height:1; }
.av3-shell .bottom-tabs { flex-shrink:0; height:62px; background:var(--arbah-surface, #FFFFFF); border-top:1px solid var(--arbah-border, #E2E8F0); align-items:stretch; justify-content:space-around; padding:4px 6px; padding-bottom:max(4px, env(safe-area-inset-bottom)); }
.av3-shell .bt-item { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; border:none; background:transparent; cursor:pointer; color:var(--arbah-ink-subtle); font-family:var(--font-sans); font-size:10.5px; font-weight:600; min-height:48px; position:relative; }
[dir="rtl"] .av3-shell .bt-item { font-family:var(--font-sans-ar); }
.av3-shell .bt-item .bt-ico { width:22px; height:22px; display:flex; align-items:center; justify-content:center; }
.av3-shell .bt-item.active { color:var(--arbah-navy-700, #102A43); }
.av3-shell .bt-item .bt-badge { position:absolute; top:4px; left:50%; margin-inline-start:6px; min-width:16px; height:16px; padding:0 4px; border-radius:8px; background:var(--arbah-bronze-500); color:#fff; font-family:var(--font-mono); font-size:9.5px; display:flex; align-items:center; justify-content:center; font-variant-numeric:tabular-nums; }
.av3-shell .drawer-overlay { position:fixed; inset:0; background:rgba(10,27,46,.45); z-index:40; }

/* ---------- RESPONSIVE: viewport, switch at 1024px ---------- */
@media (max-width: 1023px) {
  .av3-shell .sidebar { position:fixed; inset-block:0; inset-inline-start:-300px; z-index:50; width:280px; transition:inset-inline-start .26s cubic-bezier(.4,0,.2,1); box-shadow:0 0 60px rgba(10,27,46,.4); }
  .av3-shell.drawer-open .sidebar { inset-inline-start:0; }
  .av3-shell.drawer-open .drawer-overlay { display:block; }
  .av3-shell .hamburger { display:flex; }
  .av3-shell .topbar-brand { display:flex; }
  .av3-shell .bottom-tabs { display:flex; }
  .av3-shell .topbar { height:58px; padding:0 14px; gap:12px; }
  .av3-shell .topbar .search { display:none; }
  .av3-shell .top-date { display:none; }
  .av3-shell .scroll-area { padding-bottom:4px; }
  html[data-color-scheme="dark"] .av3-shell .topbar-brand,
  html[data-color-scheme="dark"] .av3-shell .topbar-brand .brand-name,
  html[data-color-scheme="dark"] .av3-shell .bt-item.active { color:var(--arbah-ink); }
}
@media (min-width: 1024px) {
  .av3-shell .hamburger, .av3-shell .topbar-brand, .av3-shell .bottom-tabs { display:none !important; }
}
