/* shared.css: theme tokens and shared idioms for every Synion view.
   Same token vocabulary as the sibling trading apps so components port between them unchanged;
   Synion's identity is the violet accent. */
:root {
  /* ── Dark theme (default) ────────────────────────────────────────────── */
  --color-bg-primary: #0f1419;
  --color-bg-secondary: #1a1f2e;
  --color-bg-tertiary: #242938;
  /* The page canvas every view sits on. Dark: matches bg-secondary; light: pure white. */
  --color-canvas: #1a1f2e;
  --color-border: #2d3748;
  --color-border-light: #3d4556;
  --color-text-primary: #ffffff;
  --color-text-secondary: #a0aec0;
  --color-text-muted: #718096;
  --color-accent: #8b5cf6;
  --color-accent-hover: #7c3aed;
  --color-success: #10b981;
  --color-success-bg: rgba(52,211,153,0.14);
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-danger-bg: rgba(248,113,113,0.14);

  /* Adaptive text opacity scale (use instead of rgba(255,255,255,N)) */
  --color-text-hi:   rgba(255,255,255,0.92);
  --color-text-med:  rgba(255,255,255,0.65);
  --color-text-lo:   rgba(255,255,255,0.38);
  --color-text-xlo:  rgba(255,255,255,0.18);

  /* Adaptive surface tints (use instead of rgba(255,255,255,0.0N) backgrounds) */
  --color-surface-hover:  rgba(255,255,255,0.06);
  --color-surface-tint:   rgba(255,255,255,0.03);
  --color-surface-subtle: rgba(255,255,255,0.08);

  /* Modals / overlays */
  --color-modal-bg:      #1e2230;
  --color-modal-border:  rgba(255,255,255,0.12);
  --color-backdrop:      rgba(0,0,0,0.6);

  /* component-level vars */
  --color-row-active-bg:    rgba(167,139,250,0.14);
  --color-row-active-border: rgba(167,139,250,0.5);
  --color-row-hover-bg:     rgba(167,139,250,0.07);
  --color-logo-text: #ffffff;
  --color-btn-ghost-bg: transparent;
  --color-btn-ghost-bg-hover: #303745;
  --color-btn-ghost-border: #3d4556;
  --color-btn-ghost-border-hover: #4a5568;
  --color-btn-ghost-text: #a0aec0;
  --color-btn-ghost-text-hover: #ffffff;
  --color-btn-action-bg: #303745;
  --color-btn-action-border: #232931;
  --color-btn-action-bg-hover: #1f2430;
  --color-input-bg: #242938;
  --color-input-border: #3d4556;
  --color-input-text: #ffffff;
  /* Cards read as an elevation step above BOTH page backgrounds. */
  --color-card-bg: #232b3d;
  --color-card-border: #465063;
  --color-overlay-bg: rgba(0, 0, 0, 0.7);

  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  line-height: 1.5;
  font-weight: 400;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Light theme ─────────────────────────────────────────────────────── */
:root[data-theme="light"] {
  /* Page canvas is PURE WHITE on every view: cards and panels are defined by hairline
     borders and the grey secondary/subtle tints, not by a grey page. */
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #f8f9fa;
  --color-bg-tertiary: #e8eaed;
  --color-canvas: #ffffff;
  --color-border: #dadce0;
  --color-border-light: #e8eaed;
  --color-text-primary: #202124;
  --color-text-secondary: #5f6368;
  --color-text-muted: #9aa0a6;
  --color-accent: #6d28d9;
  --color-accent-hover: #5b21b6;
  --color-success: #137333;
  --color-success-bg: rgba(19,115,51,0.1);
  --color-warning: #b06000;
  --color-danger: #c5221f;
  --color-danger-bg: rgba(197,34,31,0.1);

  /* Solid text scale — no opacity, high contrast on white */
  --color-text-hi:   #202124;
  --color-text-med:  #5f6368;
  --color-text-lo:   #9aa0a6;
  --color-text-xlo:  #bdc1c6;

  /* Near-white surface scale:
       #ffffff  page canvas, modals, inputs (things that sit ABOVE a card)
       #f8f9fa  card / panel surface
       #f1f3f4  hover
       #e8eaed  subtle fills, hairline-light */
  --color-surface-hover:  #f1f3f4;
  --color-surface-tint:   #f8f9fa;
  --color-surface-subtle: #e8eaed;

  --color-row-active-bg:    #ede9fe;
  --color-row-active-border: #8b5cf6;
  --color-row-hover-bg:     #f1f3f4;

  --color-modal-bg:     #ffffff;
  --color-modal-border: #dadce0;
  --color-backdrop:     rgba(0,0,0,0.45);

  --color-logo-text: #202124;
  --color-btn-ghost-bg: transparent;
  --color-btn-ghost-bg-hover: #f1f3f4;
  --color-btn-ghost-border: #dadce0;
  --color-btn-ghost-border-hover: #9aa0a6;
  --color-btn-ghost-text: #5f6368;
  --color-btn-ghost-text-hover: #202124;
  --color-btn-action-bg: #f1f3f4;
  --color-btn-action-border: #dadce0;
  --color-btn-action-bg-hover: #e8eaed;
  /* Inputs stay pure white so they read as editable ON a tinted card. */
  --color-input-bg: #ffffff;
  --color-input-border: #dadce0;
  --color-input-text: #202124;
  --color-card-bg: #f8f9fa;
  --color-card-border: #dadce0;
  --color-overlay-bg: rgba(0, 0, 0, 0.4);
}

html, body {
  font-family: inherit;
  line-height: inherit;
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--color-accent-hover);
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

/* ── Shared card idioms ─────────────────────────────────────────────────────
   One implementation for the small furniture every card uses: chips, status
   dots and lines, warning callouts, inline spinners, icon buttons. Pages must
   use these instead of redeclaring per-page copies — scoped styles carry only
   layout, never colors. All values are theme tokens, correct in both themes. */

/* Small uppercase label chip. */
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--color-row-active-bg);
  border: 1px solid var(--color-row-active-border);
  color: var(--color-accent);
}

/* Neutral chip variant — informational tags with no accent meaning. */
.chip.neutral {
  background: var(--color-surface-subtle);
  border-color: var(--color-border);
  color: var(--color-text-med);
}

/* Status dot — neutral by default, .success for active/healthy, .warning for in-progress. */
.status-dot {
  display: inline-flex;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-lo);
  flex-shrink: 0;
}

.status-dot.success { background: var(--color-success); }
.status-dot.warning { background: var(--color-warning); }
.status-dot.danger { background: var(--color-danger); }

/* Inline status text, pairs with .status-dot. */
.status-line {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.status-line.success { color: var(--color-success); }
.status-line.warning { color: var(--color-warning); }
.status-line.danger { color: var(--color-danger); }

/* Warning callout — irreversible-action notices. */
.callout-warning {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(234, 179, 8, 0.07);
  border: 1px solid rgba(234, 179, 8, 0.28);
  border-radius: 7px;
  padding: 0.75rem 1rem;
}

.callout-warning .callout-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-warning);
}

/* Inline spinner for in-flight button/row states. */
.spinner-inline {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin-inline 0.7s linear infinite;
}

@keyframes spin-inline {
  to { transform: rotate(360deg); }
}

/* Borderless icon button (copy, dismiss, …). */
.icon-btn {
  background: none;
  border: none;
  color: var(--color-text-lo);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  color: var(--color-text-med);
  background: var(--color-surface-subtle);
}

/* Primary / secondary buttons — the two button shapes every page uses. */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid var(--color-accent);
  background: var(--color-accent);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-tint);
  color: var(--color-text-hi);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-surface-hover);
}

/* Code sample block — config snippets, script previews. */
.code-block {
  border: 1px solid var(--color-border);
  border-radius: 7px;
  background: var(--color-surface-tint);
  overflow: hidden;
}

.code-block .code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-lo);
}

.code-block pre {
  margin: 0;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--color-text-primary);
}

/* Segmented control — in-page tab switch. Pair with role="tablist"/role="tab". */
.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-tint);
}

.segmented-btn {
  flex: 1;
  padding: 7px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-lo);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.segmented-btn:hover { color: var(--color-text-hi); }

.segmented-btn.active {
  background: var(--color-surface-subtle);
  color: var(--color-text-hi);
}

/* Form fields — one input idiom for every form. */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-med);
}

.field input,
.field textarea,
.field select {
  font: inherit;
  /* 16px on the phone: anything smaller makes iOS zoom the page on focus. */
  font-size: 16px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-input-border);
  background: var(--color-input-bg);
  color: var(--color-input-text);
  box-sizing: border-box;
  width: 100%;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-row-active-bg);
}

.field .hint {
  font-size: 0.72rem;
  color: var(--color-text-lo);
}

@media (min-width: 768px) {
  .field input,
  .field textarea,
  .field select {
    font-size: 0.9rem;
  }
}
