/* ==========================================================================
   Techgeezer admin + fact finder
   Same "workshop yellow + ink" look as techgeezer.ai.
   ========================================================================== */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --paper: #fffdf7;
  --ink: #12100a;
  --ink-body: #3d3a30;
  --ink-soft: #4a463a;
  --yellow: #ffd21e;
  --yellow-deep: #f0be00;
  --red: #c22f21;
  --green: #2e7d43;
  --green-soft: #c5e8cf;
  --blue-soft: #cbe1f7;
  --purple-soft: #e2d8f4;
  --sand: #f0ede4;
  --line: #12100a;
  --radius: 14px;
  --shadow: 5px 5px 0 var(--ink);
  --font-display: "Bricolage Grotesque", "Avenir Next", "Helvetica Neue", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

/* Beats display rules on .btn etc. so JS can toggle visibility via [hidden]. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-body);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.1;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
a { color: var(--ink); }

.muted { color: var(--ink-soft); font-size: 0.9375rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  padding: 0.6rem 1.3rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--ink); }
.btn-primary { background: var(--yellow); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-ghost:hover { background: rgba(18, 16, 10, 0.05); box-shadow: none; transform: none; }
.btn-big { font-size: 1.125rem; padding: 0.85rem 1.8rem; }
.btn-small { font-size: 0.875rem; padding: 0.35rem 0.9rem; box-shadow: 2px 2px 0 var(--ink); }
.btn-small:hover { box-shadow: 3px 3px 0 var(--ink); }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-danger { border-color: var(--red); color: var(--red); box-shadow: 2px 2px 0 var(--red); }
.btn-danger:hover { box-shadow: 3px 3px 0 var(--red); }

.link-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; color: var(--ink); text-decoration: underline;
}
.danger-link { color: var(--red); }
.inline-form { display: inline; }

/* ---------- Admin top bar ---------- */
.topbar { background: var(--ink); color: var(--paper); }
.topbar-inner {
  width: min(64rem, 100% - 2.5rem);
  margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 0;
}
.brand {
  font-family: var(--font-display);
  font-weight: 800; font-size: 1.25rem;
  color: inherit; text-decoration: none;
}
.brand-tag {
  font-weight: 600; font-size: 0.8em;
  background: var(--yellow); color: var(--ink);
  border-radius: 6px; padding: 0.05em 0.4em;
  vertical-align: middle;
}
.topbar-nav { display: flex; align-items: center; gap: 1.25rem; }
.topbar-nav a { color: var(--paper); text-decoration: none; font-weight: 600; }
.topbar-nav a:hover { text-decoration: underline; }
.topbar-nav .link-btn { color: var(--paper); opacity: 0.75; }

/* ---------- Page layout ---------- */
.page {
  width: min(64rem, 100% - 2.5rem);
  margin-inline: auto;
  padding: 2.5rem 0 5rem;
}
.page-narrow { width: min(46rem, 100% - 2.5rem); }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem;
}
.page-head h1 { margin: 0; font-size: 2.25rem; }
.breadcrumb { margin: 0 0 0.75rem; }
.breadcrumb a { text-decoration: none; font-weight: 600; color: var(--ink-soft); }
.breadcrumb a:hover { color: var(--ink); }

.card {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.75rem;
}
.card-title { font-size: 1.25rem; margin-bottom: 1rem; }

/* ---------- Tables ---------- */
.table-card { padding: 0.5rem 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid rgba(18, 16, 10, 0.12);
}
.table th {
  font-family: var(--font-display);
  font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.table tr:last-child td { border-bottom: none; }
.row-link { font-weight: 700; text-decoration: none; }
.row-link:hover { text-decoration: underline; }

/* ---------- Chips ---------- */
.chip {
  display: inline-block;
  font-family: var(--font-display);
  color: var(--ink);
  font-size: 0.8125rem; font-weight: 700;
  padding: 0.1em 0.7em;
  border: 2px solid var(--ink);
  border-radius: 999px;
  white-space: nowrap;
}
.chip-done { background: var(--green-soft); }
.chip-progress { background: var(--blue-soft); }
.chip-wait { background: var(--sand); color: var(--ink-soft); border-color: var(--ink-soft); }
.chip-muted { background: transparent; color: var(--ink-soft); border-style: dashed; border-color: rgba(18, 16, 10, 0.35); }

/* Effort tags on AI summary recommendations */
.chip-quick { background: var(--yellow); }
.chip-small { background: var(--blue-soft); }
.chip-large { background: var(--purple-soft); }

/* ---------- Forms (admin + public) ---------- */
.field { display: block; margin-bottom: 1.25rem; }
.field-label {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.35rem;
}
.field-label em { color: var(--red); font-style: normal; }
.field-help { color: var(--ink-soft); font-size: 0.9375rem; margin: -0.2rem 0 0.5rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 540px) { .field-row { grid-template-columns: 1fr; } }

input[type="text"], input[type="email"], input[type="tel"], input[type="password"], textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: rgba(74, 70, 58, 0.6); }

.form-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 0.5rem; }
.form-error {
  background: var(--red); color: #fff;
  border-radius: 10px; padding: 0.6rem 1rem;
  font-weight: 600; margin-bottom: 1.25rem;
}

/* ---------- Pill choices (radio / checkbox) ---------- */
.pill-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pill { position: relative; display: inline-block; }
.pill input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pill span {
  display: inline-block;
  padding: 0.4rem 0.95rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: background 0.1s ease, box-shadow 0.1s ease;
}
.pill input:checked + span { background: var(--yellow); box-shadow: 2px 2px 0 var(--ink); }
.pill input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.pill:hover span { background: rgba(255, 210, 30, 0.35); }
.pill input:checked:hover + span { background: var(--yellow); }

.other-input { margin-top: 0.6rem; }

.field-missing input[type="text"], .field-missing textarea { border-color: var(--red); }
.field-missing .field-label { color: var(--red); }
.field-missing .pill span { border-color: var(--red); }

/* ---------- Login / centred pages ---------- */
.centered-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.login-card { width: 100%; max-width: 24rem; }
.login-title { font-size: 1.5rem; text-align: center; margin-bottom: 1.25rem; }
.done-card { width: 100%; max-width: 34rem; padding: 2.5rem; }
.done-tick {
  width: 3rem; height: 3rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--yellow);
  border: 2px solid var(--ink); border-radius: 50%;
  font-size: 1.5rem; font-weight: 800;
  margin-bottom: 1.25rem;
}

/* ---------- Dashboard extras ---------- */
.empty-state { text-align: center; padding: 3rem 2rem; }
.empty-state p { color: var(--ink-soft); margin-bottom: 1.5rem; }

/* ---------- Client page ---------- */
.ff-list { list-style: none; margin: 0; padding: 0; }
.ff-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 0.85rem 0;
  border-bottom: 1px solid rgba(18, 16, 10, 0.12);
}
.ff-item:last-child { border-bottom: none; }
.ff-item-main { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.ff-item-actions { display: flex; align-items: center; gap: 0.5rem; }
.ff-view { font-weight: 700; }
.danger-zone { margin-top: 2.5rem; text-align: right; }

/* ---------- Response view ---------- */
.response-meta { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.answers { margin: 0; }
.answers dt {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  margin-top: 1.1rem;
}
.answers dt:first-child { margin-top: 0; }
.answers dd { margin: 0.15rem 0 0; }
.answer-text { white-space: pre-wrap; }
.answer-tags { list-style: none; margin: 0.25rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.answer-tags li {
  border: 2px solid var(--ink); border-radius: 999px;
  padding: 0.1em 0.7em;
  font-size: 0.875rem; font-weight: 600;
  background: var(--yellow);
}

/* ---------- Public fact finder ---------- */
.form-topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ink); color: var(--paper);
  padding: 0.75rem clamp(1rem, 4vw, 2rem);
}
.save-toast {
  position: fixed;
  left: 50%; bottom: 1.25rem;
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  font-family: var(--font-display);
  font-weight: 700; font-size: 0.9375rem;
  padding: 0.45rem 1.2rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(18, 16, 10, 0.3);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 50;
}
.save-toast.visible { opacity: 1; }

.form-wrap {
  width: min(44rem, 100% - 2rem);
  margin-inline: auto;
  padding: 2.5rem 0 5rem;
}
/* Auto-growing answers: JS sets the height, so hide the manual resize handle. */
.form-wrap textarea { resize: none; overflow: hidden; min-height: 6.5rem; }
.form-intro h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); }
.form-intro { margin-bottom: 2rem; }
.form-intro p { color: var(--ink-soft); }
.form-intro strong { color: var(--ink); }

.progress {
  display: flex; align-items: center; gap: 0.9rem;
  margin-bottom: 1.5rem;
}
.progress-track {
  flex: 1; height: 0.7rem;
  border: 2px solid var(--ink); border-radius: 999px;
  background: #fff; overflow: hidden;
}
.progress-fill { height: 100%; background: var(--yellow); transition: width 0.25s ease; }
.progress-label {
  font-family: var(--font-display);
  font-weight: 700; font-size: 0.875rem;
  white-space: nowrap;
}

.step { margin: 0 0 1.75rem; }
.step-head { margin-bottom: 1.25rem; }
.step-count {
  font-family: var(--font-display);
  font-size: 0.8125rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.step-head h2 { font-size: 1.6rem; margin: 0.2em 0 0.25em; }
.step-intro { color: var(--ink-soft); margin: 0; }
.step .question { margin-bottom: 1.6rem; }
.step .question:last-child { margin-bottom: 0.25rem; }

.form-nav {
  display: flex; justify-content: flex-end; gap: 0.75rem;
  margin-top: 0.5rem;
}
#btn-back { margin-right: auto; }
.form-footnote { text-align: center; color: var(--ink-soft); font-size: 0.9375rem; margin-top: 2rem; }

/* Small screens: tighter cards, full-width actions, room for the toast. */
@media (max-width: 540px) {
  .form-wrap { padding-top: 1.5rem; padding-bottom: 6rem; }
  .step.card { padding: 1.25rem 1rem; }
  #btn-submit { width: 100%; text-align: center; }
  .form-nav { flex-wrap: wrap; }
}

/* ---------- AI summary ---------- */
.ai-card { background: #fff; }
.ai-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
}
.ai-card-head .card-title { margin-bottom: 0; }
.ai-headline { margin-top: 0.75rem; font-weight: 500; }
.ai-subtitle { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; }
.ai-problems { margin: 0; padding-left: 1.25rem; }
.ai-problems li { margin-bottom: 0.5rem; }
.ai-recs { list-style: none; margin: 0; padding: 0; }
.ai-rec { padding: 0.85rem 0; border-bottom: 1px solid rgba(18, 16, 10, 0.15); }
.ai-rec:last-child { border-bottom: none; padding-bottom: 0; }
.ai-rec-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
.ai-rec p { margin-bottom: 0.25rem; }
.ai-meta { margin-top: 1.5rem; font-size: 0.875rem; }
