/* ══════════════════════════════════════════════════════════
   VerbSphere Control Panel — Styles
   ══════════════════════════════════════════════════════════ */

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #252836;
  --border: #2d3140;
  --text: #e1e4ed;
  --text-muted: #8b8fa3;
  --accent: #6c5ce7;
  --accent-hover: #7d6ff0;
  --green: #00d68f;
  --red: #ff6b6b;
  --yellow: #ffd93d;
  --orange: #ff922b;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Header ─────────────────────────────── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 20px; font-weight: 700; }
.badge {
  font-size: 11px;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.header-right { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.idle { background: var(--text-muted); }
.status-dot.running { background: var(--accent); animation: pulse 1s infinite; }
.status-dot.ok { background: var(--green); }
.status-dot.err { background: var(--red); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Layout ──────────────────────────────── */
.layout {
  display: flex;
  min-height: calc(100vh - 57px);
}
.sidebar {
  width: 320px;
  min-width: 320px;
  padding: 20px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sidebar h2 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.main {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Cards ───────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-header h2 { margin-bottom: 0; }
.card-header-actions { display: flex; gap: 6px; }
.card-error { border-color: var(--red); background: rgba(255,107,107,0.05); }
.card-error h3 { color: var(--red); margin-bottom: 8px; }

/* ── Fields ──────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.field input:focus,
.field select:focus {
  border-color: var(--accent);
}
.field select { cursor: pointer; }
.field input[type="range"] {
  -webkit-appearance: none;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}
.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
}
.input-with-btn {
  display: flex;
  gap: 4px;
}
.input-with-btn input { flex: 1; }
.input-with-btn button {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 14px;
}
.hint { font-size: 11px; color: var(--text-muted); }
.flex-grow { flex: 1; }

/* ── Buttons ─────────────────────────────── */
.btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 16px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { background: #303548; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}
.btn-outline:hover { background: rgba(108,92,231,0.1); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Generation row ──────────────────────── */
.gen-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

/* ── Root info ───────────────────────────── */
.root-info {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg-input);
  border-radius: 6px;
  display: flex;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}
.root-info span {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.root-lang { background: rgba(108,92,231,0.2); color: #a78bfa; }
.root-form { background: rgba(0,214,143,0.15); color: var(--green); font-family: monospace; }
.root-gloss { background: rgba(255,146,43,0.15); color: var(--orange); }
.root-pie { background: rgba(255,217,61,0.15); color: var(--yellow); }

/* ── Progress bar ────────────────────────── */
.progress-bar {
  width: 100%;
  height: 3px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

/* ── Result summary ──────────────────────── */
.result-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.result-stat {
  background: var(--bg-input);
  border-radius: 6px;
  padding: 10px 14px;
}
.result-stat .stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.result-stat .stat-value {
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
}
.stat-ok { color: var(--green); }
.stat-err { color: var(--red); }
.stat-warn { color: var(--yellow); }

/* ── Raw JSON ────────────────────────────── */
.result-raw {
  margin-top: 12px;
  background: #0d0f15;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  max-height: 500px;
  overflow: auto;
}
.result-raw pre {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}
.dry-run-output {
  margin-top: 12px;
  background: #0d0f15;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  max-height: 500px;
  overflow: auto;
}
.dry-run-output pre {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text-muted);
}

/* ── Schema errors ───────────────────────── */
.schema-err-list {
  margin-top: 8px;
  font-size: 12px;
  font-family: "JetBrains Mono", monospace;
}
.schema-err-list .err-item { color: var(--red); margin-bottom: 2px; }
.schema-err-list .warn-item { color: var(--yellow); margin-bottom: 2px; }

/* ── History table ───────────────────────── */
#historyTable { font-size: 13px; }
.history-row {
  display: grid;
  grid-template-columns: 90px 140px 50px 100px 70px 70px 1fr;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  font-size: 12px;
}
.history-row.header-row {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
}
.history-row:hover { background: rgba(108,92,231,0.05); }
.history-status { font-weight: 600; }
.history-status.ok { color: var(--green); }
.history-status.err { color: var(--red); }
.muted { color: var(--text-muted); font-size: 13px; }

/* ── Responsive ──────────────────────────── */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; min-width: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .result-summary { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* ── Login overlay ───────────────────────── */
.login-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.login-box {
  text-align: center;
  max-width: 480px;
  padding: 40px;
}
.login-box h2 {
  font-size: 24px;
  margin-bottom: 8px;
}
.login-box p {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 14px;
}
