/* Support-chat widget — new primitives (message list/bubbles/typing indicator/input row), no
   equivalent exists elsewhere on this site. Reuses the same design tokens as styles.css (--bg,
   --bg-elevated, --text, --accent, --border, --radius) rather than inventing its own palette.
   Loaded only on pages with a chat widget (support.html, portal/dashboard.html). */

/* support.html's own title section — reuses .hero (and its decorative gradient backdrop) rather
   than a bare heading, but with the long subhead/eyebrow dropped and padding cut well below
   .hero's own default (5rem/4rem), since a one-word title doesn't need that much air around it. */
.hero.support-hero {
  padding: 1rem 0 1rem;
}

.support-chat-section {
  border-top: none;
  padding: 0.5rem 0 3rem;
}

.chat-widget {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
  max-width: 720px;
  margin: 0 auto;
  box-shadow: 0 1px 3px rgba(var(--shadow-color), 0.08);
}

.chat-message-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  max-height: 640px;
  min-height: 320px;
  overflow-y: auto;
}

.chat-message {
  max-width: 80%;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-message.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-ink);
  border-bottom-right-radius: 2px;
}

.chat-message.assistant {
  align-self: flex-start;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
}

.chat-message p {
  margin: 0 0 0.5rem;
}

.chat-message ul,
.chat-message ol {
  margin: 0.25rem 0 0.5rem;
  padding-left: 1.25rem;
}

.chat-message li {
  margin-bottom: 0.25rem;
}

.chat-message p:last-child,
.chat-message ul:last-child,
.chat-message ol:last-child,
.chat-message li:last-child {
  margin-bottom: 0;
}

.chat-message code {
  background: color-mix(in srgb, var(--text) 12%, transparent);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.chat-typing-indicator {
  align-self: flex-start;
  display: flex;
  gap: 0.3rem;
  padding: 0.65rem 0.9rem;
}

.chat-typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: chat-typing-bounce 1.2s infinite ease-in-out;
}

.chat-typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.chat-input-row textarea {
  flex: 1;
  resize: none;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  max-height: 120px;
}

.chat-input-row textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chat-input-row .btn {
  flex-shrink: 0;
  align-self: flex-end;
}

.chat-escalate-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.chat-escalate-row .btn.secondary {
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
}

.chat-ticket-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.chat-ticket-heading {
  margin: 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.chat-ticket-form input[type="text"],
.chat-ticket-form textarea {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

.chat-ticket-form input[type="text"]:focus-visible,
.chat-ticket-form textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chat-ticket-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.chat-closed-note {
  padding: 1rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (prefers-reduced-motion: reduce) {
  .chat-typing-indicator span { animation: none; opacity: 0.8; }
}
