/* ══════════════════════════════════════════════════════════════════
   OrcheStream — shared design system
   Shared by all sidebar pages. Each page's own <style> block
   contains only layout and component overrides.
   ══════════════════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────────────── */
/* Dark is the default/fallback for Studio — pages that haven't yet added the
   toggle (no [data-theme] attribute set) keep today's look unchanged. */
:root, [data-theme="dark"] {
  color-scheme: dark;

  /* Surfaces */
  --os-bg:            #0c1219;
  --os-nav-bg:         #0d1b2e;
  --os-surface:        #131d2c;
  --os-surface-raised: #1c2a3a;
  --os-surface-subtle: rgba(51, 53, 56, .4);
  --os-hover-overlay:  rgba(255, 255, 255, .05);
  --os-hover-strong:   rgba(255, 255, 255, .09);

  /* Borders */
  --os-border:       #283d52;
  --os-border-inner: #1a2c3f;

  /* Accent — constant across themes, only surfaces/text shift */
  --os-accent:       #00c0e4;
  --os-accent-hover: #33d0eb;
  --os-on-accent:    #001820;

  /* Text */
  --os-text:         #e2e2e6;
  --os-text-2:       #c2c6d6;
  --os-text-muted:   #8c909f;

  /* State */
  --os-success:      #10b981;
  --os-error:        #ffb4ab;
  --os-warning:      #fbbf24;
  --os-warning-bg:     rgba(251, 191, 36, .12);
  --os-warning-border: rgba(251, 191, 36, .35);

  /* Elevation */
  --os-shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --os-shadow-md: 0 4px 24px rgba(0, 0, 0, .4);
  --os-shadow-lg: 0 12px 48px rgba(0, 0, 0, .5);
}

[data-theme="light"] {
  color-scheme: light;

  /* Surfaces */
  --os-bg:             #f8fafc;
  --os-nav-bg:         #ffffff;
  --os-surface:        #ffffff;
  --os-surface-raised: #f1f5f9;
  --os-surface-subtle: rgba(226, 232, 240, .6);
  --os-hover-overlay:  rgba(15, 23, 42, .04);
  --os-hover-strong:   rgba(15, 23, 42, .07);

  /* Borders */
  --os-border:       #e2e8f0;
  --os-border-inner: #f1f5f9;

  /* Accent — same as dark */
  --os-accent:       #00c0e4;
  --os-accent-hover: #33d0eb;
  --os-on-accent:    #001820;

  /* Text */
  --os-text:         #0f172a;
  --os-text-2:       #475569;
  --os-text-muted:   #64748b;

  /* State */
  --os-success:      #10b981;
  --os-error:        #ef4444;
  --os-warning:      #b45309;
  --os-warning-bg:     rgba(217, 119, 6, .10);
  --os-warning-border: rgba(217, 119, 6, .35);

  /* Elevation */
  --os-shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --os-shadow-md: 0 4px 24px rgba(15, 23, 42, .08);
  --os-shadow-lg: 0 12px 48px rgba(15, 23, 42, .12);
}

/* ── Theme-aware asset swap: pair .theme-light-only with .theme-dark-only
   on two elements (e.g. wordmark variants) to swap between themes. ── */
.theme-light-only { display: inline-block; }
.theme-dark-only  { display: none; }
[data-theme="dark"] .theme-light-only { display: none; }
[data-theme="dark"] .theme-dark-only  { display: inline-block; }

/* ── Chrome icon button — shared square-button look for #top-bar controls.
   .theme-toggle-btn is also a functional hook: /static/js/theme.js binds a
   click listener to every element with that class, so any other top-bar
   button (e.g. the notification bell) must use .icon-btn instead, never
   .theme-toggle-btn, or it will silently toggle the theme on click too. ── */
.icon-btn, .theme-toggle-btn {
  display: flex; height: 2.25rem; width: 2.25rem; flex-shrink: 0; align-items: center; justify-content: center;
  border-radius: 4px; border: 1px solid var(--os-border); background: var(--os-surface-raised);
  color: var(--os-text-2); cursor: pointer; padding: 0; transition: border-color .15s;
}
.icon-btn:hover, .theme-toggle-btn:hover { border-color: rgba(0, 192, 228, .4); }
.theme-toggle-btn svg { height: 1rem; width: 1rem; }
.theme-toggle-btn .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle-btn .icon-sun  { display: none; }
[data-theme="dark"] .theme-toggle-btn .icon-moon { display: block; }

/* ── Notification bell (sits beside the theme toggle in #top-bar) ───────── */
.notif-bell-btn { position: relative; }
.notif-dot {
  position: absolute; top: 5px; right: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--os-warning); border: 1.5px solid var(--os-surface-raised);
}

/* ── Fonts ─────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Changa One';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('/static/fonts/changa-one-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Changa One';
  font-style: italic; font-weight: 400; font-display: swap;
  src: url('/static/fonts/changa-one-400-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal; font-weight: 500; font-display: swap;
  src: url('/static/fonts/jetbrains-mono-500.woff2') format('woff2');
}
/* Self-hosted, subsetted to the icon set this app actually uses (see
   static/fonts/README or DESIGN-SYSTEM.md) — the full variable Material
   Symbols font is ~3.9MB; these two static instances are ~260KB combined.
   Losing the live FILL/GRAD/opsz/wght variable axes is fine since the app
   only ever needs two fixed combinations (outlined, filled). Adding an
   icon not already covered requires regenerating the subset. */
@font-face {
  font-family: 'Material Symbols Outlined';
  font-style: normal; font-weight: 400; font-display: block;
  src: url('/static/fonts/material-symbols-outlined.woff2') format('woff2');
}
@font-face {
  font-family: 'Material Symbols Outlined Fill';
  font-style: normal; font-weight: 400; font-display: block;
  src: url('/static/fonts/material-symbols-outlined-fill.woff2') format('woff2');
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

/* ── Base ──────────────────────────────────────────────────────── */
body {
  font-family: 'Changa One', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--os-bg);
  color: var(--os-text);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.5;
}

/* ── Material Symbols ──────────────────────────────────────────── */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal; font-style: normal;
  letter-spacing: normal; text-transform: none;
  white-space: nowrap; word-wrap: normal; direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-size: 20px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle; user-select: none; flex-shrink: 0;
}
.icon-sm   { font-size: 16px !important; }
.icon-xs   { font-size: 13px !important; }
/* Only 'stack', 'hub', and 'search_check' are ever rendered filled — see
   material-symbols-outlined-fill.woff2's subset list before adding more. */
.icon-fill { font-family: 'Material Symbols Outlined Fill'; }

/* ── Focus ─────────────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--os-accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

/* ── Accessibility ─────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; top: -3rem; left: 1rem;
  background: var(--os-accent); color: var(--os-on-accent);
  padding: .5rem 1rem; border-radius: 4px;
  font-weight: 400; text-decoration: none;
  z-index: 9999; transition: top .1s;
}
.skip-link:focus { top: 0; }

/* ── Side navigation ───────────────────────────────────────────── */
#side-nav {
  width: 280px;
  background: var(--os-nav-bg);
  border-right: 1px solid var(--os-border);
  display: flex;
  flex-direction: column;
}
/* Fixed to the same height as #top-bar so their border-bottoms line up exactly. */
.nav-brand { height: 64px; padding: 0 1rem; display: flex; align-items: center; border-bottom: 1px solid var(--os-border); }
.nav-brand-row {
  display: flex; align-items: center; gap: .5rem;
  font-size: 17px; font-weight: 400; color: var(--os-text); margin-bottom: 2px;
}
.nav-brand-sub { font-size: 11px; color: var(--os-text-muted); }
.nav-links { flex: 1; padding: .625rem 0; display: flex; flex-direction: column; }
.nav-link {
  display: flex; align-items: center; gap: .875rem;
  padding: .625rem 1rem; color: var(--os-text-2); text-decoration: none;
  font-size: 16px; font-weight: 400;
  border-right: 2px solid transparent;
  transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--os-hover-overlay); color: var(--os-text); }
.nav-link.active {
  color: var(--os-accent); border-right-color: var(--os-accent);
  background: rgba(0,192,228,.07);
}
.nav-footer { border-top: 1px solid var(--os-border); padding: .625rem 0; }
button.nav-link { width: 100%; background: none; border: none; cursor: pointer; font-family: inherit; text-align: left; }

/* ── Sidebar notifications (first item in .nav-footer, above Settings) ──── */
.nav-notifications {
  display: flex; flex-direction: column; gap: .375rem;
  padding: 0 1rem .625rem; margin-bottom: .625rem;
  border-bottom: 1px solid var(--os-border);
}
.nav-notif-item {
  display: flex; align-items: center; gap: .25rem;
  border-radius: 4px;
  background: var(--os-warning-bg); border: 1px solid var(--os-warning-border);
}
.nav-notif-link {
  display: flex; align-items: center; gap: .625rem; flex: 1; min-width: 0;
  padding: .5rem .625rem; text-decoration: none; transition: filter .12s;
}
a.nav-notif-link:hover { filter: brightness(1.1); }
.nav-notif-item .material-symbols-outlined { font-size: 18px !important; color: var(--os-warning); flex-shrink: 0; }
.nav-notif-title { font-size: 12.5px; color: var(--os-text); line-height: 1.3; }
.nav-notif-dismiss {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 22px; height: 22px; margin-right: .375rem;
  background: none; border: none; border-radius: 3px;
  color: var(--os-text-muted); cursor: pointer; padding: 0;
  transition: background .12s, color .12s;
}
.nav-notif-dismiss:hover { background: var(--os-hover-strong); color: var(--os-text); }
.nav-notif-dismiss .material-symbols-outlined { font-size: 15px !important; color: inherit; }
.nav-notifications.flash { animation: nav-notif-flash 1s ease; }
@keyframes nav-notif-flash {
  0%, 100% { box-shadow: none; }
  25% { box-shadow: 0 0 0 2px var(--os-warning); border-radius: 4px; }
}

/* ── Main area ─────────────────────────────────────────────────── */
#main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ── Top bar ───────────────────────────────────────────────────── */
#top-bar {
  height: 64px; flex-shrink: 0;
  background: var(--os-bg); border-bottom: 1px solid var(--os-border);
  display: flex; align-items: center;
  padding: 0 1.5rem; gap: 1rem;
}
.breadcrumb {
  flex: 1; display: flex; align-items: center;
  gap: .375rem; font-size: 12px; color: var(--os-text-muted);
}
.breadcrumb a { color: var(--os-text-muted); text-decoration: none; transition: color .12s; }
.breadcrumb a:hover { color: var(--os-accent); }
.breadcrumb-sep { font-size: 16px; line-height: 1; }
.breadcrumb-current { font-size: 14px; font-weight: 400; color: var(--os-text); }

/* ── Header banner (high-priority nudge strip anchored under #top-bar) ──── */
.header-banner {
  display: flex; align-items: center; gap: .875rem;
  padding: .75rem 1.5rem;
  background: var(--os-warning-bg);
  border-bottom: 1px solid var(--os-warning-border);
}
.header-banner .material-symbols-outlined { font-size: 22px !important; color: var(--os-warning); flex-shrink: 0; }
.header-banner-text { flex: 1; min-width: 0; }
.header-banner-title { font-size: 14px; color: var(--os-text); margin-bottom: .1rem; }
.header-banner-desc { font-size: 12px; color: var(--os-text-muted); }
.header-banner-dismiss {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 26px; height: 26px;
  background: none; border: none; border-radius: 4px;
  color: var(--os-text-muted); cursor: pointer; padding: 0;
  transition: background .12s, color .12s;
}
.header-banner-dismiss:hover { background: var(--os-hover-strong); color: var(--os-text); }

/* ── Buttons ───────────────────────────────────────────────────── */
button { cursor: pointer; font-family: inherit; }
.btn {
  display: inline-flex; align-items: center; gap: .375rem;
  border: none; border-radius: 4px;
  padding: .45rem .9rem; font-size: 13px; font-weight: 400;
  line-height: 1.3; transition: opacity .12s, background .12s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--os-accent); color: var(--os-on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--os-accent-hover); }
.btn-ghost { background: var(--os-hover-overlay); color: var(--os-text-2); border: none; }
.btn-ghost:hover:not(:disabled) { background: var(--os-hover-strong); color: var(--os-text); }
.btn-danger { background: transparent; color: var(--os-error); border: 1px solid rgba(255,180,171,.3); }
.btn-danger:hover:not(:disabled) { background: rgba(255,180,171,.1); }
.btn-sm { padding: .3rem .65rem; font-size: 12px; }

/* ── Status ────────────────────────────────────────────────────── */
.success-msg { color: var(--os-success); }
.error       { color: var(--os-error); }
.error-text  { color: var(--os-error); }

/* ── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--os-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #5c6270; }

/* ══════════════════════════════════════════════════════════════════
   Idle-session timer widget  (idle-timer.js)
   Light and dark variants; the .it-dark modifier is set by the JS.
   ══════════════════════════════════════════════════════════════════ */
.it-dialog {
  background: #fff; border: none; border-radius: 10px; padding: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,.22);
  width: min(380px, calc(100vw - 2rem)); max-width: none;
  position: fixed; inset: 0; margin: auto; transform: none;
}
.it-dialog::backdrop { background: rgba(0,0,0,.35); }
.it-dialog.it-dark { background: #1a1f2e; border: 1px solid #374151; }
.it-inner { padding: 1.5rem; }
.it-title { font-size: 1rem; margin-bottom: .45rem; color: #1a1a2e; }
.it-dialog.it-dark .it-title { color: #f1f5f9; }
.it-desc { font-size: .875rem; color: #595959; margin-bottom: 1.25rem; line-height: 1.5; }
.it-dialog.it-dark .it-desc { color: #94a3b8; }
.it-countdown { font-variant-numeric: tabular-nums; }
.it-actions { display: flex; justify-content: flex-end; gap: .6rem; }
.it-btn {
  border: none; border-radius: 5px; padding: .45rem 1rem;
  font-size: .875rem; cursor: pointer; font-family: inherit;
}
.it-btn-ghost { background: transparent; color: #595959; border: 1.5px solid #d0d0d0; }
.it-btn-ghost:hover { background: #f5f5f5; }
.it-dialog.it-dark .it-btn-ghost { color: #94a3b8; border-color: #374151; }
.it-dialog.it-dark .it-btn-ghost:hover { background: #374151; }
.it-btn-primary { background: #0a5c78; color: #fff; }
.it-btn-primary:hover { background: #07455c; }
.it-dialog.it-dark .it-btn-primary { background: #1d4ed8; }
.it-dialog.it-dark .it-btn-primary:hover { background: #1e40af; }

/* ══════════════════════════════════════════════════════════════════
   SSO configuration panel  (sso-panel.js)
   All colors are scoped to the .sso-panel element via its own vars.
   Light and dark via [data-sso-theme="dark"] attribute.
   ══════════════════════════════════════════════════════════════════ */
.sso-panel {
  --sso-text:     #1a1a2e; --sso-muted:    #595959;
  --sso-hint:     #595959; --sso-label:    #444;
  --sso-primary:  #0a5c78; --sso-prim-h:   #07455c;
  --sso-danger:   #c0392b; --sso-dang-h:   #a93226;
  --sso-in-bg:    #fff;    --sso-in-bd:    #767676;
  --sso-in-foc:   #005fcc;
  --sso-meta-bg:  #f0f7fa; --sso-meta-bd:  #c0dce8;
  --sso-sep:      #e0e0e0;
  --sso-on-bg:    #d4edda; --sso-on-fg:    #155724;
  --sso-off-bg:   #f0f0f0; --sso-off-fg:   #595959;
  --sso-ok:       #155724; --sso-err:      #c0392b;
  --sso-code-bg:  #f5f7fa; --sso-code-fg:  #0a5c78;
  font-size: .9rem;
}
.sso-panel[data-sso-theme="dark"] {
  --sso-text:     #e2e8f0; --sso-muted:    #94a3b8;
  --sso-hint:     #64748b; --sso-label:    #94a3b8;
  --sso-primary:  #1d4ed8; --sso-prim-h:   #1e40af;
  --sso-danger:   #b91c1c; --sso-dang-h:   #991b1b;
  --sso-in-bg:    #0f1117; --sso-in-bd:    #374151;
  --sso-in-foc:   #60a5fa;
  --sso-meta-bg:  #1a1f2e; --sso-meta-bd:  #334155;
  --sso-sep:      #2d3748;
  --sso-on-bg:    #064e3b; --sso-on-fg:    #6ee7b7;
  --sso-off-bg:   #1e293b; --sso-off-fg:   #94a3b8;
  --sso-ok:       #6ee7b7; --sso-err:      #fca5a5;
  --sso-code-bg:  #1a1f2e; --sso-code-fg:  #93c5fd;
}
.sso-kicker { font-size:.73rem; text-transform:uppercase; letter-spacing:.06em; color:var(--sso-muted); margin-bottom:.25rem; }
.sso-badge { display:inline-block; padding:.2rem .6rem; border-radius:99px; font-size:.78rem; }
.sso-on  { background:var(--sso-on-bg);  color:var(--sso-on-fg);  }
.sso-off { background:var(--sso-off-bg); color:var(--sso-off-fg); }
.sso-domains { font-size:.78rem; color:var(--sso-muted); margin-top:.25rem; }
.sso-sep-line { border:none; border-top:1px solid var(--sso-sep); margin:1.1rem 0; }
.sso-sp-meta { background:var(--sso-meta-bg); border:1px solid var(--sso-meta-bd); border-radius:6px; padding:.9rem 1rem; margin-bottom:1.1rem; }
.sso-sp-head { font-size:.82rem; color:var(--sso-text); margin-bottom:.2rem; }
.sso-sp-sub  { font-size:.78rem; color:var(--sso-muted); margin-bottom:.7rem; }
.sso-meta-row { display:flex; align-items:center; gap:.5rem; flex-wrap:wrap; margin-bottom:.5rem; }
.sso-meta-row:last-child { margin-bottom:0; }
.sso-meta-key { font-size:.75rem; color:var(--sso-muted); min-width:170px; }
.sso-meta-val { font-family:ui-monospace,monospace; font-size:.78rem; background:var(--sso-code-bg); color:var(--sso-code-fg); padding:.18rem .45rem; border-radius:4px; word-break:break-all; flex:1; }
.sso-copy-btn { background:none; border:1px solid var(--sso-sep); border-radius:4px; color:var(--sso-muted); font-size:.72rem; padding:.15rem .5rem; cursor:pointer; white-space:nowrap; flex-shrink:0; font-family:inherit; }
.sso-copy-btn:hover { color:var(--sso-primary); border-color:var(--sso-primary); }
.sso-field { margin-bottom:.8rem; }
.sso-lbl { display:block; font-size:.8rem; color:var(--sso-label); margin-bottom:.28rem; }
.sso-input, .sso-select, .sso-textarea {
  width:100%; padding:.48rem .62rem;
  background:var(--sso-in-bg); border:1.5px solid var(--sso-in-bd);
  border-radius:5px; color:var(--sso-text); font-size:.875rem; font-family:inherit;
}
.sso-input:focus, .sso-select:focus, .sso-textarea:focus { border-color:var(--sso-in-foc); outline:none; }
.sso-input:disabled, .sso-select:disabled, .sso-textarea:disabled { opacity:.6; cursor:not-allowed; }
.sso-textarea { resize:vertical; min-height:88px; }
.sso-hint-txt { font-size:.76rem; color:var(--sso-hint); margin-top:.2rem; }
.sso-radios { display:flex; gap:1.25rem; }
.sso-radio-lbl { display:flex; align-items:center; gap:.4rem; font-size:.875rem; color:var(--sso-text); cursor:pointer; }
.sso-radio-lbl input[type=radio] { accent-color:var(--sso-primary); }
.sso-actions { display:flex; align-items:center; gap:.65rem; margin-top:1.1rem; flex-wrap:wrap; }
.sso-btn { border:none; border-radius:5px; padding:.48rem 1.05rem; font-size:.875rem; cursor:pointer; font-family:inherit; }
.sso-btn:disabled { opacity:.55; cursor:not-allowed; }
.sso-btn-primary { background:var(--sso-primary); color:#fff; }
.sso-btn-primary:hover:not(:disabled) { background:var(--sso-prim-h); }
.sso-btn-danger  { background:var(--sso-danger);  color:#fff; }
.sso-btn-danger:hover:not(:disabled)  { background:var(--sso-dang-h);  }
.sso-msg { font-size:.84rem; min-height:1.2em; margin-top:.5rem; }
.sso-msg-ok    { color:var(--sso-ok);  }
.sso-msg-error { color:var(--sso-err); }
.sso-loading { font-size:.875rem; color:var(--sso-muted); }
.sso-gone { display:none !important; }
