/* ============================================================
 * APEX SALES OS · SYSTEM STATE PAGES
 * Owner: Worker W22
 * Page-local styles only · .page-sys-* namespace
 * Used by: 404 (not-found), network-error, permission-denied,
 *          loading-overlay utility, empty-state wrappers
 * ============================================================ */

/* outer frame — centered card on a faint radial purple wash */
.page-sys-frame {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
  padding: 60px 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(99, 91, 255, 0.06), transparent 60%),
    var(--bg-warm);
}

/* the card itself · capped width, centered column */
.page-sys-card {
  max-width: 480px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* circular icon medallion · 80x80, neutral by default */
.page-sys-icon {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: var(--bg-tint);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.page-sys-icon svg {
  width: 36px;
  height: 36px;
}

/* accent variant · purple-soft tint for success/online states */
.page-sys-icon.accent {
  background: var(--primary-soft);
  border-color: var(--status-done-bd);
  color: var(--primary);
}

/* eyebrow label · mono uppercase status code */
.page-sys-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* page title */
.page-sys-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0;
  color: var(--text);
}

/* supporting paragraph */
.page-sys-sub {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 380px;
  margin: 0;
}

/* CTA row · one primary + one secondary */
.page-sys-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* meta footer · mono attempted-path + support link */
.page-sys-meta {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  width: 100%;
  font-size: 11.5px;
  color: var(--text-faint);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.page-sys-meta .mono {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}
.page-sys-meta a {
  color: var(--text-muted);
  text-decoration: none;
}
.page-sys-meta a:hover {
  color: var(--text-soft);
  text-decoration: underline;
}

/* network error · live ping chip */
.page-sys-ping {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 6px 12px;
  background: var(--bg-tint);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}
.page-sys-ping .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: livePulse 1.6s infinite ease-in-out;
}
.page-sys-ping.up .dot {
  background: var(--primary);
}
/* offline state · muted grey, NEVER red */
.page-sys-ping.down .dot {
  background: var(--text-faint);
}

/* ============================================================
 * .system-page · BEM fallback classes used by the inline
 * renderers inside shared/router.js (renderNotFound,
 * renderError, renderPermissionDenied, renderLoading).
 *
 * Mirrors mockup #11 design language with the same purple
 * radial wash, eyebrow → big title → muted body → action row.
 * Visible immediately when something goes wrong inside the
 * router itself (before a landable system page can mount).
 * ============================================================ */

.system-page {
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 32px 72px;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(99, 91, 255, 0.08), transparent 70%),
    var(--bg-warm);
  gap: 14px;
}

/* STATE 03 · 404 NOT FOUND — tighter rhythm so the giant gradient
 * digit owns the canvas. Eyebrow hugs the digit, headline sits 14px
 * below it, body 18px under, attempted-path chip 8px under that,
 * actions 32px under the chip. Matches mockup #11 STATE 03. */
.system-page--not-found {
  gap: 0;
}

.system-page__eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}

.system-page__code {
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.044em;
  font-size: 132px;
  line-height: 1;
  margin: 0 0 4px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-variant-numeric: tabular-nums;
}

/* 404 digit · JetBrains Mono mono numerals, gradient text-clip,
 * massive at 152px so it dominates the canvas. Matches mockup #11
 * STATE 03 (.err-code) but swaps in JBM mono for the pixel-style
 * "system" feel — the rest of the page stays Inter Tight. */
.system-page--not-found .system-page__code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 152px;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin: 6px 0 6px;
  /* Subtle gradient text-shadow so the digit lifts off the wash without
   * leaking color (text-fill-color: transparent). */
  filter: drop-shadow(0 18px 32px rgba(99, 91, 255, 0.18));
}

.system-page__title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.2;
  margin: 0;
  color: var(--text);
  max-width: 560px;
}

.system-page__body {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
  max-width: 520px;
}

.system-page__body b {
  color: var(--text);
  font-weight: 600;
}

.system-page__path {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: var(--bg-tint);
  border: 1px solid var(--border);
  color: var(--text-soft);
  padding: 7px 14px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  max-width: 90%;
}

.system-page__path-label {
  color: var(--text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  font-size: 10.5px;
}

/* The attempted-path value · JBM mono so it reads as a literal route.
 * Inherits the chip's 12px size; text-soft for readable contrast. */
.system-page__path-value {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-soft);
  word-break: break-all;
}

/* Not-found rhythm overrides — gap:0 on the parent lets us pin every
 * spacing decision per element instead of relying on flex gap. */
.system-page--not-found .system-page__eyebrow { margin-bottom: 4px; }
.system-page--not-found .system-page__title   { margin-top: 8px;  margin-bottom: 14px; }
.system-page--not-found .system-page__body    { margin-bottom: 22px; }
.system-page--not-found .system-page__path    { margin-top: 0; margin-bottom: 0; }
.system-page--not-found .system-page__actions { margin-top: 28px; gap: 12px; }

.system-page__actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.system-page__action,
.system-page__action.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 550;
  border-radius: var(--radius, 8px);
}

.system-page__icon {
  width: 96px;
  height: 96px;
  border-radius: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  position: relative;
  box-shadow: var(--shadow-sm, 0 2px 5px -1px rgba(50, 50, 93, 0.08));
}

.system-page__icon svg {
  width: 44px;
  height: 44px;
  color: var(--primary);
  position: relative;
  z-index: 1;
}

/* Permission-denied lock tile · purple gradient, calm (NOT alarmed).
   Restricted, not punitive — same purple as the brand mark, no red. */
.system-page__icon--lock {
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(255, 255, 255, 0.18), transparent 55%),
    var(--grad);
  border-color: transparent;
  color: #ffffff;
  box-shadow:
    0 12px 30px -12px rgba(99, 91, 255, 0.55),
    0 2px 5px -1px rgba(50, 50, 93, 0.10);
}

.system-page__icon--lock svg {
  color: #ffffff;
}

/* Inline path chip baked into the body sentence on permission-denied.
   Mono, faint pill, no border weight — sits in flow without breaking
   the line. Keeps the attempted hash readable at small sizes. */
.system-page__body-path {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  padding: 2px 8px;
  margin: 0 2px;
  border-radius: 6px;
  background: var(--bg-tint);
  color: var(--text-soft);
  letter-spacing: 0;
  white-space: nowrap;
}

/* No-access variant · slightly tighter rhythm so the lock tile,
   eyebrow, headline, body, and action row all fit a 1440x900 frame
   without scroll. Inherits the same purple radial wash from
   .system-page. */
.system-page--no-access {
  gap: 12px;
  padding: 56px 32px 64px;
}

.system-page--no-access .system-page__title {
  max-width: 520px;
}

.system-page--no-access .system-page__body {
  max-width: 480px;
}

/* Live "reconnecting" ring around the icon for the network state */
.system-page__icon--pulsing::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 36px;
  border: 1.5px solid var(--primary);
  opacity: 0;
  animation: netRingPulse 2s cubic-bezier(.4, 0, .6, 1) infinite;
}

@keyframes netRingPulse {
  0%   { opacity: .5; transform: scale(.92); }
  100% { opacity: 0;  transform: scale(1.12); }
}

/* Calm gradient icon tile for renderError() — purple wash, NEVER red. */
.system-page__icon--alert {
  background: var(--grad);
  border: 1px solid transparent;
  box-shadow:
    0 18px 40px -22px rgba(99, 91, 255, 0.55),
    0 2px 5px -1px rgba(50, 50, 93, 0.10);
}
.system-page__icon--alert svg {
  color: #fff;
  width: 42px;
  height: 42px;
}

/* Collapsed stack-trace details for renderError(). JetBrains Mono.
 * Tight, muted, never alarming. Sits below the action row.
 */
.system-page--error {
  gap: 12px;
  padding: 48px 32px 56px;
}

.system-page__stack {
  margin-top: 10px;
  max-width: 720px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.system-page__stack-summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 14px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  user-select: none;
}
.system-page__stack-summary::-webkit-details-marker { display: none; }
.system-page__stack-summary::before {
  content: '+';
  display: inline-block;
  width: 14px;
  color: var(--text-faint);
  font-weight: 700;
}
.system-page__stack[open] .system-page__stack-summary::before { content: '−'; }
.system-page__stack[open] .system-page__stack-summary {
  border-bottom: 1px solid var(--border);
}

.system-page__stack-pre {
  margin: 0;
  padding: 14px 16px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  max-height: 220px;
  overflow: auto;
  background: var(--bg-tint);
}

/* ============================================================
 * Loading skeleton (.page-loading) used by the router while it
 * imports the matched route module. Mirrors mockup STATE 01:
 * hero block with a soft purple radial wash, a 4-card KPI row,
 * 4 list-shape rows, and a calm mono meta label. Gentle linear
 * shimmer slides left-to-right across all blocks. No spinner.
 * No bouncy animation.
 * ============================================================ */

.page-loading {
  min-height: calc(100vh - 56px);
  padding: 28px 32px 40px;
  background: var(--bg-warm);
  display: flex;
  flex-direction: column;
  font-size: 0;
}

/* hero shimmer · ::before is painted directly so it shows up the
   instant the router mounts the loader, before any child appends */
.page-loading::before {
  content: '';
  display: block;
  height: 168px;
  border-radius: var(--radius-xl, 16px);
  border: 1px solid var(--status-done-bd);
  margin-bottom: 22px;
  background:
    radial-gradient(60% 60% at 100% 0%, rgba(99, 91, 255, 0.10), transparent 65%),
    linear-gradient(90deg,
      var(--bg-tint) 0%,
      var(--bg-soft) 50%,
      var(--bg-tint) 100%);
  background-size: 100% 100%, 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

/* KPI row · 4 cards across, 14px gap, calm card-shape mirrors
   the dashboard hero KPI strip so layout shift is invisible */
.page-loading__kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.page-loading__kpi-card {
  height: 112px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  position: relative;
  overflow: hidden;
}

/* three internal lines per KPI card · sm label, xl number, sm sub */
.page-loading__kpi-card::before,
.page-loading__kpi-card::after {
  content: '';
  position: absolute;
  left: 22px;
  border-radius: 99px;
  background:
    linear-gradient(90deg,
      var(--bg-tint) 0%,
      var(--bg-soft) 50%,
      var(--bg-tint) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

.page-loading__kpi-card::before {
  top: 20px;
  height: 10px;
  width: 60%;
}

.page-loading__kpi-card::after {
  top: 42px;
  height: 36px;
  width: 70%;
  border-radius: 12px;
}

/* row shape · matches dashboard list rhythm
   (40px avatar | flex middle | three 60px right-aligned chips) */
.page-loading__row {
  height: 72px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  margin-bottom: 6px;
  position: relative;
  overflow: hidden;
}

/* 40px circular avatar shimmer on the left */
.page-loading__row::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 20px;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background:
    linear-gradient(90deg,
      var(--bg-tint) 0%,
      var(--bg-soft) 50%,
      var(--bg-tint) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

/* primary text line to the right of the avatar */
.page-loading__row::after {
  content: '';
  position: absolute;
  top: 24px;
  left: 76px;
  width: 220px;
  height: 14px;
  border-radius: 99px;
  background:
    linear-gradient(90deg,
      var(--bg-tint) 0%,
      var(--bg-soft) 50%,
      var(--bg-tint) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

/* slight width variance so the 4 list rows don't feel cloned ·
   note: kpi-row is child 1, then 4 rows are children 2-5 */
.page-loading__row:nth-child(3)::after { width: 180px; }
.page-loading__row:nth-child(4)::after { width: 240px; }
.page-loading__row:nth-child(5)::after { width: 200px; }

.page-loading__label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 14px;
  letter-spacing: 0.04em;
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ============================================================
 * .sys-state-empty · generic empty-state component
 * Pixel parity vs design-mockups/11-system-states.html STATE 02.
 * Scoped overrides on top of the .sys-state baseline in
 * frontend/styles/02-primitives.css (which we do not touch).
 *
 * Layout: centered column on a soft purple radial wash. A 120px
 * surface medallion sits above an eyebrow → 28px headline →
 * gradient accent line → muted body → two-button action row
 * (ghost secondary + gradient hero primary).
 * ============================================================ */

.sys-state.sys-state-empty {
  min-height: calc(100vh - 56px);
  padding: 64px 32px 72px;
  background:
    radial-gradient(70% 50% at 50% 0%, rgba(99, 91, 255, 0.06), transparent 70%),
    var(--bg-warm);
}

.sys-state-empty .sys-state-inner {
  max-width: 540px;
  gap: 0;
}

/* 120x120 medallion · surface tile + faint gradient halo behind icon */
.sys-state-empty .sys-state-icon-tile {
  width: 120px;
  height: 120px;
  border-radius: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  margin-bottom: 28px;
  box-shadow:
    0 16px 40px -10px rgba(99, 91, 255, 0.20),
    var(--shadow-sm, 0 2px 5px -1px rgba(50, 50, 93, 0.08));
}

.sys-state-empty .sys-state-icon-halo {
  position: absolute;
  inset: -2px;
  border-radius: 32px;
  background: var(--grad);
  opacity: 0.18;
  filter: blur(20px);
  pointer-events: none;
}

.sys-state-empty .sys-state-icon {
  position: relative;
  z-index: 1;
  width: 52px;
  height: 52px;
  color: var(--primary);
}

/* eyebrow · optional mono uppercase tag above the headline */
.sys-state-empty .sys-state-eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 10px;
}

/* big aspirational headline */
.sys-state-empty .sys-state-title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.020em;
  line-height: 1.2;
  text-align: center;
  max-width: 520px;
  margin: 0 0 8px;
  color: var(--text);
}

/* gradient accent line (mockup: "Wide-open day ahead.") */
.sys-state-empty .sys-state-accent {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.020em;
  line-height: 1.2;
  text-align: center;
  max-width: 520px;
  margin: 0 0 12px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* supporting body · 480px column, generous leading */
.sys-state-empty .sys-state-sub {
  font-size: 15px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.55;
  max-width: 480px;
  margin: 0 0 28px;
}

/* CTA row · ghost secondary + gradient hero primary */
.sys-state-empty .sys-state-actions {
  display: flex;
  gap: 12px;
  margin-top: 0;
  flex-wrap: wrap;
  justify-content: center;
}

/* hero primary · matches mockup .btn-hero (padding, glow, weight) */
.sys-state-empty .sys-state-actions .btn-hero {
  padding: 16px 28px;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.008em;
  border-radius: 12px;
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.04),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    0 10px 28px -8px rgba(99, 91, 255, 0.55),
    0 3px 8px -3px rgba(99, 91, 255, 0.40);
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}

/* lift + brighten on hover · never goes white */
.sys-state-empty .sys-state-actions .btn-hero:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  color: #fff;
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.04),
    inset 0 0 0 1px rgba(255, 255, 255, 0.22),
    0 14px 34px -8px rgba(99, 91, 255, 0.62),
    0 4px 10px -3px rgba(99, 91, 255, 0.45);
}

.sys-state-empty .sys-state-actions .btn-hero:active {
  transform: translateY(0);
  filter: brightness(1.02);
}

/* ghost secondary · btn-lg sizing parity */
.sys-state-empty .sys-state-actions .btn-lg {
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 550;
  border-radius: var(--radius, 8px);
}
