/* Sidebar for the staff pages (see shell.js). Classes are prefixed sb- because the dashboard and builder pages already
   use .side for their own panels. Loaded after app.css or builder.css and reuses their colour variables. */
:root { --sb-w: 248px; --accent-soft: #e8f1fb; --surface-2: #f6f8fa; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e6ebef; --muted: #9aa7b2; --line: #33404b; --panel: #1b232b; --bg: #12181e;
  --accent: #2f7fd1; --accent-dark: #276cb3; --accent-soft: #1f3a57; --surface-2: #222c35;
  --danger: #f08a82; --ok: #6cc38a; --warn: #e0b45c;
}
@media (min-width: 901px) { :root.side-collapsed { --sb-w: 72px; } }

body.has-sb { margin-left: var(--sb-w); }
/* The slim page header only carries the mobile menu button and title; on desktop the sidebar and the page heading replace it. */
@media (min-width: 901px) { body.has-sb > header.top { display: none; } }
.top .sb-menu { margin-right: 4px; }

.sb { position: fixed; inset: 0 auto 0 0; width: var(--sb-w); background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; z-index: 30; overflow-y: auto; overflow-x: hidden; }
.sb-head { display: flex; align-items: center; gap: 8px; min-height: 64px; margin-bottom: 8px; }
.sb-brand { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
/* Size comes from Settings (set inline by shell.js); these are only the safe limits. */
.sb-logo { max-width: 100%; object-fit: contain; object-position: left center; }
.sb-name { font-weight: 700; font-size: 16px; line-height: 1.2; overflow-wrap: anywhere; }
.sb-mark { flex: none; display: none; width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: #fff; align-items: center; justify-content: center; overflow: hidden; }
.sb-mark b { font-size: 18px; }
.sb-mark.has-img { background: #fff; border: 1px solid var(--line); }
.sb-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sb-brand:not(.has-logo) .sb-mark { display: flex; }
.sb-collapse { flex: none; width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; }

.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.sb-grow { flex: 1; min-height: 12px; }
.sb-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.sb-item:hover { background: var(--surface-2); color: var(--ink); }
.sb-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sb-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-ico { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sb-account { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 4px 12px 10px; min-width: 0; }
.sb-avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.who-text { min-width: 0; }
.who-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.sb-track { flex: none; position: relative; width: 34px; height: 20px; border-radius: 10px; background: var(--line); }
.sb-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; }
.sb-item[aria-checked="true"] .sb-track { background: var(--accent); }
.sb-item[aria-checked="true"] .sb-track::after { left: 16px; }

.sb-menu { display: none; padding: 0; width: 38px; height: 38px; align-items: center; justify-content: center; }
.sb-scrim { display: none; }

/* collapsed (desktop) */
@media (min-width: 901px) {
  :root.side-collapsed .sb { padding-left: 10px; padding-right: 10px; }
  :root.side-collapsed .sb-head { flex-direction: column; justify-content: center; gap: 8px; }
  :root.side-collapsed .sb-brand { flex: none; }
  :root.side-collapsed .sb-logo, :root.side-collapsed .sb-name { display: none; }
  :root.side-collapsed .sb-mark { display: flex; }
  :root.side-collapsed .sb-collapse .sb-ico { transform: rotate(180deg); }
  :root.side-collapsed .sb-item { justify-content: center; padding: 0; }
  :root.side-collapsed .sb-item .lbl, :root.side-collapsed .sb-track, :root.side-collapsed .who-text { display: none; }
  :root.side-collapsed .sb-user { justify-content: center; padding-left: 0; padding-right: 0; }
}

/* mobile drawer */
@media (max-width: 900px) {
  body.has-sb { margin-left: 0; }
  .sb { width: 272px; transform: translateX(-100%); visibility: hidden; }
  :root.drawer-open .sb { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  :root.drawer-open .sb-scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 25; }
  .sb-collapse { display: none; }
  .sb-menu { display: inline-flex; }
}
@media (max-width: 900px) and (prefers-reduced-motion: no-preference) { .sb { transition: transform .2s, visibility .2s; } }

/* dialogs and toast */
.sb-dlg { width: min(520px, 92vw); color: var(--ink); background: var(--panel); }
.sb-dlg h2 { margin-top: 0; }
.sb-dlg label { display: block; margin: 10px 0 4px; font-weight: 600; }
.sb-dlg input { width: 100%; }
.sb-foot { display: flex; gap: 8px; justify-content: flex-end; margin: 14px 0 0; }
.sb-toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #1f2933; color: #fff; padding: 9px 16px; border-radius: 8px; max-width: 90vw; z-index: 60; }

/* dark mode: the page stylesheets hard-code a few light colours, mapped here */
:root[data-theme="dark"] button { background: var(--panel); color: var(--ink); }
:root[data-theme="dark"] button:hover { background: var(--surface-2); }
:root[data-theme="dark"] button.primary { background: var(--accent); color: #fff; }
:root[data-theme="dark"] button.primary:hover { background: var(--accent-dark); }
:root[data-theme="dark"] button.danger { color: var(--danger); }
:root[data-theme="dark"] .sb-item { background: transparent; }
:root[data-theme="dark"] .sb-item:hover { background: var(--surface-2); }
:root[data-theme="dark"] .sb-item[aria-current="page"] { background: var(--accent-soft); }
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background: var(--bg); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] dialog { background: var(--panel); color: var(--ink); }
:root[data-theme="dark"] .fchip[aria-pressed=true],
:root[data-theme="dark"] .side button[aria-current=true],
:root[data-theme="dark"] .emp-items button[aria-current=true],
:root[data-theme="dark"] .blocklist li[aria-current=true],
:root[data-theme="dark"] .seg button[aria-pressed=true],
:root[data-theme="dark"] .notice { background: var(--accent-soft); color: var(--ink); }
:root[data-theme="dark"] .tabs button { background: transparent; }
:root[data-theme="dark"] .badge, :root[data-theme="dark"] .chip, :root[data-theme="dark"] .tile img, :root[data-theme="dark"] .tile .noimg, :root[data-theme="dark"] .thumb, :root[data-theme="dark"] .emp .thumb { background: var(--surface-2); }
:root[data-theme="dark"] .badge.draft, :root[data-theme="dark"] .chip.invited { background: #3a3220; color: var(--warn); }
:root[data-theme="dark"] .chip.active { background: #1d3527; color: var(--ok); }
:root[data-theme="dark"] .chip.inactive { background: #3d2422; color: var(--danger); }
:root[data-theme="dark"] .linkbox, :root[data-theme="dark"] details.item { background: var(--surface-2); }
:root[data-theme="dark"] .phone { border-color: #3a4651; }

/* licence warning for administrators */
.sb-banner { background: #fff4d6; color: #5c4200; border: 1px solid #e6c36a; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
:root[data-theme="dark"] .sb-banner { background: #3a3220; color: #f1d58a; border-color: #6b5a2a; }
