/* ============================================================
   STT Correction Tool - Design System (Grafana/Datadog Style)
   Data-driven dark theme with high information density
   ============================================================ */

/* ── 1. Design Tokens (CSS Custom Properties) ── */
:root {
  /* ─── Color Palette ─── */
  --bg-root:        #0b0d13;
  --bg-surface-0:   #0f1117;
  --bg-surface-1:   #151822;
  --bg-surface-2:   #1a1e2b;
  --bg-surface-3:   #222738;
  --bg-hover:       #252a3a;
  --bg-active:      #2c3248;

  --border-subtle:  #1e2233;
  --border-default: #2a2f42;
  --border-strong:  #3a4058;

  --text-primary:   #e8eaf0;
  --text-secondary: #8b90a5;
  --text-muted:     #5a5f78;
  --text-disabled:  #3e4258;

  --accent-primary:   #7c8aff;
  --accent-hover:     #6b79ee;
  --accent-muted:     rgba(124, 138, 255, 0.15);
  --accent-glow:      rgba(124, 138, 255, 0.3);

  --color-success:       #4ade80;
  --color-success-bg:    rgba(74, 222, 128, 0.1);
  --color-success-border:rgba(74, 222, 128, 0.25);

  --color-error:         #f87171;
  --color-error-bg:      rgba(248, 113, 113, 0.1);
  --color-error-border:  rgba(248, 113, 113, 0.25);

  --color-warning:       #fbbf24;
  --color-warning-bg:    rgba(251, 191, 36, 0.1);
  --color-warning-border:rgba(251, 191, 36, 0.25);

  --color-info:          #60a5fa;
  --color-info-bg:       rgba(96, 165, 250, 0.1);
  --color-info-border:   rgba(96, 165, 250, 0.25);

  --chart-1: #7c8aff;
  --chart-2: #4ade80;
  --chart-3: #f97316;
  --chart-4: #f472b6;
  --chart-5: #60a5fa;
  --chart-6: #fbbf24;
  --chart-7: #a78bfa;
  --chart-8: #2dd4bf;

  --font-sans:    'Inter', -apple-system, 'Microsoft YaHei', 'PingFang SC', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-display: 'Inter', -apple-system, 'Microsoft YaHei', sans-serif;

  --text-xs:   11px;
  --text-sm:   12px;
  --text-base: 14px;
  --text-lg:   16px;
  --text-xl:   20px;
  --text-2xl:  28px;
  --text-3xl:  36px;
  --text-4xl:  48px;

  --leading-tight:  1.25;
  --leading-normal: 1.5;
  --leading-relaxed:1.75;

  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-full: 9999px;

  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow:0 0 20px var(--accent-glow);

  --transition-fast:   150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow:   400ms ease;

  --sidebar-width: 240px;
  --panel-gap:     16px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: var(--text-base); -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--bg-root);
  color: var(--text-primary);
  line-height: var(--leading-normal);
  overflow-x: hidden;
}
a { color: var(--accent-primary); text-decoration: none; }
a:hover { color: var(--accent-hover); }
::selection { background: var(--accent-muted); color: var(--text-primary); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface-0); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }

/* Sidebar */
.sidebar {
  position: fixed; left: 0; top: 0;
  width: var(--sidebar-width); height: 100vh;
  background: var(--bg-surface-1);
  border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column;
  z-index: 100; overflow-y: auto;
}
.sidebar-brand {
  padding: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: var(--space-3);
}
.sidebar-brand .brand-icon {
  width: 32px; height: 32px;
  background: var(--accent-primary); border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-lg); font-weight: var(--weight-bold); color: #fff;
}
.sidebar-brand .brand-text { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-primary); }
.sidebar-brand .brand-sub { font-size: var(--text-xs); color: var(--text-muted); }
.sidebar-section {
  padding: var(--space-4) var(--space-5) var(--space-1);
  font-size: var(--text-xs); color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1.5px; font-weight: var(--weight-semibold);
}
.sidebar-nav a {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  color: var(--text-secondary); font-size: var(--text-sm);
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
}
.sidebar-nav a:hover { color: var(--text-primary); background: var(--bg-hover); }
.sidebar-nav a.active {
  color: var(--accent-primary); background: var(--accent-muted);
  border-left-color: var(--accent-primary); font-weight: var(--weight-medium);
}
.sidebar-nav a .nav-icon { width: 18px; text-align: center; opacity: 0.7; }
.sidebar-nav a.active .nav-icon { opacity: 1; }
.sidebar-status { margin-top: auto; padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border-subtle); }

.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: var(--radius-full); margin-right: var(--space-2);
}
.status-dot.online { background: var(--color-success); box-shadow: 0 0 6px var(--color-success); }

/* Main */
.main-content { margin-left: var(--sidebar-width); padding: var(--space-6) var(--space-8); min-height: 100vh; }
.page-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-6);
}
.page-header h1 { font-size: var(--text-xl); font-weight: var(--weight-semibold); }
.page-header .header-actions { display: flex; gap: var(--space-3); }

/* Card */
.card {
  background: var(--bg-surface-1); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: border-color var(--transition-fast);
}
.card:hover { border-color: var(--border-default); }
.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 {
  font-size: var(--text-sm); font-weight: var(--weight-semibold);
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px;
}
.card-body { padding: var(--space-5); }
.card-body.no-pad { padding: 0; }
.card-footer {
  padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs); color: var(--text-muted);
}

/* Stats */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--panel-gap); margin-bottom: var(--space-6);
}
.stat-card {
  background: var(--bg-surface-1); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: var(--space-5);
  position: relative; overflow: hidden;
  transition: all var(--transition-fast);
}
.stat-card:hover { border-color: var(--border-default); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.stat-card .stat-label {
  font-size: var(--text-xs); color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: var(--space-2);
}
.stat-card .stat-value {
  font-size: var(--text-3xl); font-weight: var(--weight-bold);
  color: var(--text-primary); line-height: 1; margin-bottom: var(--space-1);
}
.stat-card .stat-trend { font-size: var(--text-xs); display: flex; align-items: center; gap: var(--space-1); }
.stat-card .stat-trend.up   { color: var(--color-success); }
.stat-card .stat-trend.down { color: var(--color-error); }
.stat-card .stat-trend.flat { color: var(--text-muted); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: var(--accent-primary); opacity: 0;
  transition: opacity var(--transition-fast);
}
.stat-card:hover::before { opacity: 1; }
.stat-card.accent-green  .stat-value { color: var(--color-success); }
.stat-card.accent-green::before      { background: var(--color-success); }
.stat-card.accent-blue   .stat-value { color: var(--color-info); }
.stat-card.accent-blue::before       { background: var(--color-info); }
.stat-card.accent-orange .stat-value { color: var(--chart-3); }
.stat-card.accent-orange::before     { background: var(--chart-3); }
.stat-card.accent-purple .stat-value { color: var(--chart-7); }
.stat-card.accent-purple::before     { background: var(--chart-7); }
.stat-card.accent-pink   .stat-value { color: var(--chart-4); }
.stat-card.accent-pink::before       { background: var(--chart-4); }

/* Grid */
.grid { display: grid; gap: var(--panel-gap); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1200px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4, .grid-2-1 { grid-template-columns: 1fr; }
  .main-content { margin-left: 0; padding: var(--space-4); }
  .sidebar { display: none; }
}

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table thead th {
  padding: var(--space-3) var(--space-4); text-align: left;
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
  background: var(--bg-surface-2); border-bottom: 1px solid var(--border-default);
  position: sticky; top: 0;
}
.data-table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle); vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px 8px; border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: var(--weight-medium); white-space: nowrap;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid var(--color-success-border); }
.badge-error   { background: var(--color-error-bg);   color: var(--color-error);   border: 1px solid var(--color-error-border); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning-border); }
.badge-info    { background: var(--color-info-bg);     color: var(--color-info);    border: 1px solid var(--color-info-border); }
.badge-neutral { background: var(--bg-surface-3); color: var(--text-secondary); border: 1px solid var(--border-default); }

/* Diff */
.diff-segment { padding: var(--space-3) var(--space-4); margin: var(--space-2) 0; border-radius: var(--radius-md); font-size: var(--text-sm); line-height: var(--leading-relaxed); }
.diff-segment-original { background: var(--color-error-bg); border-left: 3px solid var(--color-error); }
.diff-segment-corrected { background: var(--color-success-bg); border-left: 3px solid var(--color-success); }
.diff-segment-meta { font-size: var(--text-xs); color: var(--text-muted); font-family: var(--font-mono); margin-bottom: var(--space-1); }
.word-del { background: rgba(248,113,113,0.2); color: var(--color-error); text-decoration: line-through; padding: 1px 2px; border-radius: 2px; }
.word-add { background: rgba(74,222,128,0.15); color: var(--color-success); padding: 1px 2px; border-radius: 2px; font-weight: var(--weight-medium); }
.diff-side-by-side { display: grid; grid-template-columns: 1fr 1fr; }
.diff-pane-header {
  padding: var(--space-2) var(--space-4); font-size: var(--text-xs); font-weight: var(--weight-semibold);
  text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid var(--border-subtle);
}
.diff-pane.original .diff-pane-header { background: var(--color-error-bg); color: var(--color-error); border-right: 1px solid var(--border-subtle); }
.diff-pane.corrected .diff-pane-header { background: var(--color-success-bg); color: var(--color-success); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  cursor: pointer; border: 1px solid transparent;
  transition: all var(--transition-fast); font-family: var(--font-sans);
}
.btn-primary { background: var(--accent-primary); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-glow); }
.btn-secondary { background: var(--bg-surface-3); color: var(--text-primary); border-color: var(--border-default); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { padding: 2px 10px; font-size: var(--text-xs); }

/* Input */
.input {
  width: 100%; padding: var(--space-3) var(--space-4);
  background: var(--bg-surface-2); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-size: var(--text-sm); font-family: var(--font-sans); outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-muted); }
.input::placeholder { color: var(--text-disabled); }

/* Sparkline */
.sparkline { display: flex; align-items: flex-end; gap: 2px; height: 32px; margin-top: var(--space-3); }
.sparkline-bar {
  flex: 1; border-radius: 2px 2px 0 0; min-width: 3px;
  background: var(--accent-primary); opacity: 0.4;
  transition: opacity var(--transition-fast);
}
.sparkline-bar:last-child { opacity: 1; }

/* Bar chart */
.bar-chart { display: flex; align-items: flex-end; gap: var(--space-2); height: 200px; padding-top: var(--space-4); }
.bar-chart-bar {
  flex: 1; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  position: relative; cursor: pointer; transition: all var(--transition-fast); min-width: 20px;
}
.bar-chart-bar:hover { filter: brightness(1.2); }
.bar-chart-bar .bar-label { position: absolute; bottom: -24px; left: 50%; transform: translateX(-50%); font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; }
.bar-chart-bar .bar-value { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: var(--text-xs); color: var(--text-secondary); opacity: 0; transition: opacity var(--transition-fast); }
.bar-chart-bar:hover .bar-value { opacity: 1; }

/* Chart legend */
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); margin-top: var(--space-4); }
.chart-legend-item { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--text-secondary); }
.chart-legend-dot { width: 10px; height: 10px; border-radius: var(--radius-full); }

/* Stacked bar */
.h-stacked-bar { display: flex; height: 28px; border-radius: var(--radius-sm); overflow: hidden; margin: var(--space-3) 0; }
.h-stacked-bar > div { height: 100%; transition: width 0.8s ease; }
.h-stacked-bar > div:hover { filter: brightness(1.2); }

/* Progress */
.progress-bar { width: 100%; height: 6px; background: var(--bg-surface-3); border-radius: var(--radius-full); overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: var(--radius-full); background: var(--accent-primary); transition: width var(--transition-slow); }

/* Utilities */
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
