/* Sieve App — dashboard, builder, leads. Extends the marketing site's styles.css. */

/* Warns an owner their scorecards have stopped collecting leads (out of
   credits, or pay-per-lead with no card on file) — used on both
   dashboard.html and billing.html. */
.billing-alert {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--badsoft, #FBE7E5); border: 1.5px solid #F0B4AC; color: #7A1F17;
  border-radius: var(--radius-md); padding: 14px 18px; margin-bottom: 18px; font-size: 13.5px; line-height: 1.5;
}
.billing-alert strong { color: #5C1611; }

.dash-stats { margin-bottom: 28px; }
.sc-card {
  transition: box-shadow .15s ease, transform .15s ease;
  border-left: 3px solid var(--line);
}
.sc-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.sc-card-live { border-left-color: var(--good); }
.sc-card-draft { border-left-color: var(--line); }
.sc-meta-faint { color: var(--ink-faint); font-size: 12px; }
.empty-state svg { display: block; }
.empty-state h3 { font-family: var(--font-display); font-size: 1.15rem; margin-bottom: 6px; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:hover { background: inherit; transform: none; box-shadow: none; }
.app-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.app-topbar .actions { display: flex; align-items: center; gap: 12px; }
.app-main { flex: 1; padding: 40px 28px; max-width: 1040px; margin: 0 auto; width: 100%; }
.app-narrow { max-width: 460px; margin: 60px auto; width: 100%; }

/* Auth forms */
.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 40px 36px; box-shadow: var(--shadow-md);
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.field input, .field textarea, .field select {
  padding: 12px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  font-family: var(--font-body); font-size: 15px; background: var(--surface); color: var(--ink);
}
.field textarea { resize: vertical; min-height: 70px; }
.field-password { position: relative; }
.field-password input { width: 100%; padding-right: 42px; }
.field-password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; padding: 0; color: var(--ink-faint);
}
.field-password-toggle:hover { color: var(--ink-soft); }
.field-password-toggle svg { width: 18px; height: 18px; display: block; }
.form-error {
  background: var(--badsoft, #FBE7E5); color: #B3261E; border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13.5px; font-weight: 600; margin-bottom: 16px; display: none;
}
.form-error.show { display: block; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--ink-soft); }
.auth-switch a { color: var(--blue); font-weight: 700; }

/* Dashboard */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 14px; }
.page-head h1 { font-size: 1.7rem; }
.sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.sc-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 24px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.sc-card-thumb {
  height: 110px; margin: -24px -24px 16px; background-size: cover; background-position: center;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.sc-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.sc-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.badge { font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; }
.badge.live { background: var(--good-soft); color: var(--good); }
.badge.draft { background: var(--surface-sunk); color: var(--ink-faint); }
.sc-meta { font-size: 13px; color: var(--ink-faint); }
.sc-card-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 70px 20px; color: var(--ink-soft); }

/* Builder */
.builder-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }
.builder-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 26px; }
.builder-section h2 { font-size: 16px; margin-bottom: 4px; }
.builder-hint { font-size: 13px; color: var(--ink-faint); margin-bottom: 18px; }
.cover-preview { margin-top: 6px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); max-width: 280px; }
.cover-preview img { display: block; width: 100%; height: 140px; object-fit: cover; }
.cat-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 12px; }
.cat-row, .q-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.cat-row input { flex: 1; }
.cat-personalize { display: flex; flex-direction: column; gap: 8px; }
.cat-personalize textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 8px; border: 1.5px solid var(--line);
  font-family: var(--font-body); font-size: 13px; resize: vertical; background: var(--surface-sunk);
}
.opt-insight {
  width: 100%; min-height: 48px; padding: 10px 12px; margin: -4px 0 12px; border-radius: 8px;
  border: 1.5px solid var(--accent); font-family: var(--font-body); font-size: 13px; resize: vertical;
  background: var(--accent-soft);
}
.insight-toggle {
  background: none; border: none; color: var(--ink-faint); font-size: 12.5px; font-weight: 700;
  cursor: pointer; padding: 0 0 12px; text-align: left;
}
.insight-toggle:hover { color: var(--accent-ink); }
.toggle-row { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; margin-bottom: 10px; cursor: pointer; color: var(--ink); }
.toggle-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.section-tag {
  display: inline-block; font-family: var(--font-body); font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--accent-ink); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px;
  vertical-align: middle; margin-left: 8px;
}
.tier-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px; margin-bottom: 14px; }
.tier-card-label { font-family: var(--font-display); font-weight: 700; font-size: 15px; margin-bottom: 12px; }
.tier-card-min { font-family: var(--font-body); font-weight: 600; font-size: 12px; color: var(--ink-faint); }
.icon-btn {
  background: var(--surface-sunk); border: none; border-radius: 8px; width: 32px; height: 32px;
  cursor: pointer; font-weight: 800; color: var(--ink-soft); flex-shrink: 0;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent-ink); }
.question-card { border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 18px; margin-bottom: 14px; }
.question-card-top { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.question-card-top input { flex: 1; font-weight: 700; }
.option-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.option-row .opt-label { flex: 1; min-width: 160px; }
.option-score { display: flex; align-items: center; gap: 4px; }
.option-score label { font-size: 11px; color: var(--ink-faint); font-weight: 700; }
.option-score input { width: 52px; padding: 8px; text-align: center; }
.add-row-btn {
  background: none; border: 1.5px dashed var(--line); border-radius: var(--radius-sm);
  padding: 10px 16px; font-size: 13.5px; font-weight: 700; color: var(--ink-soft); cursor: pointer; width: 100%;
}
.add-row-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.builder-footer { position: sticky; bottom: 0; background: var(--paper); border-top: 1px solid var(--line); padding: 16px 28px; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.share-box { display: flex; gap: 8px; align-items: center; background: var(--surface-sunk); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; }
.share-box input { flex: 1; border: none; background: none; font-family: monospace; font-size: 13px; }
.save-status { font-size: 13px; color: var(--ink-faint); }

/* Leads table */
.leads-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
table.leads { width: 100%; border-collapse: collapse; min-width: 700px; }
table.leads th, table.leads td { padding: 14px 16px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--line-soft); }
table.leads th { background: var(--surface-sunk); font-family: var(--font-display); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); }
.tier-pill { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--blue-soft); color: var(--blue); }

/* Billing plan cards small */
.plan-mini { display: flex; align-items: center; justify-content: space-between; border: 1.5px solid var(--line); border-radius: var(--radius-md); padding: 20px 22px; margin-bottom: 12px; }
.plan-mini.current { border-color: var(--good); background: var(--good-soft); }

/* Usage-based billing: wallet summary + mode tabs */
.wallet-card { border: 1.5px solid var(--line); border-radius: var(--radius-md); padding: 20px 22px; margin-bottom: 22px; background: var(--surface); }
.wallet-mode { display: inline-block; font-family: var(--font-display); font-weight: 800; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; padding: 4px 12px; border-radius: 999px; margin-bottom: 14px; }
.wallet-mode.mode-credits { background: var(--blue-soft); color: var(--blue); }
.wallet-mode.mode-cpl { background: var(--accent-soft); color: var(--accent-ink); }
.wallet-mode.mode-sub { background: var(--surface-sunk); color: var(--ink-faint); }
.wallet-stats { display: flex; gap: 28px; flex-wrap: wrap; }
.wallet-stats > div { display: flex; flex-direction: column; }
.wallet-num { font-family: var(--font-display); font-weight: 800; font-size: 22px; color: var(--ink); }
.wallet-label { font-size: 12.5px; color: var(--ink-faint); font-weight: 600; }

.bill-tabs { display: flex; gap: 8px; margin-bottom: 18px; border-bottom: 1.5px solid var(--line); }
.bill-tab { background: none; border: none; padding: 10px 16px; font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--ink-faint); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1.5px; }
.bill-tab:hover { color: var(--ink); }
.bill-tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.bill-tab-secondary { color: var(--ink-faint); font-weight: 600; font-size: 13px; margin-left: auto; }
.bill-panel-intro { color: var(--ink-soft); font-size: 14.5px; margin-bottom: 16px; }
.bill-panel-secondary { color: var(--ink-faint); font-size: 13.5px; }

@media (max-width: 680px) {
  .app-topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; row-gap: 8px; }
  .app-main { padding: 24px 16px; }
  .sc-grid { grid-template-columns: 1fr; }
  .builder-footer { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }

  /* The core of the complaint: question/option/category rows currently sit
     side-by-side with small icon buttons, squeezing the text input. Stack
     them on mobile so every text field gets the full screen width to type
     and navigate in. */
  .cat-row, .q-row, .question-card-top, .option-row {
    flex-direction: column;
    align-items: stretch;
  }
  .option-row .opt-label { min-width: 0; width: 100%; }
  .option-score { align-self: flex-start; }

  /* Insight/personalization textareas need real room for multi-line typing
     on a phone keyboard, not the compact desktop sizing. */
  .cat-personalize textarea, .opt-insight { min-height: 90px; }

  /* iOS Safari auto-zooms on any input under 16px font-size when focused —
     a real usability papercut on a form-heavy page like the builder. */
  .field input, .field textarea, .field select,
  .cat-row input, .q-row input, .option-row input,
  .cat-personalize textarea, .opt-insight {
    font-size: 16px;
  }

  /* Slightly larger touch targets for the small icon buttons (delete
     question/option/category) — 32px is tight to tap accurately on mobile. */
  .icon-btn { width: 38px; height: 38px; }
}

.bill-highlight { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); animation: bill-pulse 1s ease 2; }
@keyframes bill-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
  50% { box-shadow: 0 0 0 6px var(--accent-soft); }
}
.cover-upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Compact, always-visible "where you stand" line on the dashboard — links to
   Billing, sits above the billing-alert warning (which only shows when
   blocked) so usage is visible whether or not anything's currently wrong. */
#usage-summary { margin-bottom: 14px; }
.usage-pill {
  display: inline-block; font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
  background: var(--surface-sunk); border-radius: 999px; padding: 6px 14px;
}
.usage-pill:hover { color: var(--ink); }