/* HR Operations Agent — matches growth-ai-agent portfolio aesthetic.
   White bg, dark text, muted #6b6b7b, accent #1a1a2e.
   Inter for body, Playfair Display for display.
*/

:root {
  --bg: #ffffff;
  --text: #1a1a2e;
  --muted: #6b6b7b;
  --accent: #1a1a2e;
  --border: #e5e5ea;
  --bubble-user: #1a1a2e;
  --bubble-user-text: #ffffff;
  --bubble-agent: #f5f5f7;
  --code-bg: #f5f5f7;
  --error: #b00020;
  --good: #0a7d34;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

.section-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 600;
  font-size: 22px;
  margin: 0 0 16px;
}

/* -------- Back links -------- */
.back-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 32px;
  font-size: 14px;
}

.back-links a {
  color: var(--muted);
  text-decoration: none;
  width: fit-content;
}

.back-links a:hover {
  color: var(--accent);
}

/* -------- Header -------- */
header h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: 40px;
  margin: 0 0 12px;
  letter-spacing: -0.5px;
}

.tagline {
  color: var(--muted);
  max-width: 700px;
  margin: 0 0 24px;
}

/* Coverage badge row */
.coverage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 40px;
  font-size: 13px;
}

.coverage-label {
  color: var(--muted);
  margin-right: 4px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bubble-agent);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

.badge.muted {
  color: var(--muted);
  background: transparent;
  border-style: dashed;
}

/* -------- Chat -------- */
#chat {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  background: var(--bg);
}

#history {
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: min(60vh, 560px);
  min-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px; /* breathing room next to scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Webkit scrollbar polish */
#history::-webkit-scrollbar {
  width: 8px;
}
#history::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
#history::-webkit-scrollbar-thumb:hover {
  background: #c8c8d0;
}

#history:empty::before {
  content: "Your conversation will appear here.";
  color: var(--muted);
  font-style: italic;
  margin: auto;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message.user .bubble {
  background: var(--bubble-user);
  color: var(--bubble-user-text);
  align-self: flex-end;
  border-radius: 18px 18px 4px 18px;
}

.message.agent .bubble {
  background: var(--bubble-agent);
  color: var(--text);
  align-self: flex-start;
  border-radius: 18px 18px 18px 4px;
}

.bubble {
  max-width: 90%;
  padding: 12px 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 15px;
}

.bubble strong { font-weight: 600; }
.bubble em { font-style: italic; }
.bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, "Menlo", monospace;
  font-size: 13.5px;
}

.bubble.streaming::after {
  content: "▍";
  color: var(--muted);
  animation: blink 1s steps(2, start) infinite;
  margin-left: 2px;
}

.bubble.streaming:empty {
  background: transparent;
  padding: 4px 0;
}

@keyframes blink {
  to { visibility: hidden; }
}

/* -------- Agent pills (which servers were invoked) -------- */
.agent-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.agent-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(26, 26, 46, 0.06);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Per-agent colors so recruiters can visually parse which servers fired. */
.agent-pill.jurisdiction {
  background: rgba(37, 99, 235, 0.10);
  color: #1d4ed8;
}
.agent-pill.hris {
  background: rgba(16, 185, 129, 0.10);
  color: #047857;
}
.agent-pill.policy {
  background: rgba(124, 58, 237, 0.10);
  color: #6d28d9;
}

.agent-pill.deferred {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
}

/* -------- Tool-call status pills (streaming) -------- */
.tool-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.tool-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bubble-agent);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, "Menlo", monospace;
  color: var(--muted);
}

.tool-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.tool-pill.running .dot {
  background: #f59e0b;
  animation: pulse 1.2s ease-in-out infinite;
}

.tool-pill.done {
  background: rgba(10, 125, 52, 0.08);
  color: var(--good);
}

.tool-pill.done .dot { background: var(--good); }

.tool-pill.error {
  background: rgba(176, 0, 32, 0.08);
  color: var(--error);
}

.tool-pill.error .dot { background: var(--error); }

.tool-pill .tool-name {
  color: var(--text);
  font-weight: 500;
}

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* -------- Per-message cost footer -------- */
.cost-footer {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, "Menlo", monospace;
  letter-spacing: 0.3px;
}

/* -------- Composer -------- */
#composer {
  display: flex;
  gap: 8px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

#question {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
}

#question:focus {
  outline: none;
  border-color: var(--accent);
}

#send {
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

#send:hover { opacity: 0.9; }
#send:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* -------- Suggestions -------- */
#suggestions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.suggest-label {
  color: var(--muted);
  font-size: 13px;
  margin-right: 4px;
}

.suggest {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  max-width: 380px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggest:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* -------- Resolver chip (write-tool gating in progress) -------- */
.tool-pill.resolver {
  background: rgba(146, 64, 14, 0.06);
  color: #92400e;
  border: 1px dashed rgba(146, 64, 14, 0.25);
}
.tool-pill.resolver .dot {
  background: #92400e;
}

/* -------- Escalation card -------- */
.escalation-card {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 14px 16px 12px;
  background: #fafafa;
  margin-bottom: 4px;
  font-size: 14px;
}

.escalation-card.risk-low    { border-left-color: #6b7280; }
.escalation-card.risk-medium { border-left-color: #d97706; background: #fffbeb; }
.escalation-card.risk-high   { border-left-color: var(--error); background: rgba(176, 0, 32, 0.04); }

.escalation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.escalation-badge {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.escalation-risk {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}
.escalation-risk.risk-low    { background: rgba(107, 114, 128, 0.12); color: #4b5563; }
.escalation-risk.risk-medium { background: rgba(217, 119, 6, 0.12);  color: #92400e; }
.escalation-risk.risk-high   { background: rgba(176, 0, 32, 0.10);   color: var(--error); }

.escalation-action {
  font-style: italic;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}

.escalation-fields {
  margin: 0;
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 14px;
}
.escalation-fields dt {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding-top: 2px;
}
.escalation-fields dd {
  margin: 0;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
}

/* -------- Error -------- */
.error {
  color: var(--error);
  border-left: 3px solid var(--error);
  padding: 8px 12px;
  background: rgba(176, 0, 32, 0.05);
  border-radius: 4px;
  font-size: 14px;
}

/* -------- Loading thinking dots -------- */
.thinking {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-style: italic;
  font-size: 14px;
}

.thinking .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 1.4s ease-in-out infinite;
}

.thinking .dot:nth-child(2) { animation-delay: 0.2s; }
.thinking .dot:nth-child(3) { animation-delay: 0.4s; }

/* -------- Footer -------- */
footer {
  margin-top: 32px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

footer a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

footer a:hover { border-color: var(--accent); }

footer code {
  background: var(--bubble-agent);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* -------- Session stats (sticky bar above composer) -------- */
#session-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding: 8px 14px;
  background: var(--bubble-agent);
  border-radius: 8px;
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, "Menlo", monospace;
  color: var(--muted);
}
#session-stats .session-stats-label {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}
#session-stats .session-stats-value {
  color: var(--text);
}

/* -------- Mobile pass -------- */
@media (max-width: 640px) {
  main {
    padding: 28px 16px 64px;
  }
  header h1 {
    font-size: 32px;
  }
  #chat {
    padding: 16px;
    border-radius: 12px;
  }
  .escalation-fields {
    grid-template-columns: 1fr;
    gap: 4px 0;
  }
  .escalation-fields dt {
    padding-top: 8px;
  }
  .escalation-fields dt:first-child {
    padding-top: 0;
  }
  .escalation-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .suggest {
    max-width: 100%;
    white-space: normal;
  }
  #suggestions {
    flex-direction: column;
    align-items: stretch;
  }
  #composer {
    flex-direction: column;
  }
  #send {
    width: 100%;
  }
  #session-stats {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}
