/* ==========================================================================
   Supplier Portal design system — tokens + components. NO DaisyUI.
   Layout = Tailwind utilities (compiled bundle); look = these classes.
   Served directly (no build step). See specs/supplier/OVERHAUL.md D5.
   ========================================================================== */

/* ---- self-hosted faces (brand wordmark + numeric counters) ----
   base.css is the only stylesheet besides style.min.css that supplier pages
   load; the min bundle ships neither face, so declare them here. */
@font-face {
  font-family: 'DM Serif Display';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/DMSerifDisplay-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/FiraCode-Medium.woff2') format('woff2');
}

/* ---- tokens ----
   Recoloured to the "Werkbank" nav scales (specs/nav/REDESIGN.md §2b/§4):
   warm paper in light, warm graphite in dark, one signal-orange accent.
   surface is the RAISED tone (cards pop above bg); surface-2 is recessed. */
:root {
  --sp-bg: #f1f0eb;
  --sp-surface: #fafaf7;
  --sp-surface-2: #e4e2db;
  --sp-border: rgba(30, 28, 24, 0.12);
  --sp-border-strong: rgba(30, 28, 24, 0.24);
  --sp-text: #23221f;
  --sp-muted: rgba(35, 34, 31, 0.60);
  --sp-accent: #1e3a5f;
  --sp-accent-strong: #162c49;
  --sp-accent-text: #ffffff;
  --sp-ok: #2f855a;
  --sp-ok-bg: rgba(47, 133, 90, 0.12);
  --sp-warn: #b7791f;
  --sp-warn-bg: rgba(183, 121, 31, 0.13);
  --sp-late: #d9480f;
  --sp-late-bg: rgba(217, 72, 15, 0.12);
  --sp-danger: #c53030;
  --sp-danger-bg: rgba(197, 48, 48, 0.11);
  --sp-radius: 6px;
  --sp-shadow: 0 1px 2px rgba(30, 28, 24, 0.05), 0 1px 4px rgba(30, 28, 24, 0.07);
  --sp-shadow-lg: 0 4px 14px rgba(30, 28, 24, 0.14);
  --sp-focus: 0 0 0 3px rgba(217, 72, 15, 0.32);
}

[data-theme="dark"] {
  --sp-bg: #121214;
  --sp-surface: #18181b;
  --sp-surface-2: #1e1e22;
  --sp-border: rgba(255, 255, 255, 0.08);
  --sp-border-strong: rgba(255, 255, 255, 0.16);
  --sp-text: #dad8d3;
  --sp-muted: rgba(218, 216, 211, 0.55);
  --sp-accent: #60a5fa;
  --sp-accent-strong: #7ab4fb;
  --sp-accent-text: #0c1929;
  --sp-ok: #3fb27f;
  --sp-ok-bg: rgba(63, 178, 127, 0.14);
  --sp-warn: #d9a62e;
  --sp-warn-bg: rgba(217, 166, 46, 0.15);
  --sp-late: #e8632c;
  --sp-late-bg: rgba(232, 99, 44, 0.15);
  --sp-danger: #e05252;
  --sp-danger-bg: rgba(224, 82, 82, 0.16);
  --sp-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.5);
  --sp-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.55);
  --sp-focus: 0 0 0 3px rgba(232, 99, 44, 0.42);
}

/* ---- base ---- */
body.sp-body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--sp-bg);
  color: var(--sp-text);
  -webkit-font-smoothing: antialiased;
}

.sp-muted { color: var(--sp-muted); }
.sp-link { color: var(--sp-accent); text-decoration: none; }
.sp-link:hover { text-decoration: underline; }

/* ---- surfaces ---- */
.sp-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow);
}
.sp-card-flat { box-shadow: none; }
.sp-well {
  background: var(--sp-surface-2);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
}
.sp-navbar {
  background: var(--sp-surface);
  border-bottom: 1px solid var(--sp-border);
}

/* ---- buttons ---- */
.sp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  min-height: 2.5rem;
  border-radius: var(--sp-radius);
  border: 1px solid var(--sp-border-strong);
  background: var(--sp-surface);
  color: var(--sp-text);
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.25rem;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, opacity 120ms ease;
  text-decoration: none;
  white-space: nowrap;
}
.sp-btn:hover { background: var(--sp-surface-2); }
.sp-btn:focus-visible { outline: none; box-shadow: var(--sp-focus); }
.sp-btn:disabled, .sp-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.sp-btn-primary {
  background: var(--sp-accent);
  border-color: var(--sp-accent);
  color: var(--sp-accent-text);
}
.sp-btn-primary:hover { background: var(--sp-accent-strong); border-color: var(--sp-accent-strong); }
.sp-btn-danger {
  background: var(--sp-danger);
  border-color: var(--sp-danger);
  color: #fff;
}
.sp-btn-danger:hover { filter: brightness(1.1); }
.sp-btn-ghost { border-color: transparent; background: transparent; }
.sp-btn-ghost:hover { background: var(--sp-surface-2); }
.sp-btn-sm { min-height: 2rem; padding: 0.25rem 0.75rem; font-size: 0.8125rem; }

/* ---- inputs ---- */
.sp-input, .sp-select, .sp-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  min-height: 2.5rem;
  border-radius: var(--sp-radius);
  border: 1px solid var(--sp-border-strong);
  background: var(--sp-surface);
  color: var(--sp-text);
  font-size: 0.9375rem;
  transition: border-color 120ms ease;
}
.sp-input::placeholder, .sp-textarea::placeholder { color: var(--sp-muted); }
.sp-input:focus, .sp-select:focus, .sp-textarea:focus {
  outline: none;
  border-color: var(--sp-accent);
  box-shadow: var(--sp-focus);
}
.sp-input:disabled, .sp-input[readonly].sp-locked {
  background: var(--sp-surface-2);
  color: var(--sp-muted);
  cursor: not-allowed;
}
.sp-input-error { border-color: var(--sp-danger) !important; }
.sp-field-msg { font-size: 0.75rem; margin-top: 0.25rem; }
.sp-field-msg.is-error { color: var(--sp-danger); }

/* autosave state — set data-save-state on the field wrapper */
.sp-save-indicator {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity 150ms ease;
}
[data-save-state="saving"] .sp-save-indicator { opacity: 1; color: var(--sp-muted); }
[data-save-state="saved"] .sp-save-indicator { opacity: 1; color: var(--sp-ok); }
[data-save-state="error"] .sp-save-indicator { opacity: 1; color: var(--sp-danger); }
[data-save-state="error"] .sp-input { border-color: var(--sp-danger); }

/* ---- chips (status + urgency) ---- */
.sp-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.sp-chip-neutral { background: var(--sp-surface-2); color: var(--sp-muted); border-color: var(--sp-border); }
/* nav counters: rectangular, monospaced, filled accent (see REDESIGN.md §4) */
.sp-chip-accent,
.sp-chip-due {
  background: var(--sp-accent);
  color: var(--sp-accent-text);
  border-radius: 2px;
  font-family: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.sp-chip-ok { background: var(--sp-ok-bg); color: var(--sp-ok); }
.sp-chip-late { background: var(--sp-late-bg); color: var(--sp-late); }
.sp-chip-overdue { background: var(--sp-danger-bg); color: var(--sp-danger); }
.sp-chip-critical {
  background: var(--sp-danger);
  color: #fff;
  animation: sp-pulse 1.6s ease-in-out infinite;
}
@keyframes sp-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(179, 38, 30, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(179, 38, 30, 0); }
}

/* ---- progress ---- */
.sp-progress {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--sp-surface-2);
  overflow: hidden;
}
.sp-progress > div {
  height: 100%;
  border-radius: 999px;
  background: var(--sp-accent);
  transition: width 300ms ease;
}
.sp-progress.is-complete > div { background: var(--sp-ok); }

/* ---- tabs ---- */
.sp-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--sp-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.sp-tabs::-webkit-scrollbar { display: none; }
.sp-tab {
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--sp-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.sp-tab:hover { color: var(--sp-text); }
.sp-tab.is-active { color: var(--sp-accent); border-bottom-color: var(--sp-accent); }
.sp-tab:focus-visible { outline: none; box-shadow: var(--sp-focus); border-radius: 4px; }

/* ---- tables ---- */
.sp-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.sp-table th {
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sp-muted);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--sp-border-strong);
}
.sp-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--sp-border);
  vertical-align: middle;
}
.sp-table tr:last-child td { border-bottom: none; }

/* ---- modal (native <dialog>) ---- */
.sp-modal {
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  background: var(--sp-surface);
  color: var(--sp-text);
  box-shadow: var(--sp-shadow-lg);
  padding: 1.5rem;
  max-width: 32rem;
  width: calc(100vw - 2rem);
}
.sp-modal::backdrop { background: rgba(10, 12, 14, 0.55); }

/* ---- toasts ---- */
.sp-toast-region {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 24rem;
}
.sp-toast {
  padding: 0.75rem 1rem;
  border-radius: var(--sp-radius);
  border: 1px solid var(--sp-border);
  background: var(--sp-surface);
  box-shadow: var(--sp-shadow-lg);
  font-size: 0.875rem;
  border-left: 3px solid var(--sp-accent);
}
.sp-toast.is-success { border-left-color: var(--sp-ok); }
.sp-toast.is-error { border-left-color: var(--sp-danger); }
.sp-toast.is-warning { border-left-color: var(--sp-warn); }

/* ---- banner (critical escalations) ---- */
.sp-banner-critical {
  background: var(--sp-danger);
  color: #fff;
  border-radius: 999px;
  padding: 0.375rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.sp-banner-critical:hover { filter: brightness(1.08); }

/* ---- kanban ---- */
.sp-kanban-col {
  background: var(--sp-surface-2);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
}
.sp-kanban-col > header {
  padding: 0.625rem 0.875rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sp-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---- lock state ---- */
.sp-lock-badge { color: var(--sp-ok); font-weight: 700; font-size: 0.75rem; }

/* ---- skeleton/empty ---- */
.sp-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--sp-muted);
}

/* ==========================================================================
   Additions for the D5/D6 template rewrite (navbar, dropdowns, nav links).
   ========================================================================== */

/* nav links (desktop) */
.sp-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--sp-radius);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--sp-muted);
  text-decoration: none;
  white-space: nowrap;
}
.sp-nav-link:hover { color: var(--sp-text); background: var(--sp-surface-2); }
/* active = 2px accent bar under a full-strength label; orange marks, never colours the text */
.sp-nav-link.is-active {
  color: var(--sp-text);
  font-weight: 700;
  border-radius: 0;
  box-shadow: inset 0 -2px 0 0 var(--sp-accent);
}
.sp-nav-link.is-active:hover { background: transparent; }

/* JS-free dropdowns (<details><summary>…) */
.sp-dropdown > summary { list-style: none; cursor: pointer; }
.sp-dropdown > summary::-webkit-details-marker { display: none; }
.sp-menu-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  min-width: 12rem;
  z-index: 60;
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow-lg);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.sp-dropdown-end .sp-menu-panel { left: auto; right: 0; }
.sp-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  min-height: 2.25rem;
  border-radius: var(--sp-radius);
  font-size: 0.875rem;
  color: var(--sp-text);
  text-decoration: none;
}
.sp-menu-item:hover { background: var(--sp-surface-2); }

/* unread notification accent (left rail, no border-l-4 util) */
.sp-unread { box-shadow: inset 3px 0 0 0 var(--sp-accent); }

/* radial progress ring (replaces DaisyUI radial-progress) */
.sp-ring {
  --sp-ring-value: 0;
  width: 4rem;
  height: 4rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--sp-accent);
  background:
    radial-gradient(closest-side, var(--sp-surface) 78%, transparent 79% 100%),
    conic-gradient(var(--sp-accent) calc(var(--sp-ring-value) * 1%), var(--sp-surface-2) 0);
}
.sp-ring.is-complete {
  color: var(--sp-ok);
  background:
    radial-gradient(closest-side, var(--sp-surface) 78%, transparent 79% 100%),
    conic-gradient(var(--sp-ok) calc(var(--sp-ring-value) * 1%), var(--sp-surface-2) 0);
}

/* vertical timeline (replaces DaisyUI steps) */
.sp-timeline { list-style: none; padding: 0; margin: 0; }
.sp-timeline > li {
  position: relative;
  padding-left: 1.75rem;
  padding-bottom: 1.25rem;
}
.sp-timeline > li::before {
  content: "";
  position: absolute;
  left: 0.375rem;
  top: 0.35rem;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
  background: var(--sp-accent);
}
.sp-timeline > li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 0.72rem;
  top: 1.1rem;
  bottom: 0;
  width: 2px;
  background: var(--sp-border);
}

/* stat tile */
.sp-stat {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 1rem 1.25rem;
}
.sp-stat-label { font-size: 0.75rem; color: var(--sp-muted); font-weight: 600; }
.sp-stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; margin-top: 0.25rem; }

/* checkbox that reads well in both themes without DaisyUI */
.sp-checkbox {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--sp-accent);
  cursor: pointer;
}
.sp-checkbox:disabled { cursor: not-allowed; opacity: 0.6; }

/* chat bubbles (issue detail) */
.sp-bubble-you {
  background: var(--sp-accent);
  color: var(--sp-accent-text);
  border-radius: var(--sp-radius);
}
.sp-bubble-them {
  background: var(--sp-surface-2);
  color: var(--sp-text);
  border-radius: var(--sp-radius);
}

/* spinner
   NB: this file loads AFTER the tailwind bundle, so at equal specificity
   `display: inline-block` here beats tailwind's `.hidden` — the .hidden
   combo below keeps JS show/hide toggling working. */
.sp-spinner.hidden { display: none; }
.sp-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--sp-border-strong);
  border-top-color: var(--sp-accent);
  border-radius: 999px;
  animation: sp-spin 0.7s linear infinite;
}
@keyframes sp-spin { to { transform: rotate(360deg); } }

/* auth card (login / activate) */
.sp-auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--sp-bg);
}
.sp-auth-card {
  width: 100%;
  max-width: 24rem;
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow-lg);
  padding: 2rem;
}

/* days-past text beside urgency chips (outside the pill so it can wrap) */
.sp-urgency-past { color: var(--sp-danger); }

/* ---- messenger-style composer (issue chat) ----
   One rounded surface that holds tray + input row. Pill at rest, grows with
   content; accent ring on focus; send button transforms when sendable. */
.sp-composer {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border-strong);
  border-radius: 1.375rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.sp-composer:focus-within {
  border-color: var(--sp-accent);
  box-shadow: var(--sp-focus);
}
.sp-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  padding: 0.375rem;
}
.sp-composer-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--sp-text);
  font-size: 0.9375rem;
  line-height: 1.4;
  padding: 0.4375rem 0.25rem;
  resize: none;
  max-height: 8.5em; /* ~6 lines, then internal scroll */
  overflow-y: hidden;
}
.sp-composer-input:focus { outline: none; box-shadow: none; }
.sp-composer-input::placeholder { color: var(--sp-muted); }

/* round icon buttons living inside the pill */
.sp-composer-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--sp-muted);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
  -webkit-tap-highlight-color: transparent;
}
.sp-composer-icon:hover { background: var(--sp-surface-2); color: var(--sp-text); }
.sp-composer-icon:focus-visible { outline: none; box-shadow: var(--sp-focus); }

/* the send button: muted + inert while empty, accent circle when sendable */
.sp-composer-send {
  color: var(--sp-muted);
  transform: scale(0.9);
  transition: background-color 160ms ease, color 160ms ease,
              transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sp-composer-send:disabled { cursor: default; }
.sp-composer-send:disabled:hover { background: transparent; color: var(--sp-muted); }
.sp-composer.is-sendable .sp-composer-send {
  background: var(--sp-accent);
  color: var(--sp-accent-text);
  transform: scale(1);
}
.sp-composer.is-sendable .sp-composer-send:hover { background: var(--sp-accent-strong); }

/* attachment tray inside the composer, above the input row */
.sp-composer-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem 0;
}
.sp-composer-tray:empty { display: none; }
.sp-composer-tray .sp-chip { max-width: 14rem; }

/* upload progress strip inside the composer */
.sp-composer-status { padding: 0.375rem 0.875rem 0; }

/* hint below, barely-there until needed */
.sp-composer-hint {
  font-size: 0.6875rem;
  color: var(--sp-muted);
  opacity: 0.75;
  padding: 0.375rem 0.875rem 0;
}
