/* ─────────────────────────────────────────────────────────────────────────────
   leads.css — Module 4: status tracking and the saved-leads page.

   Kept separate from style.css rather than appended to it. One extra request
   against a much lower chance of clobbering something while editing a large
   stylesheet blind — and it is trivial to merge later if you want the request
   back.

   Uses the custom properties already declared in style.css. No new colours
   are invented here; --color-success-* and --color-error-* are the ones the
   alerts already use, so a "Won" badge and a success alert agree.
   ──────────────────────────────────────────────────────────────────────── */

/* ─── Inline row controls ─────────────────────────────────────────────── */

.lead-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 190px;
}

.lead-status {
  font: inherit;
  font-size: 0.85rem;
  padding: 5px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  width: 100%;
}

.lead-status:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 1px;
}

/* Colour follows meaning: untouched is quiet, won is the only celebratory
   one. Colour is never the ONLY signal — the option text says the same
   thing, which matters for the ~8% of men with colour vision deficiency. */
.lead-status--not_called { color: var(--color-text-muted); }
.lead-status--called     { border-color: var(--color-border); }
.lead-status--callback   { border-color: #fbbf24; }
.lead-status--won {
  border-color: var(--color-success-border);
  background:   var(--color-success-bg);
  color:        var(--color-success-text);
  font-weight:  500;
}

/* Module 16 D. Emailed is in progress, like called and callback, so it gets
   the accent wash. The three "done but not won" states recede: muted text,
   and only lost carries a (soft) error border, because it is the one that
   was a real opportunity. The label still says it all. */
.lead-status--emailed        { border-color: var(--color-accent); background: var(--color-accent-wash); }
.lead-status--not_interested { color: var(--color-text-muted); background: var(--color-bg); }
.lead-status--lost           { color: var(--color-text-muted); border-color: var(--color-error-border); }
.lead-status--bad_data       { color: var(--color-text-muted); background: var(--color-bg); }

.lead-notes {
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 5px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
  min-height: 32px;
  resize: vertical;
}

.lead-notes:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 1px;
}

/* Reserves its own line height so the row does not jump when the text
   appears and disappears. Layout shift on every save is worse than the
   handful of pixels this costs. */
.lead-save-state {
  font-size: 0.72rem;
  min-height: 1em;
  color: var(--color-text-subtle);
}

.lead-save-state.is-saving { color: var(--color-text-muted); }
.lead-save-state.is-saved  { color: var(--color-success-text); }
.lead-save-state.is-error  { color: var(--color-error-text); font-weight: 500; }

.lead-controls-cell { vertical-align: top; }

/* ─── Saved-leads page ────────────────────────────────────────────────── */

.leads-wrap  { padding: 32px 20px 64px; }
.leads-inner { max-width: 1160px; margin: 0 auto; }

.leads-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.leads__heading { margin: 0 0 4px; font-size: 1.5rem; }
.leads__sub     { margin: 0; color: var(--color-text-muted); font-size: 0.9rem; }

.leads-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.leads-filters {
  display: flex;
  align-items: center;
  gap: 8px 16px;
  flex-wrap: wrap;
}

.leads-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.leads-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.leads-tab:hover { color: var(--color-text); }

.leads-tab.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.leads-tab__count {
  font-size: 0.75rem;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.leads-sort {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.leads-sort select {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}

.leads-empty {
  text-align: center;
  padding: 56px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.leads-empty p { margin: 0 0 10px; }

.leads-table td { vertical-align: top; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 20px;
}

.pagination__info {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ─── Narrow screens ──────────────────────────────────────────────────── */

/* A five-column table does not fit a phone. The table scrolls horizontally
   rather than reflowing, because a lead list is genuinely tabular and
   stacking it into cards makes scanning worse, not better. */
@media (max-width: 720px) {
  .leads-toolbar { flex-direction: column; align-items: stretch; }
  .leads-sort    { justify-content: space-between; }
  .lead-controls { min-width: 160px; }
}

/* ─── Remove from search (Module 16 B) ────────────────────────────────── */

/* Row checkbox beside the business name, inside the Business cell. Not a
   column of its own: style.css targets the phone column as td:nth-child(2),
   and a new first column silently moved that nowrap onto Business. */
.pick {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.pick input { flex-shrink: 0; margin: 3px 0 0; cursor: pointer; }
.pick__body { min-width: 0; }
th .pick { align-items: center; cursor: pointer; }
th .pick input { margin-top: 0; }

/* Quiet until hovered: removing is occasional curation, not the main
   action on the row, and a loud button on every row would compete with
   the phone number. */
.lead-remove {
  display: block;
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.lead-remove:hover,
.lead-remove:focus-visible { color: var(--color-error-text); }
.lead-remove:focus-visible { outline: 2px solid var(--color-focus-ring); outline-offset: 2px; }
.lead-remove:disabled { opacity: .5; cursor: default; }

/* The bar shares .results-bar with Export CSV, which is right-aligned. */
.results-bar { align-items: center; gap: 12px; flex-wrap: wrap; }
.remove-bar { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.remove-bar[hidden] { display: none; }
.remove-bar__count { font-size: 0.85rem; color: var(--color-text-muted); }
.remove-status { font-size: 0.85rem; color: var(--color-text-muted); }
.remove-status.is-error { color: var(--color-error-text); }

/* Safety net (Module 16 B fix). style.css gives .search-card--flush
   overflow: hidden on desktop, which CLIPS a table wider than its card:
   the status column simply vanished when a column was added. Scrolling
   inside the card is the honest failure; phones already had it. */
.search-card--flush { overflow-x: auto; }

/* ─── Search history filter (Module 16 C) ─────────────────────────────── */

.history-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.history-filter .form-input { flex: 1 1 260px; max-width: 420px; }
.history-filter__clear { font-size: 0.85rem; }
