/* frontend/index.css */
:root {
  --bg: #fff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --panel: #f9fafb;
  --accent: #2563eb;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --border: #2a2e37;
    --panel: #171a21;
    --accent: #60a5fa;
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
  }
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--fg);
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif;
}

.login-screen {
  display: flex;
  text-align: center;
  flex-direction: column;
  justify-content: center;
  align-items:  center;
  gap: 12px;
  height: 100vh;
}

.button, button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.link-button {
  color: var(--muted);
  text-decoration: underline;
  background: none;
  padding: 0;
}

.app-header {
  display: flex;
  border-bottom: 1px solid var(--border);
  align-items:  center;
  gap: 24px;
  padding: 12px 24px;
}

.app-header h1 {
  margin: 0;
  font-size: 18px;
}

.app-header nav {
  display: flex;
  flex: 1;
  gap: 8px;
}

.tab {
  color: var(--muted);
  background: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 14px;
}

.tab.active {
  background: var(--panel);
  color: var(--fg);
  font-weight: 600;
}

.user-info {
  display: flex;
  color: var(--muted);
  align-items:  center;
  gap: 12px;
  font-size: 13px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.submit-panel, .job-list, .job-detail-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 16px;
}

.submit-panel form {
  display: flex;
  gap: 8px;
}

.submit-panel input, .tokens-view input {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 6px;
  flex: 1;
  padding: 8px 10px;
  font-size: 14px;
}

.jobs-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
}

.job-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.job-list li {
  display: flex;
  cursor: pointer;
  border-radius: 6px;
  align-items:  center;
  gap: 8px;
  padding: 8px;
  font-size: 13px;
}

.job-list li:hover, .job-list li.selected {
  background: var(--border);
}

.job-id {
  color: var(--muted);
}

.job-score {
  color: var(--muted);
  margin-left: auto;
}

.badge {
  display: inline-block;
  background: var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}

.status-good {
  background: color-mix(in srgb, var(--good) 20%, transparent);
  color: var(--good);
}

.status-warn {
  background: color-mix(in srgb, var(--warn) 20%, transparent);
  color: var(--warn);
}

.status-bad {
  background: color-mix(in srgb, var(--bad) 20%, transparent);
  color: var(--bad);
}

.status-pending {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
}

dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 12px;
  font-size: 14px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

th, td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.error {
  color: var(--bad);
  font-size: 13px;
}

.token-reveal {
  border: 1px dashed var(--accent);
  display: flex;
  border-radius: 6px;
  flex-wrap: wrap;
  align-items:  center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
}

.token-reveal code {
  background: var(--bg);
  word-break: break-all;
  border-radius: 4px;
  padding: 4px 8px;
}

.pipeline-stepper {
  display: flex;
  flex-direction: column;
  margin: 12px 0 20px;
}

.step {
  display: flex;
  align-items:  flex-start;
  gap: 12px;
  min-height: 34px;
}

.step-marker {
  display: flex;
  flex-direction: column;
  align-items:  center;
  width: 20px;
}

.step-icon {
  display: flex;
  border-radius: 50%;
  flex-shrink: 0;
  justify-content: center;
  align-items:  center;
  width: 18px;
  height: 18px;
  font-size: 11px;
  font-weight: 700;
}

.step-icon-done {
  background: var(--good);
  color: #06210f;
}

.step-icon-pending {
  background: var(--border);
}

.step-icon-error {
  background: var(--bad);
  color: #2a0a0a;
}

.step-icon-current {
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
  animation: pulse 1.6s ease-out infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent);
  }

  70% {
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 0%, transparent);
  }

  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent);
  }
}

.step-line {
  background: var(--border);
  flex: 1;
  width: 2px;
  min-height: 12px;
  margin: 2px 0;
}

.step-done .step-line {
  background: var(--good);
}

.step-label {
  color: var(--muted);
  padding-top: 1px;
  font-size: 13px;
}

.step-done .step-label {
  color: var(--fg);
}

.step-current .step-label {
  color: var(--accent);
  font-weight: 600;
}

.step-error .step-label {
  color: var(--bad);
  font-weight: 600;
}

.terminal-banner {
  border-radius: 6px;
  width: -moz-fit-content;
  width: fit-content;
  margin-top: 8px;
  margin-left: 32px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}

.terminal-warn {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: var(--warn);
}

.terminal-bad {
  background: color-mix(in srgb, var(--bad) 18%, transparent);
  color: var(--bad);
}

.risk-breakdown {
  margin-top: 8px;
}

.risk-bars {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.risk-bars li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items:  center;
  gap: 2px 12px;
}

.risk-bar-label {
  display: flex;
  grid-column: 1 / -1;
  justify-content: space-between;
  font-size: 12px;
}

.risk-bar-type {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
}

.risk-bar-type.heaviest {
  color: var(--bad);
}

.risk-bar-track {
  background: var(--border);
  overflow: hidden;
  border-radius: 4px;
  height: 8px;
}

.risk-bar-fill {
  background: var(--accent);
  border-radius: 4px;
  height: 100%;
}

.risk-bar-fill.heaviest {
  background: var(--bad);
}

.risk-bar-value {
  color: var(--muted);
  text-align: right;
  min-width: 32px;
  font-size: 12px;
  font-weight: 600;
}
