/* ============================================================
   PROTOTYPE DESIGN SYSTEM — Starter Kit
   Enterprise / B2B "Corporate Classic" design language.

   ┌─────────────────────────────────────────────────────────┐
   │  PER-PROJECT BRANDING — edit ONLY this :root block.       │
   │  Change the brand colors below and the whole prototype    │
   │  re-skins automatically. Everything else stays as is.     │
   │  Also: swap the wordmark text + logo in your HTML, and    │
   │  (optionally) the Google Fonts in <head>.                 │
   └─────────────────────────────────────────────────────────┘
   ============================================================ */

:root {
  /* ▼▼▼ EDIT PER PROJECT — brand colors ▼▼▼
     --brand-primary       main action color (buttons, links, active nav)
     --brand-primary-hover darker for :hover
     --brand-primary-active darkest for :active
     --brand-primary-soft  very light tint (active nav bg, chips)
     --brand-accent        secondary accent (gradients, highlights)
     --brand-pitch-bg-*    dark gradient for login/marketing panels
     --brand-light-blue    light accent on dark backgrounds            */
  --brand-primary: #1e3a6b;
  --brand-primary-hover: #15295a;
  --brand-primary-active: #0f1f44;
  --brand-primary-soft: #e8eef7;
  --brand-accent: #2563eb;
  --brand-pitch-bg-1: #1a3461;
  --brand-pitch-bg-2: #0f2547;
  --brand-pitch-bg-3: #0a1e3a;
  --brand-light-blue: #8eb4ff;
  /* ▲▲▲ EDIT PER PROJECT ▲▲▲  (neutrals/state/radii/shadows below
     are the shared system — usually leave them untouched) */

  /* Neutral colors */
  --bg-app: #f3f5f8;
  --bg-paper: #ffffff;
  --bg-subtle: #f9fafb;
  --bg-muted: #f3f4f6;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --line-soft: #f3f4f6;
  --text: #111827;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  /* State colors */
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0369a1;
  --info-soft: #dbeafe;

  /* Radii */
  --radius-sm: 3px;
  --radius: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.06);

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg-app);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, canvas { display: block; max-width: 100%; }
/* CRITICAL: ensure the HTML `hidden` attribute always wins over any display: rule */
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--brand-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout primitives */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top header */
.app-header {
  background: var(--bg-paper);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  flex-shrink: 0;
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  letter-spacing: 0.04em;
}
.app-header .brand .ai { color: var(--brand-light-blue); }
.app-header .brand .partner {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-muted);
  padding-left: 12px;
  border-left: 1px solid var(--line);
  margin-left: 4px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Card */
.card {
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}
.card-pad { padding: 24px; }
.card-pad-lg { padding: 32px; }
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.card-header .sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 2px 0 0;
}
.card-body { padding: 24px; }

/* Forms */
label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
label.field-label .req { color: var(--danger); margin-left: 2px; }
.input, input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  background: var(--bg-paper);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input::placeholder { color: var(--text-faint); }
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(30,58,107,0.12);
}
.field { margin-bottom: 18px; }
.help { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 500;
  font-size: 13.5px;
  line-height: 1.2;
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}
.btn-primary:hover { background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); }
.btn-primary:active { background: var(--brand-primary-active); }

.btn-secondary {
  background: var(--bg-paper);
  border-color: var(--line-strong);
  color: var(--text-secondary);
}
.btn-secondary:hover { background: var(--bg-subtle); border-color: var(--text-faint); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-muted); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-lg { padding: 12px 20px; font-size: 14.5px; }
.btn-block { width: 100%; }

/* Badges / chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 100px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.chip-success { background: var(--success-soft); color: var(--success); border-color: rgba(22,163,74,0.15); }
.chip-warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(217,119,6,0.15); }
.chip-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(220,38,38,0.15); }
.chip-info { background: var(--info-soft); color: var(--info); border-color: rgba(3,105,161,0.15); }
.chip-neutral { background: var(--bg-muted); color: var(--text-secondary); border-color: var(--line); }

/* Trust logos */
.trust-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px 40px;
  color: var(--text-muted);
}
.trust-logo {
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: 17px;
  white-space: nowrap;
}
.trust-logo.ibm { font-weight: 800; letter-spacing: 0.08em; }
.trust-logo.dhl { font-style: italic; font-weight: 800; }
.trust-logo.fedex { letter-spacing: -0.02em; font-weight: 700; font-style: italic; }
.trust-logo.coke { font-family: Georgia, serif; font-weight: 700; font-style: italic; }
.trust-logo.elal { letter-spacing: 0.22em; font-weight: 300; font-size: 14px; }
.trust-logo.isracard { font-weight: 500; }
.trust-logo.shipper { font-weight: 600; }

/* Wordmark used in headers */
.wordmark {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}
.wordmark .ai { color: var(--brand-light-blue); margin-left: 2px; }
.wordmark.on-dark { color: #ffffff; }

/* Utilities */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-lg { font-size: 16px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.uppercase { text-transform: uppercase; letter-spacing: 0.06em; }

/* Sidebar nav (for Dashboard) */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  overflow-y: auto;
  position: relative;
  transition: width 200ms ease;
}
.sidebar .nav-group { padding: 12px 0; }
.sidebar .nav-group-label {
  padding: 0 20px 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  margin: 1px 8px;
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 100ms ease, color 100ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .nav-item:hover {
  background: var(--bg-muted);
  color: var(--text);
  text-decoration: none;
}
.sidebar .nav-item.active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  font-weight: 500;
}
.sidebar .nav-item .icon { width: 16px; height: 16px; flex-shrink: 0; color: currentColor; }
.sidebar .nav-item .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
  background: var(--bg-muted);
  padding: 1px 6px;
  border-radius: 100px;
}
.sidebar .nav-item.active .count {
  color: var(--brand-primary);
  background: rgba(30,58,107,0.1);
}

/* KPI cards */
.kpi {
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi .kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.kpi .kpi-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.015em;
  line-height: 1.1;
}
.kpi .kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}
.kpi .kpi-trend.up { color: var(--success); }
.kpi .kpi-trend.down { color: var(--danger); }
.kpi .kpi-trend.neutral { color: var(--text-muted); }

/* Activity feed */
.feed-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.feed-item:last-child { border-bottom: none; }
.feed-item .feed-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  flex-shrink: 0;
}
.feed-item .feed-dot.ok { background: var(--success); }
.feed-item .feed-dot.warn { background: var(--warning); }
.feed-item .feed-dot.err { background: var(--danger); }
.feed-item .feed-dot.info { background: var(--brand-primary); }
.feed-item .feed-body { flex: 1; min-width: 0; }
.feed-item .feed-title { font-size: 13px; color: var(--text); margin: 0; font-weight: 500; }
.feed-item .feed-sub { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }
.feed-item .feed-time {
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Progress bar */
.progress {
  height: 4px;
  background: var(--bg-muted);
  border-radius: 100px;
  overflow: hidden;
}
.progress .progress-fill {
  height: 100%;
  background: var(--brand-primary);
  transition: width 240ms ease;
}

/* ============================================================
   Collapsed sidebar (toggleable, persisted via localStorage)
   Apply class .sidebar-collapsed to <html> for early state
   ============================================================ */
html.sidebar-collapsed .sidebar { width: 56px; }
html.sidebar-collapsed .sidebar .nav-item {
  /* font-size:0 hides text nodes (we can't target them); spans use display:none below */
  font-size: 0;
  padding: 8px 0;
  margin: 1px 6px;
  justify-content: center;
  gap: 0;
}
html.sidebar-collapsed .sidebar .nav-item svg.icon {
  font-size: 13.5px; /* restore so currentColor/em-based sizing inside stays OK */
}
html.sidebar-collapsed .sidebar .nav-item .count { display: none; }
html.sidebar-collapsed .sidebar .nav-group-label { display: none; }
html.sidebar-collapsed .sidebar > div:first-child {
  padding: 6px 4px 14px;
  text-align: center;
}
html.sidebar-collapsed .sidebar > div:first-child > div:first-child {
  font-size: 11px;
  letter-spacing: 0.02em;
}
html.sidebar-collapsed .sidebar .wordmark .ai { margin-left: 0; }
html.sidebar-collapsed .sidebar > div:first-child > div:nth-child(2) { display: none; }
html.sidebar-collapsed .sidebar .nav-item.active { box-shadow: inset 3px 0 0 var(--brand-primary); }

/* Tooltip on hover (collapsed state only) */
html.sidebar-collapsed .sidebar .nav-item { position: relative; }
html.sidebar-collapsed .sidebar .nav-item[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #1a2440;
  color: #fff;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
html.sidebar-collapsed .sidebar .nav-item:hover[data-tip]::after { opacity: 1; }

/* Toggle button (injected by brand.js, sits at bottom-right of sidebar) */
.sidebar-toggle {
  position: fixed;
  top: 12px;
  left: 224px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-paper);
  border: 1px solid var(--line);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  z-index: 50;
  transition: left 200ms ease, color 120ms ease, background 120ms ease;
}
.sidebar-toggle:hover {
  color: var(--text);
  background: var(--bg-subtle);
  border-color: var(--line-strong);
}
.sidebar-toggle svg { transition: transform 200ms ease; }
html.sidebar-collapsed .sidebar-toggle { left: 40px; }
html.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
@media (max-width: 800px) {
  .sidebar-toggle { display: none; }
}
