/* frontend/ui/shell.css — oat.ink token overrides + app shell (sidebar + topbar)
 *
 * Loaded AFTER the oat.ink CDN <link>. Three layers:
 *   1. Brand + oat.ink CSS-variable overrides (so oat's defaults pick up our palette).
 *   2. Sidebar + topbar layout from the jms-oat-mockup.html prototype.
 *   3. Light/dark theme switching via [data-theme="dark"] on <body>.
 *
 * Pages that use the shell wrap content in:
 *   <div class="app">
 *     <aside class="app-sidebar">…</aside>
 *     <main class="app-main">
 *       <header class="app-topbar">…</header>
 *       <div class="app-page">…</div>
 *     </main>
 *   </div>
 *
 * shell.js renders the sidebar + topbar from a single config; pages only
 * fill in the .app-page slot.
 */

/* ── 1. Brand tokens + oat.ink overrides ────────────────────────────── */
:root {
  --primary:        #185FA5;
  --primary-dim:    #1f73c2;
  --primary-soft:   rgba(24, 95, 165, 0.08);
  --accent:         #3b82f6;

  --bg:             #f7f8fa;
  --bg-card:        #ffffff;
  --bg-soft:        #f1f3f7;
  --text:           #0f172a;
  --text-muted:     #64748b;
  --text-faint:     #94a3b8;
  --border:         #e6e8ee;
  --border-strong:  #d4d8e0;

  --good:        #16a34a;
  --good-soft:   rgba(22, 163, 74, 0.10);
  --warn:        #d97706;
  --warn-soft:   rgba(217, 119, 6, 0.10);
  --bad:         #dc2626;
  --bad-soft:    rgba(220, 38, 38, 0.10);
  --info:        #185FA5;
  --info-soft:   rgba(24, 95, 165, 0.10);
  --neutral:     #475569;
  --neutral-soft:rgba(71, 85, 105, 0.10);

  /* oat.ink overrides — covers both --oat-* and unprefixed naming.
     Whichever one oat picks up, our palette wins. */
  --oat-color-primary:    var(--primary);
  --oat-color-primary-fg: #ffffff;
  --oat-color-bg:         var(--bg);
  --oat-color-fg:         var(--text);
  --oat-color-fg-subtle:  var(--text-muted);
  --oat-color-border:     var(--border);
  --oat-color-card:       var(--bg-card);
  --oat-color-success:    var(--good);
  --oat-color-warning:    var(--warn);
  --oat-color-danger:     var(--bad);

  --oat-radius:        8px;
  --oat-radius-small:  6px;
  --oat-radius-medium: 8px;
  --oat-radius-large:  12px;

  --oat-font-family:  "DM Sans", system-ui, -apple-system, sans-serif;
  --oat-font-sans:    "DM Sans", system-ui, sans-serif;
  --oat-font-mono:    "DM Mono", ui-monospace, monospace;
  --oat-font-display: "Syne", "DM Sans", sans-serif;
  --oat-font-size:    13px;
}

[data-theme="dark"] {
  --bg:             #0b0d10;
  --bg-card:        #14171c;
  --bg-soft:        #1a1e25;
  --text:           #e6e8ee;
  --text-muted:     #94a3b8;
  --text-faint:     #64748b;
  --border:         #232831;
  --border-strong:  #2e343f;
  --primary:        #4f8fd3;
  --primary-soft:   rgba(79, 143, 211, 0.12);

  --good-soft:    rgba(22, 163, 74, 0.18);
  --warn-soft:    rgba(217, 119, 6, 0.18);
  --bad-soft:     rgba(220, 38, 38, 0.20);
  --info-soft:    rgba(79, 143, 211, 0.18);
  --neutral-soft: rgba(148, 163, 184, 0.14);
}

/* ── Base typography ────────────────────────────────────────────────── */
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--oat-font-family);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 {
  font-family: var(--oat-font-display);
  letter-spacing: -0.01em;
  margin: 0;
}
.mono, code, kbd { font-family: var(--oat-font-mono); }

/* ── 2. App shell layout ────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 60px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.app-sidebar .logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--oat-font-display);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 18px;
  text-decoration: none;
}
.app-sidebar .nav-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  margin-bottom: 4px;
  text-decoration: none;
  position: relative;
}
.app-sidebar .nav-icon:hover {
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
}
.app-sidebar .nav-icon.active {
  background: var(--primary-soft);
  color: var(--primary);
}
.app-sidebar .nav-icon.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: auto;
}
.app-sidebar .nav-icon .material-symbols-outlined { font-size: 20px; }
.app-sidebar .nav-icon .dot {
  position: absolute;
  top: 6px; right: 8px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--bad);
}
.app-sidebar .grow { flex: 1; }

/* Main + topbar */
.app-main { padding: 0; min-width: 0; }

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 16px;
}
.app-topbar .crumb { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-topbar .crumb h1 { font-size: 18px; font-weight: 700; }
.app-topbar .crumb .sub { color: var(--text-muted); font-size: 12px; }
.app-topbar .crumb a {
  color: var(--text-muted);
  text-decoration: none;
}
.app-topbar .crumb a:hover { color: var(--primary); }
.app-topbar .crumb .sep { color: var(--text-faint); }

.app-topbar .right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.app-topbar .who-name { font-weight: 600; font-size: 12px; }
.app-topbar .who-role { color: var(--text-muted); font-size: 11px; }

.app-page { padding: 16px 24px 32px; }

/* Buttons (small set used by the shell — avoid over-styling oat's own .btn) */
.btn-tb {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn-tb:hover { border-color: var(--text-muted); text-decoration: none; }
.btn-tb.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-tb.primary:hover { background: var(--primary-dim); border-color: var(--primary-dim); }
.btn-tb.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-tb.ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn-tb .material-symbols-outlined { font-size: 16px; }

.btn-icon {
  width: 32px; height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s;
}
.btn-icon:hover { color: var(--text); border-color: var(--text-muted); }
.btn-icon .material-symbols-outlined { font-size: 17px; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 12px;
  cursor: pointer;
}

/* ── 3. Toast container ─────────────────────────────────────────────── */
.toast-host {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast-host .toast {
  pointer-events: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  font-size: 13px;
  min-width: 260px;
  animation: toast-in 0.18s ease-out;
}
.toast-host .toast.ok    { border-left-color: var(--good); }
.toast-host .toast.error { border-left-color: var(--bad); }
.toast-host .toast.warn  { border-left-color: var(--warn); }
.toast-host .toast .body { flex: 1; }
.toast-host .toast .body .title { font-weight: 600; }
.toast-host .toast .body .small { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.toast-host .toast .close {
  background: transparent; border: 0;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  line-height: 1;
  font-size: 16px;
}
.toast-host .toast .close:hover { color: var(--text); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Status pills (shared across all pages) ─────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.pill.created   { background: var(--neutral-soft); color: var(--neutral); }
.pill.opdone    { background: var(--info-soft);    color: var(--info); }
.pill.ripping   { background: rgba(139, 92, 246, 0.10); color: #7c3aed; }
.pill.output    { background: rgba(217, 119, 6, 0.10); color: var(--warn); }
.pill.challan   { background: rgba(14, 165, 233, 0.10); color: #0284c7; }
.pill.dispatch  { background: var(--good-soft);    color: var(--good); }
.pill.hold      { background: var(--warn-soft);    color: var(--warn); }
.pill.cancel    { background: var(--bad-soft);     color: var(--bad); }
.pill.nobill    { background: var(--bad-soft);     color: var(--bad); }
.pill.verified  { background: var(--good-soft);    color: var(--good); }
.pill.pending-verify { background: var(--info-soft); color: var(--info); }
.pill.clarify   { background: var(--warn-soft);    color: var(--warn); }
.pill.neutral   { background: var(--neutral-soft); color: var(--neutral); }

/* ── Reduced motion ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
