/* AdSquad Client Portal — shared styles.
   Ported from the approved prototype. */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --border: #e4e4e0;
  --border-strong: #d8d8d3;
  --ink: #16161a;
  --ink-2: #4a4a50;
  --muted: #6b6b72;
  --accent: #b5302a;
  --accent-ink: #8c241f;
  --accent-soft: #fdecea;
  --green: #2f6f4e;
  --green-soft: #e8f2ec;
  --amber: #8f5407;
  --blue: #1f4b99;
  --blue-soft: #eaf0fa;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Archivo, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- chrome ---------- */

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 24px;
  min-height: 64px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px 32px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; background: var(--accent); }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }

.nav { display: flex; align-items: center; gap: 4px; flex-grow: 1; }
.nav a {
  padding: 8px 12px; border-radius: 7px; font-size: 14px; font-weight: 500;
  color: var(--ink-2); text-decoration: none;
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { font-weight: 600; color: var(--ink); background: #f0f0ec; }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.who { font-size: 13px; color: var(--muted); }

main { max-width: 1280px; margin: 0 auto; padding: 32px 24px 64px; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  justify-content: space-between; gap: 16px; margin-bottom: 24px;
}
h1 { margin: 0 0 6px; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 17px; font-weight: 600; }
.sub { margin: 0; font-size: 14px; color: var(--muted); }

/* ---------- controls ---------- */

.btn {
  min-height: 44px; padding: 0 18px; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; border: 0; border-radius: 9px;
  background: var(--ink); color: #fff; font: inherit; font-size: 14px;
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #000; color: #fff; }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 13px; }

.segmented {
  display: flex; gap: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px; padding: 4px;
}
.segmented button {
  min-height: 36px; padding: 0 14px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-2); font: inherit;
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--ink); color: #fff; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select {
  min-height: 46px; padding: 0 14px; border: 1px solid var(--border-strong);
  border-radius: 9px; background: var(--surface); font: inherit;
  font-size: 15px; color: var(--ink);
}

/* ---------- surfaces ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-head {
  padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex;
  flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px;
}
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 24px; }

.metric-label {
  margin: 0 0 12px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.metric-value { margin: 0 0 4px; font-size: 38px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.metric-note { margin: 0; font-size: 13px; color: var(--muted); }

.status-strip {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--green); border-radius: var(--radius);
  padding: 16px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-live { background: var(--green); }
.dot-paused { background: var(--amber); }

.pill {
  display: inline-block; padding: 4px 10px; border-radius: 20px;
  background: #f0f0ec; font-size: 12px; color: var(--ink-2);
}
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px;
  font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
}
.badge-new { background: var(--accent-soft); color: var(--accent-ink); }
.badge-talking { background: var(--blue-soft); color: var(--blue); }
.badge-booked { background: var(--green-soft); color: #1f5238; }

.avatar {
  width: 42px; height: 42px; border-radius: 50%; background: #f0f0ec; color: var(--ink-2);
  font-size: 14px; font-weight: 600; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.avatar-sm { width: 30px; height: 30px; font-size: 12px; background: var(--ink); color: #fff; }

/* ---------- tables ---------- */

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 14px; }
th {
  text-align: left; padding: 12px 20px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
td { padding: 14px 20px; border-top: 1px solid #efefeb; vertical-align: top; }
.num { text-align: right; }

th.sortable { padding: 0; }
th.sortable button {
  width: 100%; padding: 12px 20px; border: 0; background: none;
  font: inherit; font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); cursor: pointer;
}
th.sortable button:hover { color: var(--ink); background: #f0f0ec; }
th.sortable[aria-sort="ascending"] button,
th.sortable[aria-sort="descending"] button { color: var(--ink); }
tr.total td { border-top: 2px solid var(--border); background: var(--surface-2); font-weight: 600; }

/* ---------- lead cards ---------- */

.lead { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.lead.is-new { border-left: 3px solid var(--accent); }
.lead-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px; }
.lead-body { flex-grow: 1; min-width: 220px; }
.lead-name { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 3px; }
.lead-name h3 { margin: 0; font-size: 16px; font-weight: 600; }
.lead-meta { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.lead-quote {
  margin: 0 0 10px; padding: 12px 14px; border-left: 2px solid var(--border-strong);
  background: var(--surface-2); border-radius: 0 7px 7px 0; font-size: 14px;
  line-height: 1.55; color: #3a3a40;
}
.lead-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.lead-actions { display: flex; flex-direction: column; gap: 8px; min-width: 150px; }

/* ---------- loading and messages ---------- */

.skeleton {
  background: linear-gradient(90deg, #eeeeea 25%, #f6f6f3 50%, #eeeeea 75%);
  background-size: 200% 100%; border-radius: 6px; animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.skeleton-line { height: 12px; margin: 6px 0; }
.skeleton-value { height: 34px; width: 70%; margin: 0 0 8px; }

.message {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--amber); border-radius: var(--radius);
  padding: 18px 22px; font-size: 15px; line-height: 1.55;
}
.message h2 { margin: 0 0 6px; font-size: 16px; }
.message p { margin: 0; color: var(--muted); }
.message code { font-size: 12px; color: var(--muted); }

.form-error { font-size: 14px; color: var(--accent-ink); margin: 0; }
.form-ok { font-size: 14px; color: var(--green); margin: 0; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); font-size: 15px; }

/* ---------- split layout for signed-out pages ---------- */

.split { min-height: 100vh; display: flex; flex-wrap: wrap; }
.split-brand {
  flex: 1 1 400px; min-width: 0; background: var(--ink); color: #fff;
  padding: 56px 48px; display: flex; flex-direction: column;
  justify-content: space-between; gap: 48px;
}
.split-brand h1 { font-size: 38px; line-height: 1.15; margin: 0 0 20px; }
.split-brand p { margin: 0; font-size: 16px; line-height: 1.6; color: #b8b8b4; }
.split-form { flex: 999 1 540px; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 56px 24px; }
.split-form > div { width: 100%; max-width: 400px; }
.divider { display: flex; align-items: center; gap: 14px; margin: 26px 0; }
.divider span:first-child, .divider span:last-child { flex-grow: 1; height: 1px; background: var(--border); }
.divider span:nth-child(2) { font-size: 12px; color: var(--muted); }

/* Contact details on a lead card. Rows with no value are never rendered,
   so a sparse contact never leaves blank labels behind. */
.contact {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 20px;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.contact div { min-width: 0; }
.contact dt {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 2px;
}
.contact dd { margin: 0; font-size: 13px; word-break: break-word; }
.contact dd a { text-decoration: none; }
.contact dd a:hover { text-decoration: underline; }

/* Campaign state dots. Three states, not two: a campaign waiting for
   approval has never run, so calling it "Paused" misreads it. */
.dot-live { background: var(--green); }
.dot-pending { background: var(--amber); }
.dot-off { background: #b4b4ae; }

/* Lead card: buttons sit as a row, not a stack of full-width blocks, and
   the contact pairs stay compact instead of stretching across the card. */
.lead-actions { flex-direction: row; flex-wrap: wrap; gap: 8px; min-width: 0; }
.contact { display: flex; flex-wrap: wrap; gap: 10px 28px; }
.contact div { flex: 0 1 auto; min-width: 140px; }

.thread-toggle {
  border: 0; background: none; padding: 0; margin-top: 8px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer;
}
.thread-toggle:hover { color: var(--accent-ink); }
.thread {
  margin: 10px 0 0; padding: 14px 16px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; line-height: 1.6; color: var(--ink-2);
  white-space: pre-wrap; word-break: break-word;
  max-height: 420px; overflow-y: auto;
}

.leads-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 4px;
}
.leads-tools input[type="search"] {
  flex: 1 1 240px; min-width: 0; min-height: 42px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--surface); font: inherit; font-size: 14px; color: var(--ink);
}
