/* ModelRunner — minimal clean UI */

:root {
  --fg: #0f172a;
  --muted: #64748b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --danger: #dc2626;
  color-scheme: light;
}

/* Dark theme — applied via <html data-theme="dark"> by the inline head
   snippet (before first paint) and toggled by app.js. Defaults follow the
   OS preference; a manual choice persists in localStorage ("sr-theme"). */
:root[data-theme="dark"] {
  --fg: #e2e8f0;
  --muted: #94a3b8;
  --bg: #0f172a;
  --card: #1e293b;
  --border: #334155;
  --accent: #60a5fa;
  --accent-fg: #0f172a;
  --danger: #f87171;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

main {
  max-width: 920px;
  margin: 24px auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

main.center { justify-content: center; min-height: 100vh; margin: 0 auto; }

/* header */

.site-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--fg); }
.site-header nav { display: flex; gap: 16px; }
.site-header nav a { text-decoration: none; color: var(--muted); font-weight: 500; }
.site-header nav a.active, .site-header nav a:hover { color: var(--accent); }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* cards & type */

.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px 24px; }
.card.narrow { max-width: 380px; margin: 0 auto; width: 100%; }

h1 { font-size: 1.4rem; margin: 0 0 12px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
h3 { font-size: 0.95rem; margin: 18px 0 8px; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); font-size: 0.9rem; min-height: 1.2em; margin: 8px 0; }
.error-box {
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  padding: 8px 12px; border-radius: 8px; font-size: 0.9rem;
}

a { color: var(--accent); }

/* forms & buttons */

label { display: block; margin: 12px 0; font-size: 0.9rem; font-weight: 500; }

input:not([type="file"]):not([type="checkbox"]) {
  display: block; width: 100%; margin-top: 4px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit;
  background: var(--card); color: var(--fg);
}

input[type="checkbox"] { accent-color: var(--accent); }

select {
  display: block; width: 100%; margin-top: 4px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit;
  background: var(--card); color: var(--fg);
}
select:disabled { opacity: 0.55; cursor: not-allowed; }

.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field { flex: 1 1 180px; max-width: 260px; }
/* Inactive mode field (Solver Option while Tough2 is selected). */
.field.dim { color: var(--muted); }

button {
  font: inherit; font-weight: 600;
  padding: 8px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-run { background: #16a34a; color: #fff; font-size: 1rem; padding: 10px 28px; }
.btn-danger { background: var(--card); color: var(--danger); border-color: var(--danger); }
.btn-quiet { background: transparent; color: var(--muted); border-color: var(--border); }

.link {
  background: none; border: none; color: var(--accent); cursor: pointer;
  padding: 0; font-weight: 500; font-size: 0.9rem; text-decoration: underline;
}

.del-btn { color: var(--danger); }

/* users page: destructive account action */
.user-del { color: var(--danger); }

.btn-icon {
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 9px; font-size: 0.95rem; line-height: 1.2; cursor: pointer;
}
.btn-icon:hover { border-color: var(--accent); }

.theme-float { position: fixed; top: 14px; right: 16px; z-index: 10; }

/* upload */

.drop-zone {
  border: 2px dashed var(--border); border-radius: 10px;
  padding: 18px; margin-bottom: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone.over { border-color: var(--accent); background: #eff6ff; }

.zone-label {
  display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 6px;
}

.progress { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; margin: 12px 0; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

#run-wrap { margin-top: 12px; }

/* status pills */

.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; white-space: nowrap;
}
.s-idle { background: #e2e8f0; color: #334155; }
.s-wait { background: #dbeafe; color: #1e40af; }
.s-run  { background: #fef3c7; color: #92400e; animation: pulse 2s infinite; }
.s-ok   { background: #dcfce7; color: #166534; }
.s-bad  { background: #fee2e2; color: #991b1b; }
.s-warn { background: #ffedd5; color: #9a3412; }
.s-off  { background: #e5e7eb; color: #4b5563; }

@keyframes pulse { 50% { opacity: 0.55; } }

/* job detail */

.job-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.job-head h1 { word-break: break-all; }

table.meta { border-collapse: collapse; margin: 8px 0; font-size: 0.92rem; }
table.meta th {
  text-align: left; color: var(--muted); font-weight: 500;
  padding: 4px 16px 4px 0; white-space: nowrap;
}
table.meta td { padding: 4px 0; }

.actions { display: flex; gap: 10px; align-items: center; margin: 14px 0; }

pre.log {
  background: #0f172a; color: #e2e8f0;
  padding: 12px 14px; border-radius: 8px;
  font-size: 0.8rem; line-height: 1.45;
  max-height: 320px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}

ul.downloads { list-style: none; padding: 0; margin: 0; }
ul.downloads li {
  padding: 6px 0; border-bottom: 1px solid var(--border);
  display: flex; gap: 10px; align-items: baseline;
}
ul.downloads li:last-child { border-bottom: none; }

/* history table */

.jobs-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.jobs-head h1 { margin: 0; }
.spacer { flex: 1; }
.checkbox { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-weight: 500; }

table.list { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.list th {
  text-align: left; color: var(--muted); font-weight: 500;
  border-bottom: 1px solid var(--border); padding: 6px 10px 6px 0;
}
table.list td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--border); }
table.list tr:last-child td { border-bottom: none; }

/* ---------- dark-theme component overrides ----------
   Components with fixed light-mode colors get dark counterparts here. */

:root[data-theme="dark"] .s-idle { background: #334155; color: #cbd5e1; }
:root[data-theme="dark"] .s-wait { background: #1e3a8a; color: #bfdbfe; }
:root[data-theme="dark"] .s-run  { background: #78350f; color: #fde68a; }
:root[data-theme="dark"] .s-ok   { background: #14532d; color: #bbf7d0; }
:root[data-theme="dark"] .s-bad  { background: #7f1d1d; color: #fecaca; }
:root[data-theme="dark"] .s-warn { background: #7c2d12; color: #fed7aa; }
:root[data-theme="dark"] .s-off  { background: #374151; color: #d1d5db; }

:root[data-theme="dark"] .error-box {
  background: #450a0a; border-color: #7f1d1d; color: #fecaca;
}

:root[data-theme="dark"] .drop-zone.over { background: rgba(96, 165, 250, 0.08); }
