/* O agent-desk: console denso e calmo, claro e escuro pelo sistema. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --text: #17202a;
  --muted: #5f6b7a;
  --line: #d9dee5;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --accent-soft: #e7f0fe;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --ok: #067647;
  --add: #e6f6ec;
  --remove: #fdecec;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font: 14px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1318;
    --surface: #161b22;
    --surface-2: #1c232c;
    --text: #e6edf3;
    --muted: #9aa6b4;
    --line: #2c3540;
    --accent: #4c9aff;
    --accent-text: #0b1220;
    --accent-soft: #14263f;
    --danger: #ff7b72;
    --danger-soft: #3a1717;
    --ok: #56d364;
    --add: #12301c;
    --remove: #3a1717;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); }

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* ── cabeçalho ─────────────────────────────────────────────────────────── */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 16px 0 12px;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.version {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.grow { flex: 1; }

.nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.nav a {
  padding: 8px 12px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.nav a:hover { color: var(--text); }

.nav a.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

/* ── página ────────────────────────────────────────────────────────────── */

.page { padding-top: 20px; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
h4 { font-size: 13px; margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

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

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

.card > h3:first-of-type { margin-top: 0; }

.note summary { font-weight: 600; }
.note ul { margin: 8px 0 0; padding-left: 18px; }
.note li { margin: 4px 0; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.badge.ok { color: var(--ok); border-color: currentColor; }

/* ── listas ────────────────────────────────────────────────────────────── */

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

.list a {
  display: grid;
  grid-template-columns: minmax(120px, 220px) 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.list li:last-child a { border-bottom: 0; }
.list a:hover strong { color: var(--accent); }
.list .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── formulários ───────────────────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}

.full { grid-column: 1 / -1; }

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

input:not([type="checkbox"]), select, textarea {
  display: block;
  width: 100%;
  padding: 7px 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

textarea { resize: vertical; }

textarea.code {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
}

input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
}

.hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.sealed {
  display: block;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ok);
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 6px 0;
  font-weight: 400;
}

.check input { margin-top: 3px; }

.invalid input, .invalid select, .invalid textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px var(--danger-soft);
}

details { margin: 12px 0; }
summary { cursor: pointer; color: var(--muted); }

/* ── workflows ─────────────────────────────────────────────────────────── */

.workflows { display: grid; gap: 12px; }

.workflow {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
}

.wake {
  margin-top: 8px;
  border-top: 1px dashed var(--line);
}

.block {
  margin-top: 10px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 6px;
}

.rows { display: grid; gap: 8px; margin: 8px 0; }

.row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr auto;
  align-items: end;
  gap: 8px;
}

/* ── ações e retorno ───────────────────────────────────────────────────── */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.actions.end { justify-content: flex-end; }

.button {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

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

.status {
  margin: 10px 0;
  padding: 9px 12px;
  border-radius: 6px;
  background: var(--accent-soft);
}

.status.error {
  background: var(--danger-soft);
  color: var(--danger);
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 20px);
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── diff ──────────────────────────────────────────────────────────────── */

.diff {
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}

.diff div { white-space: pre; padding: 0 8px; }
.diff .add { background: var(--add); }
.diff .remove { background: var(--remove); }
.diff .gap { color: var(--muted); text-align: center; }

/* ── telas estreitas ───────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; }
  .list a { grid-template-columns: 1fr; gap: 2px; }
  .list .muted { white-space: normal; }
}
