/**
 * Taiwan Market Quantitative Terminal - Core Design System
 * (terminal-theme.css)
 *
 * Implements Anti-Slop principles from taste-skill (app-screens.md):
 * - Ground & Surfaces: #080c14 ground, #0f172a cards, 1px hairlines.
 * - Restrained Color Budget: 3-5% colored pixels max, reserved for financial data.
 * - Typography: JetBrains Mono / Noto Sans TC, tabular-nums right-aligned.
 * - Flat surfaces: no glowing neon borders or blurry colored drop-shadows.
 * - Navigation recedes: subtle muted pills and borders.
 */

:root {
  /* Surfaces & Canvas */
  --term-bg-ground:   #080c14;
  --term-bg-surface:  #0f172a;
  --term-bg-elevated: #151e32;
  --term-bg-hover:    #1e293b;
  --term-bg-subtle:   #111a2e;

  /* Borders & Hairlines */
  --term-border-base: #1e293b;
  --term-border-hair: rgba(255, 255, 255, 0.07);
  --term-border-mid:  rgba(255, 255, 255, 0.12);

  /* Typography Colors */
  --term-text-primary:   #f8fafc; /* Slate 50 */
  --term-text-secondary: #94a3b8; /* Slate 400 */
  --term-text-muted:     #64748b; /* Slate 500 */
  --term-text-dim:       #475569; /* Slate 600 */

  /* Taiwan Financial Semantics (3-5% Color Budget) */
  --term-tw-up:       #ef4444; /* Bullish / Price Rise / Foreign Buy */
  --term-tw-up-tint:  rgba(239, 68, 68, 0.10);
  --term-tw-down:     #10b981; /* Bearish / Price Drop / Foreign Sell */
  --term-tw-down-tint:rgba(16, 185, 129, 0.10);
  --term-tw-warn:     #f59e0b; /* Attention / High Risk / PB < 1.0 */
  --term-tw-warn-tint:rgba(245, 158, 11, 0.10);
  --term-tw-info:     #38bdf8; /* Institutional / Secondary Data */
  --term-tw-info-tint:rgba(56, 189, 248, 0.10);
}

/* Global Font & Tabular Num Reset */
.term-mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
  font-variant-numeric: tabular-nums !important;
}

.term-tabular {
  font-variant-numeric: tabular-nums !important;
  font-feature-settings: "tnum" 1 !important;
}

/* Financial Semantic Classes */
.term-up {
  color: var(--term-tw-up) !important;
}

.term-down {
  color: var(--term-tw-down) !important;
}

.term-warn {
  color: var(--term-tw-warn) !important;
}

.term-info {
  color: var(--term-tw-info) !important;
}

.term-text-muted {
  color: var(--term-text-muted) !important;
}

.term-text-secondary {
  color: var(--term-text-secondary) !important;
}

/* Badges: restrained, non-distracting tints */
.term-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  line-height: 1.3;
  letter-spacing: 0.02em;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.term-badge-up {
  background: var(--term-tw-up-tint);
  color: var(--term-tw-up);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.term-badge-down {
  background: var(--term-tw-down-tint);
  color: var(--term-tw-down);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.term-badge-warn {
  background: var(--term-tw-warn-tint);
  color: var(--term-tw-warn);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.term-badge-info {
  background: var(--term-tw-info-tint);
  color: var(--term-tw-info);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.term-badge-neutral {
  background: rgba(148, 163, 184, 0.10);
  color: var(--term-text-secondary);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

/* Card Surface - Flat Layering with 1px Hairlines */
.term-card {
  background: var(--term-bg-surface);
  border: 1px solid var(--term-border-base);
  border-radius: 8px;
  box-shadow: none !important;
  overflow: hidden;
}

.term-card-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--term-border-hair);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
}

.term-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--term-text-primary);
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.term-card-body {
  padding: 14px 16px;
}

/* KPI Unit: Type over tiles, no decorative tinted icon boxes */
.term-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.term-kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--term-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.term-kpi-val {
  font-size: 24px;
  font-weight: 700;
  color: var(--term-text-primary);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.term-kpi-sub {
  font-size: 11px;
  color: var(--term-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

/* Clean Financial Data Table - Rules & Alignment, No Zebra Stripes */
.term-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
}

.term-table th {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--term-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--term-border-base);
  background: transparent;
  white-space: nowrap;
}

.term-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--term-border-hair);
  color: var(--term-text-primary);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.term-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.term-table tr:last-child td {
  border-bottom: none;
}

/* Table Column Alignments */
.term-table .num,
.term-num {
  text-align: right !important;
}

.term-table .text,
.term-text {
  text-align: left !important;
  font-family: inherit !important;
}

.term-table .center,
.term-center {
  text-align: center !important;
}

/* Subtle Interactive Buttons */
.term-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  user-select: none;
  text-decoration: none;
}

.term-btn:hover {
  background: #334155;
  color: #ffffff;
  border-color: #475569;
}

.term-btn-active {
  background: #1e293b !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
  box-shadow: none !important;
}
