/* Shared chat widget styles. Used by site/index.html (landing chatbot) and
 * the per-page docs chatbot rendered by scripts/build-docs.ts. Depends on the
 * --bg / --bg-surface / --bg-card / --text / --text-dim / --accent /
 * --accent-hover / --border CSS variables defined in the host page. */

.chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition:
    transform 0.15s,
    background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-btn:hover {
  transform: scale(1.08);
  background: var(--accent-hover);
}

.chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  width: min(400px, calc(100vw - 3rem));
  height: min(500px, calc(100vh - 6rem));
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.chat-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
}
.chat-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
}
.chat-close:hover {
  background: var(--bg-card);
  color: var(--text);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chat-msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}
.chat-msg-bot {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text);
}
.chat-msg-bot a {
  color: var(--accent);
  text-decoration: underline;
}
.chat-msg-bot code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  background: rgba(127, 127, 127, 0.18);
  padding: 1px 5px;
  border-radius: 4px;
}
.chat-msg-bot pre {
  background: rgba(127, 127, 127, 0.12);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 6px 0;
  overflow-x: auto;
  white-space: pre;
}
.chat-msg-bot pre code {
  background: transparent;
  padding: 0;
  font-size: 0.82em;
  line-height: 1.45;
}

.chat-starters {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-starters p {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.chat-starter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.chat-starter-btn:hover {
  background: var(--bg);
}

.chat-loading {
  align-self: flex-start;
  background: var(--bg-card);
  padding: 8px 12px;
  border-radius: 10px;
  display: flex;
  gap: 4px;
}
.chat-loading span {
  width: 6px;
  height: 6px;
  background: var(--text-dim);
  border-radius: 50%;
  animation: chat-dot 1.2s ease-in-out infinite;
}
.chat-loading span:nth-child(2) {
  animation-delay: 0.2s;
}
.chat-loading span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes chat-dot {
  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.chat-error {
  font-size: 0.8rem;
  color: #f85149;
  padding: 4px 0;
}

.chat-footer {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
}
.chat-form {
  display: flex;
  gap: 8px;
}
.chat-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
.chat-input:focus {
  border-color: var(--accent);
}
.chat-input::placeholder {
  color: var(--text-dim);
}
.chat-send {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  padding: 0 12px;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.chat-send:hover {
  background: var(--accent-hover);
}
.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.chat-powered {
  text-align: center;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 6px;
}
