/*
 * Chat widget styles (chat-rag.md Phase 1), shared by the /chat/ page and the
 * homepage launcher + full-screen overlay. Built on the :root design tokens
 * defined in base.html (--card-background, --border-color, --radius-*, ...).
 *
 * Two layout modes for the same _chat_widget.html markup:
 *   page mode    — the document scrolls; the composer is sticky at the
 *                  viewport bottom (.chat-page wraps the widget).
 *   overlay mode — a fixed full-screen dialog; .chat-scroll is its own
 *                  scroll container and the composer is pinned by flexbox.
 */

/* ---------- widget core ---------- */

.chat-widget {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-scroll {
  flex: 1 0 auto;
}

.chat-transcript {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  min-height: 200px;
  margin-bottom: 1rem;
}

.chat-empty-state {
  color: var(--text-muted);
  font-size: 0.9375rem;
  text-align: center;
  padding: 2rem 1rem;
}

.chat-empty-state p {
  margin-bottom: 1rem;
}

/* Example-prompt chips: the primary "what do I type here?" affordance. */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.75rem;
}

.chat-suggestion {
  font: inherit;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.375rem 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.chat-suggestion:hover,
.chat-suggestion:focus-visible {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background: var(--hover-bg);
  outline: none;
}

.chat-bubble {
  max-width: 85%;
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-sm);
  line-height: 1.5;
  font-size: 0.9375rem;
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--text-primary);
  color: #fff;
  border-bottom-right-radius: var(--radius-sm);
}

.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-sm);
  width: 85%;
}

.chat-bubble-typing {
  color: var(--text-muted);
  font-style: italic;
}

.chat-bubble-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chat-bubble-text a,
.chat-handle-link {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  text-underline-offset: 2px;
}

.chat-bubble-text a:hover {
  text-decoration-color: currentColor;
}

.chat-matches {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.625rem;
}

.chat-match-card {
  background: var(--hover-bg);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.75rem;
}

.chat-match-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}

a.chat-match-name-link {
  color: var(--text-primary);
  text-decoration: none;
}

a.chat-match-name-link:hover {
  text-decoration: underline;
}

.chat-match-description {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.125rem;
}

.chat-match-attribution {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.chat-match-attribution a {
  color: var(--text-secondary);
  font-weight: 600;
  text-decoration: none;
}

.chat-match-attribution a:hover {
  text-decoration: underline;
}

.chat-empty-turn {
  margin-top: 0.625rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.chat-empty-turn p {
  margin-bottom: 0.375rem;
}

.chat-ask-link {
  color: var(--accent-color);
  font-weight: 600;
  text-decoration: none;
}

.chat-ask-link:hover {
  text-decoration: underline;
}

.chat-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: var(--radius-md);
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  margin-bottom: 0.875rem;
}

.chat-error a {
  color: #b91c1c;
  font-weight: 600;
}

.chat-composer {
  display: flex;
  gap: 0.625rem;
  align-items: flex-end;
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: var(--background-color);
  padding: 0.5rem 0 1rem;
}

.chat-input {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  font-family: inherit;
  resize: none;
  background: var(--card-background);
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---------- zero-follow hint banner ---------- */
/* A lightweight strip above the (always-present) composer -- growth-plan.md
 * §5.2 #3: zero-follow users get a real composer, not an onboarding wall.
 * "Browse"/"Post a request" stay as secondary text-link CTAs, not buttons,
 * so the composer below reads as the primary action. */

.chat-zero-follow-banner {
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 0.875rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.chat-zero-follow-banner p {
  margin-bottom: 0.5rem;
}

.chat-zero-follow-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.chat-zero-follow-actions a {
  color: var(--accent-color);
  font-weight: 600;
  text-decoration: none;
}

.chat-zero-follow-actions a:hover {
  text-decoration: underline;
}

/* ---------- /chat/ page mode ---------- */

.chat-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 4.5rem);
}

.chat-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}

.chat-subtitle {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.9375rem;
}

/* ---------- homepage launcher ---------- */

.chat-launcher-wrap {
  max-width: 720px;
  margin: 0 auto 2.25rem;
}

.chat-launcher {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.5rem 0.5rem 0.5rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.chat-launcher:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.chat-launcher-icon {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  color: var(--accent-color);
}

.chat-launcher-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text-primary);
  padding: 0.375rem 0;
}

.chat-launcher-input::placeholder {
  color: var(--text-muted);
}

.chat-launcher-input:focus {
  outline: none;
}

.chat-launcher-cta {
  flex: none;
  border: none;
  cursor: pointer;
  background: var(--text-primary);
  color: #fff;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.5625rem 1.125rem;
  transition: opacity 0.15s ease;
}

.chat-launcher-cta:hover {
  opacity: 0.85;
}

@media (prefers-reduced-motion: reduce) {
  .chat-launcher,
  .chat-suggestion {
    transition: none;
  }
}

.chat-scope-community {
  color: var(--text-muted);
  font-weight: 400;
}
