/* Terminal Dark — copied from the security dashboard so the two UIs match
   exactly rather than approximately. Only change here: font paths are
   relative, because Flask serves /static/fonts/ and S3 does not.
   Canonical source: the design-system skill. */
/* ============================================================================
   Terminal Dark — Portable Design System
   Framework-agnostic. Import once at app entry, before other CSS.
   See DESIGN_PRINCIPLES.md for the rules behind these values.
   ============================================================================ */

/* Self-hosted fonts — no external network access required.
   Files live in static/fonts/ and are served by Flask at /static/fonts/. */
@font-face {
  font-family: 'Share Tech Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/sharetechmono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/rajdhani-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/rajdhani-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/rajdhani-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/rajdhani-700.woff2') format('woff2');
}

/* ============================================================================
   1. TOKENS — the single source of truth. Never hard-code these values.
   ============================================================================ */

:root {
  /* Backgrounds — layered depth (page → panel → card). Lighter = more foreground. */
  --bg:      #0a0c10;   /* outermost — page background */
  --bg2:     #0f1318;   /* panel background */
  --bg3:     #151b24;   /* card / input / nested item background */

  /* Borders — structure comes from these, not shadows */
  --border:  #1e2a38;   /* default subtle border */
  --border2: #2a3a4e;   /* hover / active / focus border */

  /* Text — three-step hierarchy */
  --text:    #c8d8e8;   /* primary — readable content */
  --text2:   #7a90a8;   /* secondary — labels, descriptions */
  --text3:   #3a5068;   /* muted — timestamps, placeholders, minor labels */

  /* Interactive accent — means "you can act here / this is live" */
  --accent:  #00b4d8;   /* primary cyan — links, focus, selection, highlights */
  --accent2: #0077a8;   /* darker cyan — primary button / active tab background */

  /* Semantic colours — each means ONE thing. Never decorative. */
  --gold:    #f4a820;   /* current state, "you are here", warning */
  --red:     #e84040;   /* negative delta, danger, error, destructive */
  --green:   #30c060;   /* positive delta, success, confirmed, live */
  --orange:  #f07820;   /* moderate warning, partial state */
  --purple:  #9060e0;   /* reserved accent for special states */

  /* Fonts — two jobs. mono = data/labels; main = human prose. */
  --font-mono: 'Share Tech Mono', monospace;
  --font-main: 'Rajdhani', sans-serif;

  /* ---- APP-SPECIFIC EXAMPLE — replace or delete per project ----
     GeoSim used per-entity brand colours. Kept here only as a pattern
     to copy; the core system does not depend on them. */
  --brand-1: #3060f0;
  --brand-2: #e83030;
  --brand-3: #508030;
}

/* ============================================================================
   2. BASE RESET
   ============================================================================ */

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

#root { margin: 0; padding: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.5;
}

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

input, textarea, select, button { font-family: var(--font-main); }

/* ============================================================================
   3. LAYOUT PRIMITIVES
   ============================================================================ */

/* Width-constrained, centred content column (a console/reading width). */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px;
  position: relative;
}

/* Uppercase section label with a trailing rule. */
.section-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1.25rem 0 0.6rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* App header row. */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.app-title {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
}

/* Two-column main layout (content + sidebar), collapses on narrow screens. */
.split {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 10px;
  margin-bottom: 10px;
}
@media (max-width: 700px) {
  .split { grid-template-columns: 1fr; }
}

/* ============================================================================
   4. STICKY CHROME (fixed top tab bar + context bar)
   Add `padding-top` to body equal to chrome height when you use this.
   ============================================================================ */

.app-chrome {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: var(--bg);
}

.tab-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 48px;
  padding: 0 0.75rem;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text2);
  font-family: var(--font-main);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.tab-btn:hover:not(.active) {
  background: var(--bg3);
  border-color: var(--border2);
  color: var(--text);
}
.tab-btn.active {
  background: var(--accent2);
  color: white;
}

/* ============================================================================
   5. CONTAINERS — panels, cards
   ============================================================================ */

.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
}

.card-lg {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}

/* Score / stat card with a coloured top edge (--card-color, default accent). */
.score-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s;
}
.score-card:hover { border-color: var(--border2); }
.score-card.active { border-color: var(--accent); }
.score-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--card-color, var(--accent));
}
.sc-flag { font-size: 18px; margin-bottom: 2px; }
.sc-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.sc-score {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--card-color, var(--accent));
}
.sc-delta { font-family: var(--font-mono); font-size: 10px; margin-top: 1px; }
.sc-bar {
  height: 3px;
  background: var(--bg3);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.sc-bar-fill { height: 100%; border-radius: 2px; transition: width 0.6s ease; }

.scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

/* ============================================================================
   6. CALLOUTS — coloured left-border boxes
   ============================================================================ */

.callout {
  border-left: 3px solid var(--accent);
  padding: 0.85rem 1rem;
  background: var(--bg2);
  margin-bottom: 0.85rem;
}
.callout.gold  { border-left-color: var(--gold); }
.callout.red   { border-left-color: var(--red); }
.callout.green { border-left-color: var(--green); }
.callout-title { font-size: 12px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.callout-text  { font-size: 13px; color: var(--text); line-height: 1.6; }

/* Highlighted banner (e.g. a verdict / situation line). */
.verdict-banner {
  margin-top: 8px;
  padding: 0 12px;
  min-height: 29px;
  display: flex;
  align-items: center;
  background: rgba(244, 168, 32, 0.08);
  border: 1px solid rgba(244, 168, 32, 0.2);
  border-radius: 3px;
  font-size: 12px;
  color: var(--gold);
  font-family: var(--font-mono);
  line-height: 1.5;
}

/* ============================================================================
   7. TABLE / LIST ROWS (label | body)
   ============================================================================ */

.t-row { display: flex; border-bottom: 1px solid var(--border); }
.t-row:last-child { border-bottom: none; }
.t-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  min-width: 110px;
  padding: 12px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  line-height: 1.4;
}
.t-body { font-size: 13px; color: var(--text); padding: 12px; line-height: 1.55; flex: 1; }

/* ============================================================================
   8. BUTTONS
   ============================================================================ */

.btn {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.15s;
}
.btn:hover { background: var(--border); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { font-size: 11px; padding: 0 10px; height: 29px; letter-spacing: 0.5px; }

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

.btn-danger { background: rgba(232, 64, 64, 0.15); border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(232, 64, 64, 0.3); }

/* ============================================================================
   9. TABS (in-content)
   ============================================================================ */

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 1.25rem; }
.tab {
  padding: 7px 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg2);
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  font-family: var(--font-main);
  transition: all 0.15s;
}
.tab.active { background: var(--accent2); color: white; font-weight: 600; border-color: var(--accent); }
.tab:hover:not(.active) { border-color: var(--border2); color: var(--text); }

/* ============================================================================
   10. FORM CONTROLS — inputs, textarea, select (all restyled dark)
   ============================================================================ */

.input {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--font-main);
  font-size: 13px;
  height: 29px;
  padding: 0 10px;
  width: 100%;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.input:hover:not(:focus) { border-color: var(--accent); }
.input:focus { border-color: var(--accent); }

/* Recolour native number spinners to fit the dark theme. */
.input[type="number"]::-webkit-inner-spin-button,
.input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
  filter: invert(35%) sepia(20%) saturate(400%) hue-rotate(175deg);
}

.textarea {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--font-main);
  font-size: 12px;
  padding: 6px 8px;
  outline: none;
  resize: vertical;
  line-height: 1.6;
  box-sizing: border-box;
  transition: border-color 0.15s;
  width: 100%;
}
.textarea:hover:not(:focus) { border-color: var(--accent); }
.textarea:focus { border-color: var(--accent); }

/* Native <select> with custom chevron, restyled to match. */
select {
  box-sizing: border-box;
  height: 29px;
  padding: 0 28px 0 8px;
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--text);
  background-color: var(--bg3);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%233a5068'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border: 1px solid var(--border2);
  border-radius: 3px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
select:hover, select:focus { border-color: var(--accent); }
select option { background: var(--bg3); color: var(--text); }

/* ============================================================================
   11. CHECKBOX / TOGGLE (custom, styleable)
   ============================================================================ */

.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.checkbox-box {
  width: 16px; height: 16px; flex-shrink: 0;
  border: 1px solid var(--border2);
  border-radius: 2px;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.checkbox:hover .checkbox-box { border-color: var(--accent); }
.checkbox.checked .checkbox-box { border-color: var(--accent); background: var(--accent2); }
.checkbox-tick { display: none; width: 9px; height: 7px; }
.checkbox.checked .checkbox-tick { display: block; }
.checkbox-label { font-family: var(--font-mono); font-size: 11px; color: var(--text2); letter-spacing: 0.5px; }

.toggle {
  width: 36px; height: 20px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}
.toggle.on { background: var(--accent2); border-color: var(--accent); }
.toggle::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  background: var(--text2);
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: left 0.2s, background 0.2s;
}
.toggle.on::after { left: 18px; background: white; }

/* ============================================================================
   12. TAGS / BADGES — tinted semantic chips
   ============================================================================ */

/* Impact / meaning tag: tinted fill + border, coloured text. */
.tag {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 2px;
  display: inline-block;
}
.tag-accent { color: var(--accent); border: 1px solid rgba(0,180,216,0.27); background: rgba(0,180,216,0.09); }
.tag-gold   { color: var(--gold);   border: 1px solid rgba(244,168,32,0.27); background: rgba(244,168,32,0.09); }
.tag-red    { color: var(--red);    border: 1px solid rgba(232,64,64,0.27);  background: rgba(232,64,64,0.09); }
.tag-green  { color: var(--green);  border: 1px solid rgba(48,192,96,0.27);  background: rgba(48,192,96,0.09); }
.tag-orange { color: var(--orange); border: 1px solid rgba(240,120,32,0.27); background: rgba(240,120,32,0.09); }

/* Outline status badge that fills when active. */
.status-badge {
  display: inline-block;
  height: 29px;
  line-height: 27px;
  padding: 0 10px;
  border-radius: 3px;
  border: 1px solid var(--border2);
  color: var(--text3);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
  box-sizing: border-box;
  transition: background 0.15s;
}
.status-badge.active { border-color: var(--green); color: var(--green); background: rgba(48, 192, 96, 0.08); }
button.status-badge:hover { background: var(--border); }
button.status-badge.active:hover { background: rgba(48, 192, 96, 0.2); }

/* Delta text colours. */
.delta-pos { color: var(--green); }
.delta-neg { color: var(--red); }
.delta-neu { color: var(--text3); }

/* ============================================================================
   13. PROGRESS & QUALITY DOTS
   ============================================================================ */

/* Step / progress dots. */
.dots { display: flex; gap: 4px; }
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  transition: background 0.3s;
}
.dot.done    { background: var(--accent2); border-color: var(--accent); }
.dot.current { background: var(--gold); border-color: var(--gold); }

/* 1–5 quality dots that shift colour by score. Set class acc-1 … acc-5 on parent. */
.rating-dots { display: flex; gap: 3px; }
.rating-dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--border2); }
.rating-dot.filled { background: var(--accent); border-color: var(--accent); }
.acc-5 .rating-dot.filled { background: var(--green); border-color: var(--green); }
.acc-4 .rating-dot.filled { background: #60c090; }
.acc-3 .rating-dot.filled { background: var(--gold); border-color: var(--gold); }
.acc-2 .rating-dot.filled { background: var(--orange); }
.acc-1 .rating-dot.filled { background: var(--red); border-color: var(--red); }

/* ============================================================================
   14. STATES — empty, error
   ============================================================================ */

.empty-state {
  background: var(--bg);
  border: 1px dashed var(--border2);
  border-radius: 3px;
  padding: 20px 24px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.error-callout {
  padding: 0 12px;
  background: rgba(232, 64, 64, 0.08);
  border: 1px solid rgba(232, 64, 64, 0.3);
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--red);
  min-height: 29px;
  display: flex;
  align-items: center;
}

/* ============================================================================
   15. OVERLAYS — dropdown, modal (the only place shadows are used)
   ============================================================================ */

.dropdown {
  position: absolute;
  top: 100%; left: 0;
  margin-top: 4px;
  background: var(--bg3);
  border: 1px solid var(--accent);
  border-radius: 3px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  z-index: 1000;
  padding: 8px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 24px 28px;
  font-family: var(--font-mono);
}
.modal-title { font-size: 12px; font-weight: 600; color: var(--accent); letter-spacing: 1px; margin-bottom: 12px; }
.modal-body  { font-size: 12px; color: var(--text2); line-height: 1.7; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 32px; }

/* ============================================================================
   16. ANIMATIONS
   ============================================================================ */

/* Content appearing. */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fade-in 0.2s ease-out; }

/* Value-change flash. */
@keyframes delta-flash-pos { 0% { background: rgba(48, 192, 96, 0.2); } 100% { background: transparent; } }
@keyframes delta-flash-neg { 0% { background: rgba(232, 64, 64, 0.2); } 100% { background: transparent; } }
.flash-pos { animation: delta-flash-pos 0.8s ease-out; }
.flash-neg { animation: delta-flash-neg 0.8s ease-out; }

/* Live/running indicator. */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.pulse { animation: pulse 1.5s ease-in-out infinite; }

/* Optional "live instrument" scan-line sweeping down the viewport. */
.scan-line {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(0, 180, 216, 0.3), transparent);
  animation: scan 4s linear infinite;
  pointer-events: none;
  z-index: 9999;
}
@keyframes scan { 0% { top: 0; } 100% { top: 100vh; } }
