@import url('assets/colors_and_type.css');

/* ============================================================
   Bishop Health — Lead Console
   Internal lead-logging & conversion-upload tool
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--fg-default);
  background: var(--navy-50);
  font-size: var(--text-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::selection { background: var(--blue-100); }

/* ---------- App shell ---------- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.topbar {
  background: var(--navy-700);
  color: var(--fg-on-dark);
  border-bottom: 3px solid var(--blue-600);
}
.topbar-inner {
  max-width: 1340px;
  margin: 0 auto;
  padding: 14px var(--gutter);
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.brand img { height: 34px; width: auto; display: block; filter: brightness(0) invert(1); }
.brand-divider { width: 1px; height: 30px; background: rgba(255,255,255,0.25); }
.brand-title {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-title .kicker {
  font-size: 11px;
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--blue-300);
  font-weight: var(--fw-bold);
}
.brand-title .name {
  font-size: 17px;
  font-weight: var(--fw-bold);
  color: #fff;
}
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }

/* ---------- Tabs ---------- */
.tabs {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.tabs-inner {
  max-width: 1340px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  gap: 2px;
  overflow-x: auto;
}
.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 16px 18px;
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--fg-muted);
  white-space: nowrap;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab:hover { color: var(--navy-700); }
.tab.active { color: var(--navy-700); border-bottom-color: var(--blue-600); }
.tab .count {
  display: inline-block;
  margin-left: 6px;
  background: var(--navy-50);
  color: var(--navy-600);
  font-size: 12px;
  font-weight: var(--fw-bold);
  padding: 1px 8px;
  border-radius: var(--radius-pill);
}
.tab.active .count { background: var(--blue-100); color: var(--blue-800); }

/* ---------- Main ---------- */
main {
  max-width: 1340px;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-6) var(--gutter) var(--space-9);
  flex: 1;
}
.view { display: none; }
.view.active { display: block; }

.view-head { margin-bottom: var(--space-5); }
.view-head h1 {
  font-size: var(--text-h2);
  margin: 0 0 4px;
}
.view-head p { margin: 0; color: var(--fg-muted); max-width: 70ch; }

/* ---------- Stat cards ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-xs);
}
.stat .label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  font-weight: var(--fw-semibold);
}
.stat .value {
  font-size: 1.9rem;
  font-weight: var(--fw-bold);
  color: var(--navy-700);
  line-height: 1.1;
  margin-top: 4px;
}
.stat .value.accent { color: var(--blue-600); }
.stat .value.good { color: var(--success); }
.stat .sub { font-size: var(--text-xs); color: var(--fg-muted); margin-top: 2px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.search {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  background: #fff;
}
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--fg-muted); }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--shadow-focus); border-color: var(--blue-500); }

.filter-select {
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  background: #fff;
  color: var(--fg-default);
  min-width: 130px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease), transform 120ms var(--ease), box-shadow var(--dur) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--action); color: #fff; }
.btn-primary:hover { background: var(--action-hover); }
.btn-navy { background: var(--navy-700); color: #fff; }
.btn-navy:hover { background: var(--navy-800); }
.btn-ghost { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.3); }
.btn-ghost:hover { background: rgba(255,255,255,0.2); }
.btn-outline { background: #fff; color: var(--navy-700); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--navy-400); background: var(--navy-50); }
.btn-sm { padding: 7px 12px; font-size: var(--text-xs); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Table ---------- */
.table-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.table-scroll { overflow-x: auto; }
table.leads {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
table.leads th {
  text-align: left;
  padding: 12px 14px;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  font-weight: var(--fw-bold);
  background: var(--navy-50);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.leads td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--ink-100);
  vertical-align: middle;
}
table.leads tbody tr:last-child td { border-bottom: none; }
table.leads tr.lead-row { transition: background 140ms var(--ease); cursor: pointer; }
table.leads tr.lead-row:hover { background: var(--blue-50); }
.cell-name { font-weight: var(--fw-semibold); color: var(--navy-700); }
.cell-sub { font-size: var(--text-xs); color: var(--fg-muted); }
.cell-mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; color: var(--ink-600); }
.empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--fg-muted);
}
.empty svg { color: var(--ink-300); margin-bottom: var(--space-3); }

/* ---------- Platform badge ---------- */
.platform {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  padding: 3px 9px 3px 7px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.platform .dot { width: 8px; height: 8px; border-radius: 50%; }
.platform.google { background: #eaf1fe; color: #1a56c4; }
.platform.google .dot { background: #4285F4; }
.platform.meta { background: #e9f0ff; color: #1d4fc4; }
.platform.meta .dot { background: #1877F2; }
.platform.tiktok { background: #eef0f1; color: #1c1c1c; }
.platform.tiktok .dot { background: #111; }
.platform.other { background: var(--sand-100); color: var(--ink-700); }
.platform.other .dot { background: var(--ink-400); }

/* ---------- Status pill / select ---------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.st-new      { background: var(--navy-50);  color: var(--navy-600); }
.st-new .dot { background: var(--navy-400); }
.st-attempted      { background: #fff4e0; color: #9a6a12; }
.st-attempted .dot { background: var(--warning); }
.st-contacted      { background: var(--blue-50); color: var(--blue-800); }
.st-contacted .dot { background: var(--blue-500); }
.st-scheduled      { background: #eaf3ff; color: #1455a8; }
.st-scheduled .dot { background: #2f7fd6; }
.st-converted      { background: var(--success-bg); color: #1f6b50; }
.st-converted .dot { background: var(--success); }
.st-unqualified      { background: var(--ink-100); color: var(--ink-600); }
.st-unqualified .dot { background: var(--ink-400); }
.st-lost      { background: var(--error-bg); color: #93302b; }
.st-lost .dot { background: var(--error); }
.st-dnc      { background: #efe7f3; color: #6a3f7a; }
.st-dnc .dot { background: #8a5a9c; }

/* ---------- Drawer ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16,37,64,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
  z-index: 50;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(480px, 100%);
  background: var(--bg-page);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--dur) var(--ease-out);
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.drawer-head h2 { font-size: var(--text-h3); margin: 0 0 4px; }
.drawer-head .meta { font-size: var(--text-xs); color: var(--fg-muted); }
.icon-btn {
  appearance: none; border: none; background: none;
  padding: 6px; border-radius: var(--radius-sm); color: var(--fg-muted);
  display: inline-flex; line-height: 0;
}
.icon-btn:hover { background: var(--navy-50); color: var(--navy-700); }
.drawer-body { padding: var(--space-5); overflow-y: auto; flex: 1; }
.drawer-foot {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-3);
  background: var(--navy-50);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
}
.detail-grid.full { grid-template-columns: 1fr; }
.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--fg-muted);
  font-weight: var(--fw-bold);
  margin-bottom: 3px;
}
.field-value { font-size: var(--text-sm); color: var(--navy-800); word-break: break-word; }
.field-value.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; background: var(--navy-50); padding: 6px 8px; border-radius: var(--radius-xs); }

.section-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue-700);
  font-weight: var(--fw-bold);
  margin: var(--space-5) 0 var(--space-3);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ---------- Form ---------- */
.form-row { margin-bottom: var(--space-4); }
.form-row label.lbl {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--navy-700);
  margin-bottom: 6px;
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.input, .textarea, select.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  background: #fff;
  color: var(--fg-default);
}
.textarea { min-height: 80px; resize: vertical; }
.hint { font-size: var(--text-xs); color: var(--fg-muted); margin-top: 5px; }

.status-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}
.status-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  background: #fff;
  transition: all 140ms var(--ease);
  text-align: left;
}
.status-opt:hover { border-color: var(--navy-400); }
.status-opt.selected { border-color: var(--blue-600); background: var(--blue-50); box-shadow: inset 0 0 0 1px var(--blue-600); }
.status-opt .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(16,37,64,0.45);
  display: none;
  align-items: center; justify-content: center;
  padding: var(--gutter);
  z-index: 70;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: min(680px, 100%);
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  padding: var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-3);
}
.modal-head h2 { margin: 0; font-size: var(--text-h3); flex: 1; }
.modal-body { padding: var(--space-5); overflow-y: auto; }
.modal-foot {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex; gap: var(--space-3); justify-content: flex-end;
  background: var(--navy-50);
}

/* ---------- Import ---------- */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
  margin-bottom: var(--space-5);
}
.card h3 { margin: 0 0 var(--space-2); font-size: var(--text-h4); }
.card p.lead-sm { margin: 0 0 var(--space-4); color: var(--fg-muted); font-size: var(--text-sm); }
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-7);
  text-align: center;
  color: var(--fg-muted);
  transition: all 160ms var(--ease);
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: var(--blue-500); background: var(--blue-50); color: var(--blue-800); }
.dropzone svg { color: var(--ink-400); margin-bottom: var(--space-2); }
.dropzone strong { color: var(--navy-700); }

.platform-picker { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.platform-card {
  flex: 1;
  min-width: 130px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: #fff;
  text-align: left;
  transition: all 140ms var(--ease);
}
.platform-card:hover { border-color: var(--navy-400); }
.platform-card.selected { border-color: var(--blue-600); box-shadow: inset 0 0 0 1px var(--blue-600); background: var(--blue-50); }
.platform-card .pc-name { font-weight: var(--fw-bold); color: var(--navy-700); }
.platform-card .pc-id { font-size: var(--text-xs); color: var(--fg-muted); margin-top: 2px; font-family: ui-monospace, monospace; }

.code-sample {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  background: var(--navy-900);
  color: #cfe3f5;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre;
  line-height: 1.6;
}
.code-sample .k { color: var(--blue-300); }

.preview-note {
  display: flex; align-items: center; gap: 8px;
  background: var(--blue-50); color: var(--blue-800);
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); margin-bottom: var(--space-4);
}
.preview-note.warn { background: var(--warning-bg); color: #8a5d12; }
.preview-note.err { background: var(--error-bg); color: #93302b; }

/* ---------- Export ---------- */
.export-platforms { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: var(--space-4); }
.export-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-5); box-shadow: var(--shadow-xs);
  display: flex; flex-direction: column; gap: var(--space-3);
}
.export-card .ec-head { display: flex; align-items: center; gap: 10px; }
.export-card .ec-count { font-size: 2rem; font-weight: var(--fw-bold); color: var(--navy-700); line-height: 1; }
.export-card .ec-meta { font-size: var(--text-xs); color: var(--fg-muted); }
.export-card .ec-fields { font-size: var(--text-xs); color: var(--fg-muted); line-height: 1.5; }
.export-card .ec-fields code { font-family: ui-monospace, monospace; background: var(--navy-50); padding: 1px 5px; border-radius: 3px; color: var(--navy-700); }

/* ---------- Webhook ---------- */
.webhook-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: var(--text-xs); font-weight: var(--fw-semibold);
  color: #d7f0e4; background: rgba(46,139,107,0.22);
  border: 1px solid rgba(120,210,175,0.4);
  padding: 6px 12px; border-radius: var(--radius-pill);
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #4fd99a; flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(79,217,154,0.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(79,217,154,0.55); }
  70% { box-shadow: 0 0 0 7px rgba(79,217,154,0); }
  100% { box-shadow: 0 0 0 0 rgba(79,217,154,0); }
}
.webhook-url {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--navy-50); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: var(--space-3);
}
.webhook-url .method {
  font-size: var(--text-xs); font-weight: var(--fw-bold); letter-spacing: 0.06em;
  background: var(--success); color: #fff; padding: 3px 9px; border-radius: var(--radius-xs);
}
.webhook-url code {
  flex: 1; min-width: 200px; font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 13px; color: var(--navy-700);
}
.webhook-status {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--text-sm); color: var(--fg-muted);
}
.inline-code { font-family: ui-monospace, monospace; background: var(--navy-50); padding: 1px 6px; border-radius: 3px; color: var(--navy-700); font-size: 0.92em; }

.ec-pushed {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-xs); font-weight: var(--fw-semibold);
  color: #1f6b50; background: var(--success-bg);
  padding: 4px 10px; border-radius: var(--radius-pill);
}
.ec-pushing { font-size: var(--text-xs); color: var(--blue-700); font-weight: var(--fw-semibold); }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: var(--space-5); left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--navy-800); color: #fff;
  padding: 11px 18px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: var(--fw-medium);
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 9px;
  animation: toastIn 240ms var(--ease-out);
}
.toast.success { background: #1f6b50; }
.toast.error { background: #93302b; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Mobile cards ---------- */
.mcards { display: none; flex-direction: column; gap: var(--space-3); }
.mcard {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-4); box-shadow: var(--shadow-xs);
}
.mcard-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-2); }
.mcard-name { font-weight: var(--fw-bold); color: var(--navy-700); }
.mcard-row { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--text-sm); padding: 3px 0; }
.mcard-row .l { color: var(--fg-muted); }
.mcard-foot { margin-top: var(--space-3); display: flex; justify-content: space-between; align-items: center; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  :root { --text-h2: 1.6rem; }
  .table-wrap { display: none; }
  .mcards { display: flex; }
  .brand-title .kicker { display: none; }
  .drawer { width: 100%; }
  .form-grid-2, .detail-grid { grid-template-columns: 1fr; }
  .status-options { grid-template-columns: 1fr; }
  main { padding-top: var(--space-5); }
}
@media (max-width: 560px) {
  .topbar-actions .btn span.lbl { display: none; }
  .stat .value { font-size: 1.5rem; }
}
