/* PH Self-Service Assistant (pilot) — internal tool, neutral styling. */

:root {
  --bg: #f5f4f2;
  --surface: #ffffff;
  --ink: #23201d;
  --ink-soft: #6d675f;
  --line: #e2ded8;
  --accent: #9d2b2b;      /* muted brick — PH-adjacent, not branded */
  --accent-ink: #ffffff;
  --amber-bg: #fdf3dd;
  --amber-line: #e3b74a;
  --amber-ink: #7a5a10;
  --red-bg: #b3261e;
  --chip-bg: #f0eeea;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* Header */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.pilot-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 1px 8px;
  vertical-align: 2px;
  margin-left: 6px;
}
.persona-label {
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.persona-label select {
  font: inherit;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

/* Health banner */
.health-banner {
  background: var(--red-bg);
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 14px;
}

/* Chat area */
.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 0;
}
.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg { max-width: 85%; }

.user-msg {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 14px 14px 3px 14px;
  padding: 9px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.assistant-msg {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 3px;
  padding: 12px 16px;
}
.assistant-msg .answer-body { overflow-wrap: anywhere; }
.assistant-msg code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--chip-bg);
  border-radius: 4px;
  padding: 1px 5px;
}

/* Gap answers — distinct amber treatment */
.assistant-msg.gap {
  background: var(--amber-bg);
  border-color: var(--amber-line);
}
.gap-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--amber-ink);
  border: 1px solid var(--amber-line);
  border-radius: 999px;
  padding: 1px 9px;
  margin-bottom: 8px;
}
.assistant-msg.gap .answer-body { color: var(--amber-ink); }

/* Citations */
.citations {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.citation-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  background: var(--chip-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
  color: var(--ink);
  text-decoration: none;
  max-width: 100%;
}
a.citation-chip:hover { border-color: var(--accent); color: var(--accent); }
.citation-source {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 30ch;
}

/* Confidence + meta */
.confidence {
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-soft);
}

/* System / error messages */
.system-msg {
  align-self: center;
  font-size: 13px;
  color: var(--ink-soft);
  font-style: italic;
  text-align: center;
}
.error-msg {
  align-self: center;
  font-size: 13px;
  color: var(--red-bg);
  background: #fbeeed;
  border: 1px solid #eacfcd;
  border-radius: 8px;
  padding: 6px 14px;
  text-align: center;
}

/* Typing / loading indicator */
.typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 3px;
}
.typing .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: pulse 1.2s infinite ease-in-out;
}
.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* Composer */
.composer {
  display: flex;
  gap: 10px;
  padding: 12px 0 16px;
  border-top: 1px solid var(--line);
}
.composer input {
  flex: 1;
  font: inherit;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
.composer input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}
.composer button {
  font: inherit;
  font-weight: 600;
  padding: 10px 22px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
.composer button:disabled { opacity: 0.5; cursor: default; }

/* Stats view */
.stats-view {
  max-width: 860px;
  width: 100%;
  margin: 0 auto 12px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.stats-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.stats-head h2 { margin: 0 0 8px; font-size: 14px; }
.stats-sub { font-weight: 400; font-size: 12px; color: var(--ink-soft); }
.stats-body table { border-collapse: collapse; font-size: 13px; }
.stats-body td {
  padding: 3px 18px 3px 0;
  border-bottom: 1px solid var(--line);
}
.stats-body td:first-child { color: var(--ink-soft); }
.stats-body .num { font-family: var(--mono); }

/* Footer */
.footer {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 6px 20px 14px;
  font-size: 12px;
  color: var(--ink-soft);
}
.footer-sep { margin: 0 6px; }
.link-btn {
  font: inherit;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}
