/* ---------------------------------------------------------------
   AI Candidate Intake — demo styling
   Self-contained, no external fonts or libraries (offline-safe).
----------------------------------------------------------------- */
:root {
  --bg:        #eef0f7;
  --bg-2:      #f7f8fc;
  --panel:     #ffffff;
  --ink:       #161a27;
  --muted:     #5d6470;
  --faint:     #6b7180; /* ~4.9:1 on white — passes WCAG AA for normal text */
  --line:      #e6e8f1;
  --line-2:    #eef0f6;
  /* --accent* and --topbar are overridden per vertical pack at runtime */
  --accent:    #4f46e5;
  --accent-2:  #6366f1;
  --accent-sft:#eef0fe;
  --accent-rgb:79,70,229;
  --topbar:    linear-gradient(118deg, #1b1840 0%, #3b34b0 52%, #5b54e6 100%);
  --hot:       #f59e0b;
  --hot-bg:    #fff8ec;
  --ok:        #10b981;
  --shadow:    0 1px 2px rgba(20,23,40,.05), 0 10px 30px rgba(20,23,40,.07);
  --shadow-sm: 0 1px 2px rgba(20,23,40,.06);
  --radius:    16px;
  /* tuned easing — calm, decisive, never bouncy (taste over flash) */
  --ease:      cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background:
    radial-gradient(1100px 480px at 78% -8%, #e7e9fb 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(var(--accent-rgb), .18); }

/* ---- top bar -------------------------------------------------- */
.topbar {
  background: var(--topbar);
  color: #fff;
  box-shadow: 0 8px 24px rgba(27,24,64,.18);
  transition: background .45s var(--ease);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 24px 6px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  flex: none;
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-tag { font-size: 12px; color: rgba(255,255,255,.78); }
.demo-pill {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.30);
  white-space: nowrap;
}

/* ---- vertical-pack switcher (segmented control) --------------- */
.pack-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.20);
}
.pack {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  padding: 7px 13px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255,255,255,.80);
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.pack:hover:not(.is-active):not(:disabled) { color: #fff; background: rgba(255,255,255,.10); }
.pack.is-active {
  background: #fff;
  color: #1b1840;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.pack:disabled { cursor: default; opacity: .65; }
.pack-switch :focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.topbar-sub {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 24px 24px;
}
.headline {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.014em;
  line-height: 1.34;
  color: rgba(255,255,255,.95);
  max-width: 48ch;
  text-wrap: balance; /* even two-line wrap where supported */
}

/* ---- layout --------------------------------------------------- */
.layout {
  max-width: 1180px;
  margin: 26px auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0; /* let the grid track shrink instead of the table forcing overflow */
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, var(--bg-2));
}
.panel-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.panel-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.online-dot {
  font-size: 12px;
  color: #0f766e; /* darker green: passes WCAG AA on white (the dot itself stays --ok) */
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.online-dot::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(16,185,129,.18);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
  50%      { box-shadow: 0 0 0 5px rgba(16,185,129,.08); }
}

/* ---- chat ----------------------------------------------------- */
.chat-log {
  height: 432px;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  background:
    radial-gradient(circle at 1px 1px, rgba(20,23,40,.04) 1px, transparent 0) 0 0 / 22px 22px;
}
.msg { display: flex; align-items: flex-end; gap: 8px; }
.msg-bot { justify-content: flex-start; }
.msg-candidate { justify-content: flex-end; }
.msg-system { justify-content: center; }

.msg-col { display: flex; flex-direction: column; max-width: 82%; min-width: 0; }
.msg-candidate .msg-col { align-items: flex-end; }
.msg-time { font-size: 10.5px; color: var(--faint); margin: 3px 5px 0; }

.avatar {
  flex: none;
  width: 27px; height: 27px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}
.avatar-bot { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #fff; }
.avatar-cand { background: #e7e9f2; color: #8b91a1; }

.bubble {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 15px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: var(--shadow-sm);
  animation: pop .18s ease-out;
}
.msg-bot .bubble {
  background: #f2f3f9;
  color: var(--ink);
  border-bottom-left-radius: 5px;
}
.msg-candidate .bubble {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #fff;
  border-bottom-right-radius: 5px;
}
.msg-system span {
  font-size: 12px;
  color: var(--muted);
  background: #f1f2f8;
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 999px;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* typing indicator */
.bubble.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.bubble.typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #9aa0b4;
  animation: blink 1.2s infinite ease-in-out;
}
.bubble.typing span:nth-child(2) { animation-delay: .2s; }
.bubble.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* inline "send reply" chip used by the vague scenario */
.reply-chip {
  border: 1px dashed var(--accent);
  background: var(--accent-sft);
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 14px;
  border-bottom-right-radius: 5px;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.reply-chip:hover { background: #e3e6ff; }
.reply-chip:active { transform: translateY(1px); }

/* ---- presets + controls -------------------------------------- */
.presets {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 15px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}
.presets-label { font-size: 12.5px; color: var(--muted); margin-right: 2px; }
/* a full-width zero-height break: examples on one row, controls on the next —
   two calm groups instead of a ragged right-pushed wrap */
.presets-spacer { flex-basis: 100%; height: 0; margin: 0; }
.preset {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s, box-shadow .15s;
}
.preset:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-sft); }
.preset:active:not(:disabled) { transform: translateY(1px); }
.preset:disabled { opacity: .5; cursor: default; }

.ctrl {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 11px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, transform .05s;
}
.ctrl:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.ctrl:active:not(:disabled) { transform: translateY(1px); }
.ctrl:disabled { opacity: .45; cursor: default; }
.ctrl.is-playing,
.ctrl.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---- presenter / record mode --------------------------------- */
/* A clean capture frame: hide the example presets + composer, keeping the
   minimal control cluster reachable. Toggle from the Record button, or press
   "r"; Esc exits. Off by default. */
body.record-mode .preset,
body.record-mode .presets-label,
body.record-mode .composer,
body.record-mode .foot { display: none; }
body.record-mode .presets { justify-content: flex-end; }

.composer {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
}
.composer input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.composer input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-sft); }
.composer button {
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.composer button:hover:not(:disabled) { background: var(--accent-2); }
.composer button:active:not(:disabled) { transform: translateY(1px); }
.composer button:disabled, .composer input:disabled { opacity: .55; cursor: default; }

/* shared focus ring for keyboard users */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- leads table --------------------------------------------- */
.counters { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.counter b {
  color: var(--ink);
  font-size: 14px;
  display: inline-block;
  font-variant-numeric: tabular-nums; /* digits don't jiggle as they tick */
}
.counter.hot b { color: var(--hot); }
.counter.muted b { color: var(--muted); }
.bump { animation: bump .32s ease; }
@keyframes bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.32); }
  100% { transform: scale(1); }
}

.table-wrap { position: relative; max-height: 486px; overflow: auto; }
.leads {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed; /* fixed widths so the Fit column can't be pushed off-screen */
}
/* column proportions come from the active pack (inline on <col>, rebuilt in JS) */
.leads thead th {
  position: sticky;
  top: 0;
  background: #fafbff;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .02em;
  white-space: nowrap;
  color: var(--muted);
  padding: 13px 13px;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}
.leads tbody td {
  padding: 14px 13px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
  overflow-wrap: break-word;
}
.lead-row {
  transition: opacity .4s var(--ease), transform .4s var(--ease), background-color .6s ease;
}
.lead-row:hover { background: #fbfbff; }
.lead-row.row-enter { opacity: 0; transform: translateY(-10px); }
.lead-row.is-hot { background: var(--hot-bg); box-shadow: inset 3px 0 0 var(--hot); }
.lead-row.is-hot:hover { background: #fff4df; }
.lead-row.row-flash { animation: flash 1s ease; }
/* Only the start frame is defined so the row settles back to its OWN background
   (amber for a hot row), instead of being forced transparent. */
@keyframes flash {
  from { background: var(--accent-sft); }
}
/* ONE restrained pulse the moment a lead turns hot — the single hero beat.
   The inset amber bar is preserved throughout; only an outer glow blooms once. */
.lead-row.hot-pulse { animation: hotpulse 1.5s var(--ease); }
@keyframes hotpulse {
  0%   { box-shadow: inset 3px 0 0 var(--hot), 0 0 0 0 rgba(245,158,11,.5); }
  35%  { box-shadow: inset 3px 0 0 var(--hot), 0 0 0 7px rgba(245,158,11,0); }
  100% { box-shadow: inset 3px 0 0 var(--hot), 0 0 0 0 rgba(245,158,11,0); }
}
.dim { color: #b9bdcc; }

.role-main { font-weight: 600; }
.role-meta {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: .01em;
}

.fit-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.fit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.fit-hot  { background: #fff1da; color: #b45309; }
.fit-ok   { background: #e7f8f1; color: #0f766e; }
.fit-wait { background: #f1f2f8; color: #5d6470; }
.fit-reason { font-size: 11px; color: var(--faint); }

.empty-state {
  padding: 46px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.empty-icon { display: block; color: var(--faint); margin: 0 auto 10px; opacity: .85; }
.empty-icon svg { display: block; margin: 0 auto; }

/* ---- footer --------------------------------------------------- */
.foot {
  max-width: 1180px;
  margin: 4px auto 28px;
  padding: 0 24px;
  color: var(--faint);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.foot-badge {
  font-weight: 600;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}
.foot-note { color: var(--faint); }

/* ---- responsive: table -> stacked cards on phones ------------- */
@media (max-width: 640px) {
  .topbar-inner { padding: 16px 18px 10px; }
  .topbar-sub { padding: 12px 18px 22px; }
  /* brand + Live-demo pill on top; the switcher takes its own full-width row */
  .pack-switch { order: 3; width: 100%; justify-content: center; }
  .pack { flex: 1 1 0; text-align: center; padding: 8px 10px; }
  .demo-pill { order: 2; }
  .headline { font-size: 16px; font-weight: 600; line-height: 1.42; max-width: none; }
  .layout { margin: 16px auto; padding: 0 14px; gap: 14px; }
  .chat-log { height: 50vh; min-height: 320px; }

  .table-wrap { max-height: none; }
  .leads thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .leads, .leads tbody { display: block; }
  .lead-row {
    display: block;
    margin: 12px;
    padding: 4px 2px;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
  }
  .lead-row:hover { background: #fff; }
  /* keep the amber left bar on the card (combined with the card shadow) */
  .lead-row.is-hot { background: var(--hot-bg); box-shadow: inset 3px 0 0 var(--hot), var(--shadow-sm); }
  .leads tbody td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--line-2);
    text-align: right;
  }
  .lead-row td:last-child { border-bottom: none; }
  .leads tbody td.is-empty { display: none; } /* hide blank fields so sparse cards look intentional */
  .leads tbody td::before {
    content: attr(data-label);
    flex: none;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--faint);
    text-align: left;
  }
  .role-meta { text-align: right; }
  .fit-cell { align-items: flex-end; }
}

/* on small phones the brand sub-label wraps and crowds the header — drop it;
   the headline already carries the message */
@media (max-width: 560px) {
  .brand-tag { display: none; }
  .brand-name { font-size: 17px; }
}

/* ---- respect reduced-motion preferences ----------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
