/* Shared styling for the integration testbed. Plain CSS, nothing fancy. */

/* Auth gate: a protected page ships <body data-gated> and stays hidden until the
   session check resolves. auth.js's gatePage() reveals it on success (or 403, to
   show the message); on the redirect-to-login path it stays hidden, so signed-out
   users never see protected content flash. In the render-blocking stylesheet, so
   it applies before first paint. */
body[data-gated] { visibility: hidden; }

:root {
  --fg: #1a1a1a;
  --muted: #666;
  --border: #ddd;
  --card-bg: #fafafa;
  --accent: #0067b8;
  --ok-bg: #1f1f1f;
  --ok-fg: #eaeaea;
  --err-bg: #fff5f5;
  --err-border: #f5b5b5;
  --err-fg: #7a1f1f;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, sans-serif;
  color: var(--fg);
  line-height: 1.5;
  background: #fff;
}

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* --- Page header (injected by mountHeader) ------------------------------- */
.page-header {
  max-width: 820px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 0;
}
.page-header h1 { font-size: 1.6rem; margin: 0.5rem 0 0.25rem; }
.page-header .subtitle { color: var(--muted); margin: 0; }
.page-header .env-note {
  color: #8a5a00;
  background: #fff8e6;
  border: 1px solid #f0d68a;
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  display: inline-block;
  font-size: 0.8rem;
  margin-top: 0.6rem;
}
.back-link { color: var(--accent); text-decoration: none; font-size: 0.85rem; }
.back-link:hover { text-decoration: underline; }

/* --- Cards / sections ---------------------------------------------------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  background: var(--card-bg);
}
.card h2 { font-size: 1.05rem; margin: 0 0 0.75rem; }
.card p.hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.75rem; }

/* --- Forms --------------------------------------------------------------- */
.field { margin-bottom: 0.85rem; }
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
}
.field textarea { min-height: 6rem; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.field .field-hint { color: var(--muted); font-size: 0.78rem; margin-top: 0.2rem; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 8rem; }

/* --- Buttons ------------------------------------------------------------- */
button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
}
button:hover { filter: brightness(1.05); }
button:disabled { opacity: 0.6; cursor: progress; }
button.secondary {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
}

/* --- Output panel -------------------------------------------------------- */
.output {
  background: var(--ok-bg);
  color: var(--ok-fg);
  padding: 0.85rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  min-height: 1.5rem;
}
.output.is-error {
  background: var(--err-bg);
  color: var(--err-fg);
  border: 1px solid var(--err-border);
}
.output:empty::before { content: "(no output yet)"; color: var(--muted); }

code {
  background: #eee;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* --- Hub (test directory) ------------------------------------------------ */
.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.9rem;
  list-style: none;
  padding: 0;
  margin: 0;
}
.test-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--card-bg);
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.test-card:hover { border-color: var(--accent); box-shadow: 0 1px 6px rgba(0,0,0,0.06); }
.test-card h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.test-card p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}
.badge.backend { background: #e7f0fb; color: #0a4d8c; }
.badge.client { background: #e8f5e9; color: #1b5e20; }
.badge.todo { background: #f3e8fb; color: #5e2a8c; }
.badge.done { background: #1b5e20; color: #fff; }
.test-card.done { border-color: #1b5e20; box-shadow: inset 4px 0 0 #1b5e20; }
.test-card.done:hover { border-color: #1b5e20; }

/* --- Result table (e.g. postcode address list) -------------------------- */
.result-summary { font-weight: 600; margin: 0 0 0.6rem; }
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 22rem;
}
.addr-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.addr-table th,
.addr-table td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.addr-table thead th {
  background: var(--accent);
  color: #fff;
  position: sticky;
  top: 0;
  font-weight: 600;
}
.addr-table tbody tr:nth-child(even) { background: #f5f7fa; }
.addr-table tbody tr:hover { background: #e7f0fb; cursor: pointer; }
.addr-table tbody tr.selected { background: #d4e6fb; box-shadow: inset 3px 0 0 var(--accent); }
.addr-table td.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
}
.detail-card {
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: #f7fbff;
}
.detail-card h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.detail-card dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2rem 0.9rem;
  margin: 0;
  font-size: 0.85rem;
}
.detail-card dt { color: var(--muted); }
.detail-card dd { margin: 0; }
details.raw { margin-top: 1rem; }
details.raw summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; }
details.raw .output { margin-top: 0.5rem; }

/* --- Admin / user management -------------------------------------------- */
.addr-table td.actions { white-space: nowrap; text-align: right; }
.addr-table tbody tr:hover { background: inherit; cursor: default; }
.btn-sm {
  font-size: 0.78rem;
  padding: 0.3rem 0.55rem;
  margin-left: 0.35rem;
}
.btn-sm:first-child { margin-left: 0; }
.btn-danger { background: #fff; color: #a12121; border: 1px solid #e0a3a3; }
.btn-danger:hover { background: #fff5f5; filter: none; }
.pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}
.pill.active { background: #e8f5e9; color: #1b5e20; }
.pill.pending { background: #fff8e6; color: #8a5a00; }
.pill.disabled { background: #f1f1f1; color: #777; }
.pill.admin { background: #f3e8fb; color: #5e2a8c; margin-left: 0.3rem; }
.row.inline { align-items: flex-end; }
.row.inline .check { flex: 0 0 auto; min-width: 0; display: flex; align-items: center; gap: 0.4rem; padding-bottom: 0.6rem; }
.row.inline .check input { width: auto; }
.row.inline button { flex: 0 0 auto; }
.muted { color: var(--muted); }
