/* VUMO chatbot panel — components.
   Uses tokens from tokens.css only. Radius 0, no shadows, no gradients, Space Grotesk only.
   Operational type column: display 40px, h2 22px, h4 16px, body 14px, label-caps 11px. */

[hidden] { display: none !important; }

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--primary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased;
}

h2, h3, h4 { margin: 0; font-family: var(--font); }
h2 { font-size: 22px; font-weight: 500; line-height: 1.1; letter-spacing: -0.045em; }
h3 { font-size: 19px; font-weight: 500; line-height: 1.15; letter-spacing: -0.03em; }
p { margin: 0; }

button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

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

.label-caps {
  display: block;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.105em;
  text-transform: uppercase;
  color: var(--secondary);
}

.numeric { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0; }

.meta { font-size: 12px; line-height: 1.45; font-weight: 500; color: var(--secondary); }
.meta .ink { color: var(--primary); }

/* ---------- top bar (nav-operational) ---------- */
.topbar {
  height: var(--h-nav);
  padding: 0 var(--page-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
  background: var(--topbar-bg);
  color: var(--topbar-ink);
}
.brand { display: flex; align-items: center; gap: var(--sp-md); min-width: 0; }
.wordmark { font: 600 18px/1 var(--font); letter-spacing: 0.02em; color: var(--topbar-ink); padding-top: 2px; }
.product { font-size: 14px; font-weight: 500; color: var(--topbar-muted); white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-sm); }
.lang-toggle { min-width: 56px; }

/* live-process pill: outline + dot; busy pulses, ok/err steady, label always shown */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--secondary);
  color: var(--topbar-ink);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.pill .dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: var(--radius-full);
  background: var(--secondary);
}
.pill.is-ok .dot { background: var(--success-fill); }
.pill.is-warn .dot { background: var(--warning); }
.pill.is-err .dot { background: var(--error); }
.pill.is-busy .dot { animation: pulse 1.2s var(--ease-default) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---------- buttons (square, sentence case, 40px pointer) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  height: var(--h-control);
  padding: 2px 16px 0; /* +2px optical offset for Space Grotesk, per Brand Core */
  border: 1px solid transparent;
  border-radius: var(--radius-none);
  background: var(--primary);
  color: var(--white);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition:
    background var(--dur-micro) var(--ease-default),
    border-color var(--dur-micro) var(--ease-default),
    color var(--dur-micro) var(--ease-default);
}
.btn:hover:not(:disabled) { background: var(--accent); }
.btn:disabled { opacity: 0.4; }

/* ghost: 1px line border for filters and toolbars */
.btn-ghost { background: var(--surface); color: var(--primary); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--surface); border-color: var(--primary); }
.btn-ghost[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--white); }
.btn-ghost[aria-pressed="true"]:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }

/* nav action on the top bar */
.btn-nav { background: transparent; color: var(--topbar-ink); border-color: var(--secondary); }
.btn-nav:hover:not(:disabled) { background: transparent; color: var(--topbar-ink); border-color: var(--topbar-ink); }

/* text action (inside notices and results) */
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--accent); }

/* ---------- inputs (filled gray, no resting border, 42px) ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.input {
  width: 100%;
  height: var(--h-input);
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-none);
  background: var(--gray);
  color: var(--primary);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: -0.018em;
}
.input::placeholder { color: var(--secondary); font-weight: 400; }
.input:focus { border-color: var(--primary); }

.search { position: relative; display: block; }
.search > svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--secondary);
  pointer-events: none;
}
.search .input { padding-left: 40px; }

/* ---------- status tabs (slate inactive, ink active, 4px accent indicator) ---------- */
.tabs {
  display: flex;
  gap: var(--sp-lg);
  border-bottom: 1px solid var(--line);
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 0 10px;
  border: 0;
  background: none;
  color: var(--secondary);
  font-size: 14px;
  font-weight: 500;
}
.tab:hover { color: var(--primary); }
.tab[aria-selected="true"] { color: var(--primary); }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 4px;
  background: var(--accent);
}
.tab .count { font-size: 12px; color: var(--secondary); font-variant-numeric: tabular-nums; }

.presets { display: flex; flex-wrap: wrap; gap: var(--sp-sm); }
.presets .btn { height: var(--h-control); }

.custom-range { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* result line: reserved height so state changes do not shift layout */
.result {
  min-height: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
  font-size: 12px;
  color: var(--secondary);
}
.result-warn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-weight: 600;
}
.result-warn::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--warning);
}

/* ---------- stats strip (display numerals, accent on the one number that matters) ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border-bottom: 2px solid var(--separator);
}
.stat {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  padding: var(--sp-lg) var(--page-x) var(--sp-md);
  border-right: 1px solid var(--separator);
}
.stat:last-child { border-right: 0; }
.stat-value {
  font-size: 40px;
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.06em;
  color: var(--primary);
}
.stat-value.is-focus { color: var(--accent); }

/* ---------- layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  min-height: 0;
}

.list-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--separator);
}
.toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  padding: var(--sp-md) var(--page-x);
  border-bottom: 2px solid var(--separator);
}

/* ---------- thread list (rows 60px+, canvas hover, ink marker on selected) ---------- */
.thread-list {
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 240px;
  max-height: calc(100vh - 340px);
  overflow-y: auto;
}
.thread-list > li { border-bottom: 1px solid var(--separator); }
.thread {
  display: block;
  width: 100%;
  min-height: var(--h-row);
  padding: 14px var(--page-x) 14px 15px;
  border: 0;
  border-left: 3px solid transparent;
  background: var(--surface);
  color: var(--primary);
  text-align: left;
  transition: background var(--dur-micro) var(--ease-default);
}
.thread:hover { background: var(--canvas); }
.thread[aria-current="true"] { background: var(--canvas); border-left-color: var(--primary); }

.thread-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.thread-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.thread-name {
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-time { font-size: 12px; color: var(--primary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.thread-snippet {
  font-size: 14px;
  line-height: 1.5;
  color: var(--primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.thread-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-sm); font-size: 12px; color: var(--secondary); }

/* chips: square, label-caps, neutral gray fill; status shown by dot plus word */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 20px;
  padding: 0 8px;
  background: var(--gray);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.105em;
  text-transform: uppercase;
  white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; flex: none; border-radius: var(--radius-full); background: var(--secondary); }
.chip-open .dot { background: var(--success-fill); }

.spinner {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid var(--separator);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.note {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--sp-lg) var(--page-x);
  color: var(--secondary);
  font-size: 14px;
}

/* error notice: error border + error label, text states what to do */
.notice {
  margin: var(--sp-md) var(--page-x);
  padding: 12px 14px;
  border: 1px solid var(--error);
  background: var(--surface);
  color: var(--primary);
  font-size: 14px;
  line-height: 1.5;
}
.notice strong { display: block; margin-bottom: 2px; color: var(--error); font-weight: 600; }

/* ---------- detail pane ---------- */
.detail {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: var(--page-y) var(--page-x);
}
.empty {
  margin: auto;
  max-width: 440px;
  padding: var(--sp-xl);
  background: var(--surface);
  border: 1px solid var(--pale);
}
.empty h3 { margin-bottom: var(--sp-sm); }
.empty p { color: var(--secondary); }

.conversation {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--separator);
}
.conv-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-md);
  padding: var(--sp-md) var(--sp-lg);
  border-bottom: 2px solid var(--separator);
}
.conv-head h2 { margin-bottom: 6px; overflow-wrap: anywhere; }
.conv-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--sp-sm); }

.messages {
  list-style: none;
  margin: 0;
  padding: var(--sp-lg);
  min-height: 280px;
  max-height: calc(100vh - 300px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}
.msg { max-width: 72%; display: flex; flex-direction: column; gap: 6px; }
.msg-in { align-self: flex-start; }
.msg-out { align-self: flex-end; }
.msg-meta { font-size: 12px; color: var(--secondary); }
.msg-bubble {
  padding: 12px 14px;
  border: 1px solid var(--separator);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-out .msg-bubble { background: var(--gray); border-color: var(--gray); }
.msg-empty { color: var(--secondary); }
mark { background: var(--pale); color: var(--primary); padding: 0 2px; }

/* ---------- sign-in page (same look as the outbound sign-in) ---------- */
.login { display: flex; justify-content: center; padding: 64px var(--page-x); }
.login-page .topbar { border-bottom: 2px solid var(--separator); }
.login-card {
  width: 100%;
  max-width: 356px;
  display: grid;
  gap: var(--sp-md);
  align-content: start;
  padding: var(--sp-xl);
  background: var(--surface);
  border: 1px solid var(--separator);
}
.login-title {
  margin: 0 0 var(--sp-sm);
  padding-bottom: var(--sp-md);
  border-bottom: 2px solid var(--separator);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.045em;
}
.login-error { min-height: 18px; margin: 0; font-size: 12px; line-height: 1.45; color: var(--error); } /* reserved space */
.login-error.is-info { color: var(--primary); }
.login-card .btn { width: 100%; }
.login-note { margin: 0; font-size: 12px; line-height: 1.45; color: var(--secondary); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  /* stacked layout: height follows content, so the list is never squeezed to zero */
  html, body { height: auto; }
  .layout { flex: none; grid-template-columns: minmax(0, 1fr); }
  .list-pane { flex: none; }
  .list-pane { border-right: 0; border-bottom: 2px solid var(--separator); }
  .thread-list { min-height: 0; max-height: 45vh; }
  .messages { max-height: none; }
  .msg { max-width: 88%; }
}

@media (max-width: 640px) {
  .product { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n + 2) { border-bottom: 1px solid var(--separator); }
  .stat-value { font-size: 32px; }
  .detail { padding: var(--sp-md); }
  .conv-head { flex-direction: column; }
  .conv-actions { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- reply in chat ---------- */
.reply { display: grid; gap: var(--sp-sm); padding: var(--sp-md) var(--page-x); border-top: 1px solid var(--separator); background: var(--surface); }
.reply textarea.input { min-height: 72px; height: auto; padding: 10px 12px; resize: vertical; font-family: var(--font); }
.reply-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-sm); }
.reply-foot .meta { margin-right: auto; }
.reply-status { margin: 0; font-size: 12px; color: var(--secondary); flex-basis: 100%; }
.reply-status.is-ok { color: var(--success); }
.reply-status.is-error { color: var(--error); }

.reply-emails { margin: 0; display: flex; flex-wrap: wrap; gap: var(--sp-sm); align-items: baseline; font-size: 12px; }
