/* Lead X — see docs/DESIGN.md before adding to this file. */

/* Dark is the default (:root, no attribute needed — zero flash on first visit).
   Light is the alternate, opted into via [data-theme="light"] on <html>,
   toggled by .theme-toggle (see bottom of file) and remembered in localStorage.
   --brand / --brand-dark / --brand-darker / --success / --danger are brand-identity
   colors and intentionally do NOT change between themes — only the surface/text
   tokens do. */
:root {
  --brand: #527588;
  --brand-dark: #25353d;
  --brand-darker: #16262b;
  --ink: #eef3f4;
  --muted: #93a7ad;
  --border: #34474e;
  --surface: #1e2d33;
  --bg: #16262b;
  --success: #5fb890;
  --danger: #e2725c;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

:root[data-theme="light"] {
  --ink: #1b2226;
  --muted: #5b6b72;
  --border: #dbe2e5;
  --surface: #ffffff;
  --bg: #f4f6f7;
  --shadow: 0 2px 8px rgba(15, 30, 34, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

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

/* ── Layout ────────────────────────────────────────────────────────────── */

.header {
  position: relative;
  background: var(--brand-dark);
  padding: 14px 20px;
  display: flex;
  align-items: center;
}

/* Absolutely positioned so it never fights the logo's own alignment
   (including the portrait-centered .header-public). */
.header-nav {
  display: flex;
  gap: 20px;
  margin-left: 28px;
}

.header-nav a {
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.header-nav a.active { color: #fff; }

/* room for the absolutely-positioned .theme-toggle sitting to its right */
.logout-form { margin-right: 52px; }

.theme-toggle {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
}

.header img { height: 32px; display: block; }

/* The public forms' header has nothing else in it (no logout button, unlike
   admin's) — center the logo in portrait, where left-aligned reads unbalanced. */
@media (orientation: portrait) {
  .header-public { justify-content: center; }
}

.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.shell-wide { max-width: 1100px; }

.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 16px; }
p.lead { color: var(--muted); margin: 0 0 24px; }

/* ── Forms ─────────────────────────────────────────────────────────────── */

label.fld {
  display: block;
  margin-bottom: 18px;
}

label.fld > span {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
select,
textarea {
  width: 100%;
  font-size: 1rem;
  padding: 14px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(82, 117, 136, 0.25);
}

textarea { resize: vertical; min-height: 80px; }

.fldrow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0 16px;
}

.hint {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
}

.hint.error { color: var(--danger); }

/* Sits directly under a .fldrow whose fields already carry the standard
   18px bottom margin — pull it up close to that row, then restore the
   normal field-to-field rhythm below it. */
.fld-group-hint { margin-top: -12px; margin-bottom: 18px; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 22px;
  font-size: 0.95rem;
}

.check input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; }

/* ── Buttons ───────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* the accent, not --brand-dark — a dark button would blend into the now-dark surfaces around it */
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  padding: 14px 22px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { opacity: 0.92; }
.btn-block { width: 100%; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}

/* ghost button on a dark surface, e.g. the admin header's "Log out" */
.btn-ghost-invert {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

/* ── Pill selector (interest level, admin filters) ────────────────────── */

.pillgroup {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.pill {
  position: relative;
  flex: 1 1 auto;
  text-align: center;
  padding: 14px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  min-width: 100px;
}

.pill:has(input:checked) { padding-right: 32px; }

/* Selected state has one source of truth: the input's own :checked state
   (radio pills) or the .active class (admin filter-chip links, which have
   no underlying input). Never rely on JS to mirror this — it can desync
   from what was actually submitted. */
.pill.active,
.pill:has(input:checked) {
  /* the accent, not --brand-dark — too close to the unselected pill's own
     --surface tone on a dark page to read as clearly "selected" */
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.pill:has(input:checked)::after {
  content: "\2713";
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  font-weight: 700;
}

.pill input { position: absolute; opacity: 0; pointer-events: none; }

/* small pill used as a filter chip / link, not a form control */
a.pill { display: inline-block; text-decoration: none; font-weight: 500; }

/* ── Confirmation / idle full-bleed states ────────────────────────────── */

.confirm {
  position: relative;
  min-height: 100vh;
  background: var(--brand-darker);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  overflow: hidden;
}

.confetti-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: 0;
  width: 6px;
  height: 10px;
  border-radius: 1px;
  animation-name: confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(-16px) rotate(0deg); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translateY(480px) rotate(340deg); opacity: 0; }
}

/* When .confirm is an <a> (the idle screen, tap-anywhere-for-staff-entry) */
a.confirm { text-decoration: none; color: inherit; cursor: pointer; }

.confirm img.logo { height: 40px; margin-bottom: 32px; }
.confirm h1 { color: #fff; font-size: 2rem; margin-bottom: 12px; }
.confirm p { color: rgba(255, 255, 255, 0.75); font-size: 1.1rem; max-width: 420px; }
.confirm .qr-wrap { background: #fff; padding: 20px; border-radius: var(--radius); margin: 24px 0; }
.confirm .sub { color: rgba(255, 255, 255, 0.5); font-size: 0.85rem; margin-top: 8px; }

.error-icon { margin-bottom: 22px; opacity: 0.85; }
.error-eyebrow {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--brand);
  margin: 0 0 10px;
}
.confirm .btn { margin-top: 26px; }

/* The idle/QR screen is read from further away than a form screen —
   logo and QR both go noticeably larger than the post-submit confirmation. */
.confirm-qr img.logo { height: 90px; }
.confirm-qr .qr-wrap { padding: 28px; }

/* Staff confirmation: no auto-advance — stays up until staff explicitly
   taps + for the next visitor, since they may still be talking to the guest. */
.fab-next {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: #fff;
  color: var(--brand-darker);
  font-size: 2.75rem;
  line-height: 1;
  text-decoration: none;
  margin-top: 28px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* ── Admin ─────────────────────────────────────────────────────────────── */

.navrow {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.navrow .pillgroup { flex: 0 1 auto; }
.filter-form select { width: auto; padding: 10px 14px; }

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

.spacer { flex: 1 1 auto; }

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

table.leads {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table.leads th, table.leads td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

table.leads th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

table.leads tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.qr_guest { background: #e4ecef; color: var(--brand-dark); }
.badge.kiosk_staff { background: #f0e6d8; color: #7a5a24; }

.statrow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card { padding: 16px 20px; }

.stat-card-highlight { border-color: var(--brand); }

.stat {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}

.stat .n { font-size: 1.6rem; font-weight: 700; }
.stat .l { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.stat-card-highlight .stat .n { color: var(--brand); }

.errors {
  background: #fbe9e6;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.9rem;
}

.errors ul { margin: 0; padding-left: 18px; }

.offline-banner {
  display: none;
  align-items: center;
  gap: 10px;
  background: rgba(226, 114, 92, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.87rem;
  line-height: 1.4;
}

.offline-banner.is-visible { display: flex; }
.offline-banner svg { flex-shrink: 0; }

.errors-card {
  background: var(--surface);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}

.errors-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--danger);
}

.errors-card-head span { font-size: 0.87rem; font-weight: 700; }

.errors-card-list {
  font-size: 0.87rem;
  color: var(--ink);
  line-height: 1.7;
}

#lead-submit-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

@keyframes leadx-spin { to { transform: rotate(360deg); } }
.spin { animation: leadx-spin 0.8s linear infinite; }
@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
}

.link-center { text-align: center; margin-top: 16px; }

.steps {
  margin: 20px 0 0;
  padding-left: 22px;
}

.steps li {
  margin-bottom: 10px;
  line-height: 1.5;
}

.steps li:last-child { margin-bottom: 0; }

/* The one step in a list that needs to stand out from the rest — Chrome's
   own "unknown source" warning, expected and not a sign anything's wrong. */
.callout-warn {
  background: #2a1f1a;
  border: 1px solid #6b4a2f;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 4px 0;
  color: #e2b98c;
  font-size: 0.92em;
  line-height: 1.5;
}

.settings-tabs { margin-bottom: 24px; }

.invite-link-card { margin-bottom: 18px; }
.invite-link-card p.hint { margin: 0 0 10px; }
.invite-link {
  display: block;
  font-family: monospace;
  font-size: 0.85rem;
  word-break: break-all;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.status-banner {
  background: rgba(95, 184, 144, 0.12);
  border-color: var(--success);
  color: var(--success);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.9rem;
}

.qr-preview-card { text-align: center; }
.qr-preview-card .qr-preview { background: #fff; display: inline-block; padding: 16px; border-radius: var(--radius); }
.qr-preview-card p.hint { margin: 16px 0 20px; }
.qr-preview-card code { color: var(--ink); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}
