/* ============================================================
   Helikona — Agent chat rail
   The layout and interaction vocabulary every Helikona agent
   rail already agreed on independently (helikona-client's
   portal/admin rails, helikona-marketing's marketing rail) —
   codified here rather than invented, so a new rail (starting
   with pardot-mcp-client's MCAE Agent) gets it for free instead
   of hand-copying a third time.

   Depends on tokens.css — import that first, including the
   --radius-* tokens.

   Shipped unlayered, like buttons.css. Under Tailwind, wrap the
   import in `layer(components)` or `.hk-chat-*` outranks every
   utility class site-wide:

     @import "@helikona/brand/chat.css" layer(components);

   See docs/building-an-agent-panel.md for the full wire-up and
   the reasoning behind each rule below.
   ============================================================ */

.hk-chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  /* Deliberately --leaf-pale, not --surface — the panel is a different
     plane from page content, not a card sitting on it. */
  background: var(--leaf-pale);
}

.hk-chat-header {
  border-bottom: 1px solid var(--border);
}

.hk-chat-scroll {
  display: flex;
  flex-direction: column;
  /* Must beat ChatMarkdown's block gap (1rem) — the space between two
     turns has to read as bigger than the space between two paragraphs
     inside one reply. */
  gap: 1.5rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* The user's message gets a bubble; the assistant's does not — the
   reply is the page, not a chat log entry. */
.hk-chat-user {
  align-self: flex-end;
  max-width: 85%;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 14px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
}

.hk-chat-assistant {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
}

/* Tool-call chips. Only five states exist and only .is-success may read
   as past tense — a chip reporting a cancelled call in the past tense
   ("Sent the email") tells someone their CRM changed when it didn't. */
.hk-chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  border-radius: var(--radius-chip);
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.hk-chat-chip.is-failed {
  color: var(--rust-mid);
}
.hk-chat-chip.is-declined {
  font-style: italic;
}

.hk-chat-composer {
  border-radius: var(--radius-field);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  /* Centered, not flex-end — the icon buttons (44px), the send button
     (36px) and a single line of textarea text are three different
     heights, and center is the only one of the three that puts all of
     their midpoints at the same y regardless of that difference. */
  align-items: center;
  gap: 8px;
  padding: 8px;
}
.hk-chat-composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  /* 16px so iOS Safari doesn't zoom the page on focus; drops to the
     tighter 14px once there's room for it not to matter. */
  font-size: 16px;
  line-height: 1.5;
}
@media (min-width: 1024px) {
  .hk-chat-composer textarea {
    font-size: 14px;
  }
}

.hk-chat-send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  background: var(--leaf-light);
  color: var(--deep-jungle);
}

.hk-chat-icon-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
}
.hk-chat-icon-btn[data-active="true"] {
  color: var(--rust-mid);
}
@media (min-width: 1024px) {
  .hk-chat-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 7px;
  }
}

.hk-chat-approval {
  border-radius: var(--radius-card);
  border: 1px solid var(--rust-mid);
  background: var(--surface);
  padding: 12px 14px;
}
.hk-chat-approval .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 600;
  color: var(--rust-mid);
}

/* The flag affordance under every assistant reply. An icon, not a label —
   "Flag this reply" in words under every single answer reads as a running
   commentary on replies that were fine. Meaning lives in title/aria-label. */
.hk-chat-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  /* Negative margin so the 44px hit box doesn't push the glyph itself out
     of alignment with the reply's left edge above it. */
  margin-left: -10px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  opacity: 0.6;
}
@media (hover: hover) {
  .hk-chat-flag:hover {
    opacity: 1;
  }
}
