@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── UnifektoBridge admin UI — light SaaS theme. Signature: machine data (ids, cron, tokens, counts)
   is always set in mono, so the "data" the platform moves feels tangible. The Block Mapper canvas keeps
   its own blockmapper.css; everything here is bare element + utility-class selectors at low specificity
   so the canvas's .bm-* rules always win inside it. ── */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e6e9f0;
  --border-strong: #d4dae6;
  --text: #19212e;
  --muted: #5b6878;
  --faint: #8a96a8;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-tint: #eef3ff;
  --ok: #157347; --ok-tint: #e7f6ee;
  --danger: #b42318; --danger-tint: #fdecea; --danger-line: #f3c8c3;
  --warn: #b54708; --warn-tint: #fdf3e6; --warn-line: #f3dcb0;
  --radius: 11px; --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .10), 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 28px -12px rgba(16, 24, 40, .28);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans); background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 23px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 18px; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; margin: 26px 0 10px; }
code { font-family: var(--mono); font-size: .9em; }

/* ── shell ───────────────────────────────────────────────────────────────── */
.admin-shell { display: flex; min-height: 100vh; }
.admin-nav {
  width: 244px; flex: none; background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 14px; display: flex; flex-direction: column; gap: 2px;
}
.admin-brand {
  display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px;
  letter-spacing: -.01em; padding: 6px 10px 16px; color: var(--text);
}
.admin-brand .brand-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 14px; flex: none;
}
.admin-brand .brand-dim { color: var(--faint); }
.nav-section {
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--faint); padding: 14px 11px 5px;
}
.admin-nav a {
  position: relative; display: flex; align-items: center; gap: 9px;
  color: var(--muted); padding: 8px 11px; border-radius: 8px;
  font-size: 13.5px; font-weight: 550; transition: background .12s, color .12s;
}
.admin-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.admin-nav a.active { background: var(--brand-tint); color: var(--brand-strong); font-weight: 650; }
.admin-nav a.active::before {
  content: ""; position: absolute; left: -14px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand);
}

.admin-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between;
  align-items: center; gap: 16px; padding: 12px 32px;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border);
}
.topbar .who { color: var(--muted); font-size: 13px; }
.topbar .who strong { color: var(--text); font-weight: 650; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.admin-main { width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 32px 64px; }

/* ── buttons (default = secondary; primary/danger via class) ─────────────── */
button, .btn {
  font-family: var(--sans); font-size: 13px; font-weight: 600; line-height: 1.2;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s, color .12s;
}
button:hover, .btn:hover { background: var(--surface-2); border-color: var(--faint); }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-tint); }

.btn-primary, .create-workflow, .install-seeds {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.btn-primary:hover, .create-workflow:hover, .install-seeds:hover {
  background: var(--brand-strong); border-color: var(--brand-strong);
}
.btn-danger, .confirm-reset { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover, .confirm-reset:hover { background: #98271d; border-color: #98271d; }
.reset-seeds { color: var(--danger); border-color: var(--danger-line); }
.reset-seeds:hover { background: var(--danger-tint); border-color: var(--danger); }

/* ── forms ───────────────────────────────────────────────────────────────── */
input, select, textarea {
  font-family: var(--sans); font-size: 13.5px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 11px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
label { display: block; margin: 0 0 14px; font-size: 13px; font-weight: 600; color: var(--text); }
label > input, label > select, label > textarea { display: block; margin-top: 6px; width: 100%; max-width: 440px; font-weight: 400; }
small { display: block; color: var(--muted); font-size: 12px; margin: -8px 0 14px; }

/* ── tables ──────────────────────────────────────────────────────────────── */
table {
  border-collapse: separate; border-spacing: 0; width: 100%; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
th, td { padding: 11px 15px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
  background: var(--surface-2); font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--faint);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td a { font-weight: 600; }
td .mono, td code { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
/* row action buttons: compact */
td button, td a.btn { padding: 5px 10px; font-size: 12px; margin-right: 6px; }

/* ── badges (status pills) ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; line-height: 1.5; white-space: nowrap;
}
.badge-ok { background: var(--ok-tint); color: var(--ok); }
.badge-muted { background: #eceff4; color: var(--muted); }
.badge-info { background: var(--brand-tint); color: var(--brand-strong); }
.badge-warn { background: var(--warn-tint); color: var(--warn); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }

/* ── alerts / banners ────────────────────────────────────────────────────── */
.error, .info, .once-link, .bm-banner-conflict, .bm-banner-diag, .seed-banner {
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px;
}
.error, .bm-banner-conflict { background: var(--danger-tint); border: 1px solid var(--danger-line); color: var(--danger); }
.info, .seed-banner { background: var(--brand-tint); border: 1px solid #cfe0ff; color: var(--brand-strong); }
.bm-banner-diag { background: var(--warn-tint); border: 1px solid var(--warn-line); color: var(--warn); }
.once-link { background: var(--warn-tint); border: 1px solid var(--warn-line); color: var(--warn); word-break: break-all; font-family: var(--mono); font-size: 12.5px; }

/* ── page-specific toolbars ──────────────────────────────────────────────── */
.new-workflow { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.new-workflow input { min-width: 260px; margin: 0; }
.seed-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.reset-warning { color: var(--warn); font-size: 13px; font-weight: 600; }

/* ── auth screens (login / setup) ────────────────────────────────────────── */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #e7eefb, var(--bg)); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 30px 28px; }
.auth-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; margin-bottom: 22px; }
.auth-brand .brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-size: 15px; }
.auth-card h1 { font-size: 19px; margin-bottom: 18px; }
.auth-card label > input { max-width: none; }
.auth-card button { width: 100%; margin-top: 4px; }

/* ── fields page: collapsible entity sections + per-entity filter ─────────── */
details.entity { border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); margin: 8px 0; box-shadow: var(--shadow-sm); }
details.entity > summary { display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 11px 14px; list-style: none; user-select: none; }
details.entity > summary::-webkit-details-marker { display: none; }
details.entity > summary::before { content: "▸"; color: var(--faint); font-size: 11px; width: 10px; }
details.entity[open] > summary::before { content: "▾"; }
details.entity > summary:hover { background: var(--surface-2); border-radius: var(--radius-sm); }
details.entity[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.entity-name { font-weight: 650; }
.entity-refresh { margin-left: auto; }
.entity-body { padding: 6px 14px 14px; }
.entity-body table { margin-top: 4px; }
.field-tools { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 2px; }
.field-filter { width: 240px; max-width: 100%; padding: 6px 10px; }
.field-count { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }

/* ── provider connection: which providers are configured ──────────────────── */
ul.provider-status { list-style: none; display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 18px; padding: 0; }
ul.provider-status > li { display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow-sm); }
ul.provider-status > li.is-connected { border-color: var(--ok); background: var(--ok-tint); }
ul.provider-status .provider-status-name { font-weight: 600; }

/* Run-now parameter prompt (Phase 3 run-parameter filter values). */
.runparam-modal { position: fixed; inset: 0; background: rgba(20, 20, 18, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; }
.runparam-card { background: var(--surface, #fff); border-radius: 12px; padding: 22px 24px;
  min-width: 360px; max-width: 90vw; box-shadow: var(--shadow-sm, 0 8px 30px rgba(0,0,0,0.18)); }
.runparam-card h3 { margin: 0 0 4px; }
.runparam-card > p { margin: 0 0 14px; color: #6b6b66; font-size: 13px; }
.runparam-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.runparam-row label { flex: 0 0 130px; font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.runparam-input { flex: 1; height: 36px; border: 1px solid #e6e6e0; border-radius: 8px; padding: 0 11px;
  font-family: 'JetBrains Mono', monospace; font-size: 12.5px; outline: none; }
.runparam-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
