/* ============================================================================
   theia-tokens.css
   ============================================================================
   Theia Fiber AI design tokens. Include this stylesheet in every console
   module so colors, spacing, fonts, and component primitives stay aligned
   across the platform.

   Inclusion order matters:
     1. theia-tokens.css       (this file)
     2. <module>.css            (module-specific styles)
     3. inline overrides        (rare; document why)

   Tokens are CSS custom properties on :root. Override per-module by setting
   them on a narrower scope, but never hardcode hex values in component CSS.

   Light theme is default. Dark theme is reserved for marketing surfaces
   (landing page, sign-in) and is NOT used in console modules.
   ============================================================================ */

/* ---- FONTS -------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=IBM+Plex+Sans:wght@300;400;500;600;700&display=swap');

:root {
  /* ---- Typography ----------------------------------------------------- */
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', Consolas, monospace;

  /* ---- Backgrounds (light theme) ------------------------------------- */
  --bg:  #ffffff;   /* primary surface */
  --bg2: #f8f9fb;   /* page background, secondary surface */
  --bg3: #f1f3f6;   /* hover state, tertiary surface */
  --bg4: #e8ecf2;   /* pressed state, disabled fill */

  /* ---- Brand --------------------------------------------------------- */
  --orange:    #d95f02;                    /* primary brand orange (light theme) */
  --orange-lt: rgba(217, 95, 2, 0.09);     /* tinted background */
  --orange-bd: rgba(217, 95, 2, 0.25);     /* border tint */
  --orange-dark: #f5731f;                  /* brand orange for dark backgrounds */

  --navy: #0a1628;                         /* deep navy — marketing & sign-in */

  /* ---- Severity colors (used by alarm, validation, status) ----------- */
  --red:    #b91c1c;
  --red-lt: rgba(185, 28, 28, 0.07);
  --red-bd: rgba(185, 28, 28, 0.28);

  --yellow:    #92400e;
  --yellow-lt: rgba(146, 64, 14, 0.08);
  --yellow-bd: rgba(146, 64, 14, 0.26);

  --green:    #15803d;
  --green-lt: rgba(21, 128, 61, 0.08);
  --green-bd: rgba(21, 128, 61, 0.26);

  --blue:    #1e5fa4;
  --blue-lt: rgba(30, 95, 164, 0.08);
  --blue-bd: rgba(30, 95, 164, 0.26);

  --purple:    #6d28d9;
  --purple-lt: rgba(109, 40, 217, 0.07);
  --purple-bd: rgba(109, 40, 217, 0.24);

  /* Maintenance / editor-context state. Same hue as --purple but
     namespaced so the KMZ Editor and Circuits modules reference a
     stable semantic token instead of color-by-color literals.
     Used for deselected geometry in editor panels (visible against
     the gray basemap, signals "maintenance" / "edit" context). */
  --maint:    #6d28d9;
  --maint-lt: rgba(109, 40, 217, 0.09);
  --maint-bd: rgba(109, 40, 217, 0.25);

  /* ---- Text colors --------------------------------------------------- */
  --text:  #0f172a;   /* primary — headings, key values */
  --text2: #334155;   /* secondary — body, labels */
  --text3: #64748b;   /* tertiary — meta, helper text */
  --text4: #94a3b8;   /* quaternary — disabled, placeholder */

  /* ---- Borders ------------------------------------------------------- */
  --border:  #e2e8f0;   /* default — card edges, divider lines */
  --border2: #cbd5e1;   /* emphasized — input fields, active borders */

  /* ---- Alarm state colors (canonical, never override) ---------------- */
  /* These map 1:1 to span.alarm_state values returned by the API.       */
  --col-unbound:      #94a3b8;   /* No port binding. Not monitoring.       */
  --col-no-telemetry: #64748b;   /* Port bound, ALM not yet detecting.     */
  --col-online:       #15803d;   /* Healthy. SLA clock not running.        */
  --col-warning:      #d97706;   /* Signal degraded. SLA clock may run.    */
  --col-critical:     #dc2626;   /* Major event. SLA clock running.        */

  /* ---- Spacing scale -------------------------------------------------- */
  /* Use these for margins, padding, and gaps. Multiples of 4. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* ---- Border radius ------------------------------------------------- */
  --radius-sm:   3px;   /* badges, small pills */
  --radius:      5px;   /* buttons, inputs */
  --radius-md:   6px;   /* cards */
  --radius-lg:   8px;   /* large cards, panels */
  /* NOTE: full-pill (border-radius: 999px) is FORBIDDEN per design rules.
     Always use rectangular shapes with soft corners. */

  /* ---- Shadows ------------------------------------------------------- */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:    0 1px 4px rgba(15, 23, 42, 0.07);
  --shadow-md: 0 2px 8px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.18);

  /* ---- Topbar ------------------------------------------------------- */
  /* Set --topbar-h to 0 when the module is embedded in the SvelteKit
     shell (the shell owns the topbar). Set to 56px for standalone preview. */
  --topbar-h: 0;
}

/* ============================================================================
   COMPONENT PRIMITIVES
   ============================================================================
   Base styles for the elements that appear in every console module. Modules
   add their own styles on top, but should never override these primitives
   without a documented reason.
   ============================================================================ */

body {
  background: var(--bg2);
  font-family: var(--font-sans);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Mono text (IDs, codes, numeric values) ----------------------------- */
.mono {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0;
}

/* ---- Cards -------------------------------------------------------------- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* ---- Buttons (rectangular, soft corners — NEVER full pill) ------------- */
.btn {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1.5px solid;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg);
  color: var(--text);
  border-color: var(--border2);
}
.btn:hover { background: var(--bg2); border-color: var(--text3); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}
.btn-primary:hover { background: #b54f02; border-color: #b54f02; }

/* ---- Form inputs -------------------------------------------------------- */
.inp, .sel {
  padding: 7px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease;
}
.inp:focus, .sel:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-lt);
}

/* ---- Status pills (severity badges) ------------------------------------ */
.pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  white-space: nowrap;
}
.pill.ok    { color: var(--green);  border-color: var(--green-bd);  background: var(--green-lt); }
.pill.warn  { color: var(--yellow); border-color: var(--yellow-bd); background: var(--yellow-lt); }
.pill.err   { color: var(--red);    border-color: var(--red-bd);    background: var(--red-lt); }
.pill.info  { color: var(--blue);   border-color: var(--blue-bd);   background: var(--blue-lt); }

/* ---- Topbar pattern ----------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 300;
  box-shadow: var(--shadow);
}

.logo-name {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--orange);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
}

.page-id {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  color: var(--text2);
  padding-left: 18px;
  border-left: 1px solid var(--border2);
  letter-spacing: 0;
  white-space: nowrap;
  line-height: 1.2;
}

/* ---- Section header (sec-head) ----------------------------------------- */
.sec-head {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--orange);
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* ---- Tables ------------------------------------------------------------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.tbl th {
  text-align: left;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.tbl td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
}
.tbl tr:last-child td { border-bottom: none; }

/* ============================================================================
   END theia-tokens.css
   ============================================================================ */
