/* ==========================================================================
   ReplySage AI — owner dashboard design system
   Source of truth: docs/07-ui-ux-spec.md ("front of house, back of house")
   All colors/type/spacing decisions live here as tokens. No inline styles.
   ========================================================================== */

:root {
  /* color */
  --porcelain: #F3F6F4;
  --surface: #FFFFFF;
  --ink: #152420;
  --muted: #5D6F68;
  --evergreen: #1E5745;
  --evergreen-deep: #153F32;
  --sage-line: #D8E2DC;
  --sage-fill: #EAF0EC;
  --hold: #8A5A00;        /* reserved: held / needs you */
  --hold-fill: #FAF0DC;
  --hold-line: #E4C778;
  --live: #1C7A4A;        /* reserved: live on Google */
  --live-fill: #E2F2E8;
  --clay: #A63D2F;        /* negative / destructive */
  --clay-fill: #F7E7E3;
  --star: #C29020;        /* reserved: star glyphs only */

  /* type */
  --font-display: "Bricolage Grotesque", "Public Sans", system-ui, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, "SF Mono", monospace;

  /* shape */
  --r-card: 10px;
  --r-ui: 8px;
  --shadow-lift: 0 2px 8px rgb(21 36 32 / 0.08);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--porcelain);
  color: var(--ink);
  min-height: 100vh;
}

a { color: var(--evergreen); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   Top bar — org name is the workspace identity; product name sits quietly.
   -------------------------------------------------------------------------- */
.topbar {
  background: var(--ink);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 56px;
  flex-wrap: wrap;
}
.topbar .brand-mark {
  width: 24px; height: 24px; flex: none;
  margin-right: -12px; /* tighten the 24px flex gap into a logo+name lockup */
}
.topbar .org {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  letter-spacing: 0.01em;
}
.topbar nav { display: flex; gap: 20px; align-items: center; }
.topbar nav a {
  color: #B9C6C0;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 4px 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar nav a[aria-current="page"] {
  color: #fff;
  text-decoration: underline;
  text-decoration-color: var(--evergreen);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}
.topbar .spacer { flex: 1; }
.topbar .whoami { font-size: 0.8rem; color: #8FA39B; }
.topbar .signout-form { display: inline; }
.topbar .signout { color: #8FA39B; font-size: 0.8rem; background: none; border: 0;
  padding: 0; font-family: inherit; cursor: pointer; text-decoration: none; }
.topbar .signout:hover { color: var(--porcelain); text-decoration: underline; }
.topbar .product { font-size: 0.72rem; color: #6E837B; font-family: var(--font-mono); letter-spacing: 0.06em; }

/* the only colored element allowed in the bar */
.pill {
  background: var(--hold-fill);
  color: var(--hold);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1;
  padding: 3px 8px;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.container { max-width: 1040px; margin: 0 auto; padding: 32px 16px 48px; }

.page-header { margin-bottom: 24px; }
.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.page-header .sub { color: var(--muted); margin-top: 4px; font-size: 0.85rem; }
.page-header .sub .count { font-family: var(--font-mono); }

.breadcrumb {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  margin-bottom: 16px;
  display: inline-block;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--sage-line);
  border-radius: var(--r-card);
  padding: 20px;
  margin-bottom: 16px;
}
.notice-upgrade {
  border-left: 3px solid var(--evergreen);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.notice-upgrade p { margin: 0; max-width: 62ch; }
.card-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

/* held items carry the amber rail — the one loud thing on any page */
.is-held { box-shadow: inset 3px 0 0 var(--hold-line); }
.rail-clay { box-shadow: inset 3px 0 0 var(--clay); }

/* --------------------------------------------------------------------------
   Needs-you band (home page, only when pending > 0)
   -------------------------------------------------------------------------- */
.needs-band {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--hold-line);
  box-shadow: inset 3px 0 0 var(--hold-line);
  border-radius: var(--r-card);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.needs-band p { flex: 1; min-width: 220px; }
.needs-band strong { font-family: var(--font-display); }

/* --------------------------------------------------------------------------
   Stat tiles
   -------------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--sage-line);
  border-radius: var(--r-card);
  padding: 14px 16px;
  display: block;
  color: var(--ink);
}
a.stat:hover { text-decoration: none; box-shadow: var(--shadow-lift); }
.stat-value { font-family: var(--font-display); font-size: 2.1rem; font-weight: 600; line-height: 1.1; }
.stat-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}
.stat.is-hot { border-top: 3px solid var(--hold-line); }
.stat.is-hot .stat-value { color: var(--hold); }

/* --------------------------------------------------------------------------
   Badges & chips
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-hold  { background: var(--hold-fill); color: var(--hold); }
.b-live  { background: var(--live-fill); color: var(--live); }
.b-sage  { background: var(--sage-fill); color: var(--muted); }
.b-clay  { background: var(--clay-fill); color: var(--clay); }
.b-clay-o { background: transparent; color: var(--clay); border: 1px solid var(--clay); }
.b-outline { background: transparent; color: var(--muted); border: 1px solid var(--sage-line); }

/* hold-reason chips: plain English, amber outline; raw code in title attr */
.chip {
  display: inline-block;
  border: 1px solid var(--hold-line);
  background: var(--surface);
  color: var(--hold);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.72rem;
  font-weight: 500;
  margin: 2px 4px 2px 0;
}
.chip-clay { border-color: var(--clay); color: var(--clay); }
/* A policy hold (below auto-post rating, review-every-reply) — calmer than the
   amber compliance chips, since nothing is wrong, it's just your rule. */
.chip-sage { border-color: var(--sage-line); color: var(--muted); }
.chip code { font-family: var(--font-mono); font-size: 0.7rem; }

/* --------------------------------------------------------------------------
   Stars — gold, reserved
   -------------------------------------------------------------------------- */
.stars { color: var(--star); letter-spacing: 2px; font-size: 0.85rem; white-space: nowrap; }
.stars .off { color: var(--sage-line); }

/* --------------------------------------------------------------------------
   Conversation thread (the signature)
   -------------------------------------------------------------------------- */
.review-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--sage-fill);
  color: var(--evergreen);
  font-weight: 700;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  flex: none;
}
.review-head .who { font-weight: 600; }
.review-head .when { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); margin-left: auto; }
.review-quote { line-height: 1.6; color: var(--ink); }
.review-meta { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); margin-top: 10px; }

.reply-thread {
  margin-top: 14px;
  margin-left: 16px;
  padding-left: 16px;
  border-left: 2px solid var(--sage-line);
}
.reply-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.reply-eyebrow .held-tag { color: var(--hold); font-weight: 500; }
.reply-bubble {
  background: var(--sage-fill);
  border-radius: 0 var(--r-card) var(--r-card) var(--r-card);
  padding: 12px 14px;
  line-height: 1.6;
}
.reply-bubble.is-editable {
  background: var(--surface);
  border: 1px solid var(--sage-line);
  padding: 0;
}
.reasons { margin-top: 10px; }
.reasons .lead {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hold);
  margin-right: 6px;
}

/* queue cards lift on hover — they are actionable */
.queue-card { transition: box-shadow 150ms ease; }
.queue-card:hover { box-shadow: inset 3px 0 0 var(--hold-line), var(--shadow-lift); }
.queue-card .actions { display: flex; justify-content: flex-end; margin-top: 12px; }

/* why-held panel on detail */
.why-held {
  background: var(--surface);
  border: 1px solid var(--hold-line);
  box-shadow: inset 3px 0 0 var(--hold-line);
  border-radius: var(--r-card);
  padding: 14px 16px;
  margin-top: 12px;
}
.why-held ul { list-style: none; margin-top: 8px; }
.why-held li { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; font-size: 0.85rem; }
.why-held li .code { font-family: var(--font-mono); font-size: 0.7rem; color: var(--hold); flex: none; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--r-ui);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--evergreen); color: #fff; }
.btn-primary:hover { background: var(--evergreen-deep); color: #fff; }
.btn-quiet { background: var(--surface); color: var(--ink); border-color: var(--sage-line); }
.btn-quiet:hover { border-color: var(--evergreen); color: var(--evergreen); }
.btn-danger { background: transparent; color: var(--clay); border-color: var(--clay); }
.btn-danger:hover { background: var(--clay); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }

.action-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.action-note { font-size: 0.75rem; color: var(--muted); margin-top: 10px; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th {
  text-align: left;
  padding: 10px 16px;
  background: var(--sage-fill);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
th:first-child { border-radius: var(--r-ui) 0 0 var(--r-ui); }
th:last-child { border-radius: 0 var(--r-ui) var(--r-ui) 0; }
td { padding: 12px 16px; border-bottom: 1px solid var(--sage-line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--porcelain); }
td.mono, .mono { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); }
td.nowrap { white-space: nowrap; }

/* audit timeline */
.audit td { padding: 8px 16px; font-size: 0.8rem; }
.audit .t { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); white-space: nowrap; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--sage-line);
  border-radius: var(--r-ui);
  font-family: var(--font-body);
  font-size: 0.875rem;
  line-height: 1.5;
  background: var(--surface);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--evergreen);
  outline-offset: 0;
  border-color: var(--evergreen);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
select { width: auto; min-width: 180px; }
input.w-narrow { width: 90px; }
.inline-fields { display: flex; gap: 8px; align-items: center; }
.inline-fields .sep { color: var(--muted); font-size: 0.8rem; }

/* full-width click-target toggle rows */
.check-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--sage-line);
  border-radius: var(--r-ui);
  cursor: pointer;
}
.check-row:hover { border-color: var(--evergreen); }
.check-row input { width: auto; margin-top: 3px; accent-color: var(--evergreen); }
.check-row .check-label { font-weight: 600; font-size: 0.85rem; display: block; }
.check-row .help { margin-top: 2px; }
.help { font-size: 0.75rem; font-weight: 400; color: var(--muted); }

.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

/* --------------------------------------------------------------------------
   Alerts (Django messages: success / error / warning / info)
   -------------------------------------------------------------------------- */
.alert {
  background: var(--surface);
  border: 1px solid var(--sage-line);
  border-radius: var(--r-ui);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
}
.alert-success { border-color: var(--live); box-shadow: inset 3px 0 0 var(--live); }
.alert-error, .alert-danger { border-color: var(--clay); box-shadow: inset 3px 0 0 var(--clay); }
.alert-warning { border-color: var(--hold-line); box-shadow: inset 3px 0 0 var(--hold-line); }
.alert-info { box-shadow: inset 3px 0 0 var(--sage-line); }

/* --------------------------------------------------------------------------
   Empty states
   -------------------------------------------------------------------------- */
.empty { text-align: center; padding: 48px 16px; }
.empty h2 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto; }

/* --------------------------------------------------------------------------
   Login (standalone page)
   -------------------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--sage-line);
  border-radius: var(--r-card);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
}
.login-card .login-logo { display: block; width: 52px; height: 52px; margin-bottom: 14px; }
/* free-text business type — revealed only when "Custom" is picked (no JS) */
.custom-type-field { display: none; margin-top: 10px; }
#vertical:has(option[value="custom"]:checked) ~ .custom-type-field { display: block; }
.login-card .brand { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }
.login-card .promise { color: var(--muted); font-size: 0.85rem; margin: 4px 0 24px; }
.login-card .form-group { margin-bottom: 14px; }
.login-card .btn { width: 100%; margin-top: 6px; }
.login-card .alert-error div + div { margin-top: 4px; }
.login-help { text-align: center; margin-top: 14px; font-size: 0.82rem; }
.login-help a { color: var(--muted); text-decoration: underline; }
.login-help a:hover { color: var(--ink); }

/* Signup: compact monthly / annual plan selector (posts with the form) */
.plan-choice-legend {
  display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px;
}
.plan-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plan-opt {
  display: block; margin: 0; cursor: pointer;
  border: 1px solid var(--sage-line); border-radius: var(--r-ui);
  padding: 10px 12px; background: var(--surface);
  transition: border-color 120ms ease, background 120ms ease;
}
.plan-opt:hover { border-color: var(--evergreen); }
.plan-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.plan-opt-body { display: block; }
.plan-opt-name { display: block; font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.plan-opt-price { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.plan-opt:has(input:checked) {
  border-color: var(--evergreen); background: var(--sage-fill);
  box-shadow: inset 0 0 0 1px var(--evergreen);
}
.plan-opt:has(input:focus-visible) {
  outline: 2px solid var(--evergreen); outline-offset: 2px;
}

@media (max-width: 360px) {
  .plan-choice { grid-template-columns: 1fr; }
}

/* Onboarding checklist */
.onboarding-steps { list-style: none; margin: 0; padding: 0; }
.onboarding-steps li { display: flex; gap: 14px; align-items: flex-start;
  padding: 16px 0; border-bottom: 1px solid var(--sage-line); }
.onboarding-steps li:last-child { border-bottom: 0; }
.onboarding-steps .step-mark { flex: 0 0 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.8rem; font-weight: 600;
  background: var(--sage-fill); color: var(--muted); border: 1px solid var(--sage-line); }
.onboarding-steps li.done .step-mark { background: var(--evergreen); color: #fff;
  border-color: var(--evergreen); }
.onboarding-steps .step-body { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex: 1; flex-wrap: wrap; }
.onboarding-steps li.done .step-label { color: var(--muted); }
.onboarding-steps .btn { margin: 0; }

/* --------------------------------------------------------------------------
   Settings / detail layout
   -------------------------------------------------------------------------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.narrow { max-width: 720px; margin: 0 auto; }
.gate-card { max-width: 460px; margin: 64px auto; text-align: center; padding: 40px 32px; }
.gate-card h2 { font-family: var(--font-display); font-size: 1.3rem; margin-bottom: 10px; }
.gate-card p { color: var(--muted); margin-bottom: 20px; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .container { padding: 20px 12px 40px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 10px 16px; gap: 12px; }
  .topbar .product { display: none; }
  .reply-thread { margin-left: 6px; padding-left: 10px; }

  /* review table → stacked cards */
  .collapsing thead { display: none; }
  .collapsing tr {
    display: block;
    border: 1px solid var(--sage-line);
    border-radius: var(--r-card);
    margin-bottom: 10px;
    background: var(--surface);
    padding: 8px 0;
  }
  .collapsing td { display: flex; gap: 10px; border: none; padding: 4px 14px; }
  .collapsing td::before {
    content: attr(data-label);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    min-width: 84px;
    padding-top: 2px;
  }
  .collapsing tbody tr:hover td { background: transparent; }
}

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