/* BuildServer/dashboard/public/styles.css */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #1c1f24;
  --muted: #646b76;
  --border: #dcdfe4;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --warn: #b26a00;
  --fail: #c62f2f;
  --run: #2f6fde;
  --idle: #7a818c;
  --log-bg: #15181d;
  --log-text: #d8dde4;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --surface-2: #23272f;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --border: #2e333c;
    --accent: #5b8ff0;
    --ok: #46b97a;
    --warn: #e0a33a;
    --fail: #ef6464;
    --run: #5b8ff0;
    --idle: #8a919b;
    --log-bg: #0b0d10;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
}

h1 { font-size: 18px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
}

button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.ghost { background: transparent; }
button.danger { color: var(--fail); }

input, select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 10px;
}

label { display: grid; gap: 4px; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
label > input, label > select { color: var(--text); }

fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-size: 14px; color: var(--muted); margin-bottom: 4px; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-status { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.topbar-status form { margin: 0; }

.agent-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 14px;
}

.agent-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--idle);
}

.agent-pill.online::before { background: var(--ok); }
.agent-pill.building::before { background: var(--run); }
.agent-pill.offline::before { background: var(--fail); }

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1280px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}

.card.wide { grid-column: 1 / -1; }

.targets { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.targets label { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--text); }
.targets input { width: auto; }

.switch { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; color: var(--text); }
.switch input { width: auto; }
.switch.compact { margin: 0 0 12px; }
#new-build > .switch.compact { margin-top: 8px; }
.hint { font-size: 13px; margin: 8px 0 0; }

.form-message { margin: 10px 0 0; font-size: 14px; }
.form-message.error { color: var(--fail); }

.status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
  background: var(--surface-2);
}

.status.success, .step-state.done { color: var(--ok); }
.status.failed, .step-state.failed { color: var(--fail); }
.status.running, .step-state.running { color: var(--run); }
.status.queued, .status.cancelled, .step-state.pending, .step-state.skipped { color: var(--idle); }
.step-state.warning { color: var(--warn); }

.current-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline; margin-bottom: 10px; }

.steps { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; }
.steps li { display: grid; grid-template-columns: 92px minmax(120px, 230px) 1fr; gap: 8px; font-size: 14px; }
.steps .step-result { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.steps li.step-stage { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-top: 6px; }
.nowrap { white-space: nowrap; }

pre.log {
  background: var(--log-bg);
  color: var(--log-text);
  font: 12px/1.4 var(--mono);
  padding: 10px 12px;
  border-radius: 8px;
  max-height: 340px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
}

.table-wrap { overflow-x: auto; }

table.history { width: 100%; border-collapse: collapse; font-size: 14px; }
table.history th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.history td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.history tbody tr { cursor: pointer; }
table.history tbody tr:hover { background: var(--surface-2); }
.comment-cell { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

dialog {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 16px;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.45); }

.details-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.details-head h2 { margin: 0; }
.meta { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; font-size: 14px; margin: 0 0 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.artifacts { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.artifacts a { color: var(--accent); }
.summary-box { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; margin-bottom: 12px; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.login-card h1 { margin-bottom: 6px; }
.login-card button { width: 100%; margin-top: 4px; }
.login-error { color: var(--fail); }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; padding: 12px; }
  .steps li { grid-template-columns: 80px 1fr; }
  .steps .step-result { grid-column: 1 / -1; }
  .meta { grid-template-columns: 1fr; }
  .meta dt { margin-top: 6px; }
}
