/* Karbon Bot control panel.
   Split out of index.html so the markup, styling and behaviour are separate. */

:root {
  --ink: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --hair: #f1f5f9;
  --good: #059669;
  --good-bg: #ecfdf5;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
  --btn: #111827;
  --btn-quiet: #475569;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  margin: 0 auto;
  padding: 20px;
  max-width: 1200px;
  color: var(--ink);
  background: #fff;
}

h1 { font-size: 20px; margin: 0; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  background: var(--btn);
  color: #fff;
  border: none;
  padding: 9px 15px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.quiet { background: var(--btn-quiet); }
button.danger { background: var(--bad); }
.btn-sm { padding: 3px 11px; font-size: 12px; border-radius: 6px; }

select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 13px;
  max-width: 100%;
}

.profile-status { font-size: 12px; padding: 4px 8px; border-radius: 4px; }
.profile-exists { background: #dcfce7; color: #166534; }
.profile-missing { background: var(--bad-bg); color: var(--bad); }

/* --- tabs ---------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: 20px 0 0;
}
.tab {
  background: none;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
  font-weight: 600;
}
/* `hidden` must win over the display below, or the "running" dot shows on an
   idle tab. */
.tab .dot[hidden] { display: none; }
.tab .dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--good);
  margin-left: 7px;
  vertical-align: middle;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

.panel { display: none; padding-top: 18px; }
.panel.active { display: block; }

/* --- controls ------------------------------------------------------------ */
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.control-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.control-row label { font-size: 13px; color: var(--muted); }

.hint { font-size: 12px; color: var(--faint); }
.hint.stale { color: #b45309; }

/* --- progress ------------------------------------------------------------ */
.progress { height: 8px; background: var(--hair); border-radius: 6px; overflow: hidden; margin-top: 16px; }
.bar { height: 100%; width: 0%; background: var(--good); transition: width .25s ease; }
.stats { font-size: 13px; margin-top: 8px; color: #334155; }

/* --- summary ------------------------------------------------------------- */
.summary { margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.summary-head {
  background: #f8fafc;
  padding: 10px 12px;
  font-size: 13px;
  color: #334155;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.summary-head b { color: var(--ink); }

table.phases { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
table.phases th, table.phases td {
  text-align: left;
  padding: 7px 12px;
  border-top: 1px solid var(--hair);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table.phases th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.phases th.num, table.phases td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.phases th:nth-child(1), table.phases td:nth-child(1) { width: 23%; }
table.phases th:nth-child(2), table.phases td:nth-child(2) { width: 25%; }
table.phases th:nth-child(3), table.phases td:nth-child(3) { width: 13%; }
table.phases th:nth-child(n+4), table.phases td:nth-child(n+4) { width: 8%; }
/* The per-row Run button sits in its own fixed column. */
table.phases th.act, table.phases td.act { width: 74px; text-align: right; }
tr.active { background: var(--good-bg); }

.ok { color: var(--good); }
.bad { color: var(--bad); font-weight: 600; }
.muted { color: var(--faint); }

/* --- logs ---------------------------------------------------------------- */
.toolbar { margin-top: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.logs {
  margin-top: 10px;
  background: #0b1220;
  color: #d1d5db;
  padding: 12px;
  border-radius: 8px;
  height: 58vh;
  min-height: 300px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
}
.logs div { white-space: pre-wrap; word-break: break-word; }
/* Plain white: a key step that is neither good news nor bad. */
.line-info { color: #e5e7eb; }
.line-skip { color: #fcd34d; }
.line-bad { color: #fca5a5; }
.line-good { color: #6ee7b7; }
.line-head { color: #93c5fd; font-weight: 600; }

@media (max-width: 640px) {
  body { padding: 14px; }
  .tab { padding: 10px 10px; font-size: 13px; }
  table.phases th:nth-child(2), table.phases td:nth-child(2) { display: none; }
  table.phases th.act, table.phases td.act { width: 62px; }
}
