/* Chat widget — reuses the site's existing design tokens from style.css (--bg, --accent, etc.) */

.chat-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  height: 52px;
  padding: 0 20px 0 18px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  z-index: 200;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}
.chat-fab:hover, .chat-fab:focus-visible { background: var(--accent-strong); transform: translateY(-1px); }
.chat-fab .icon { width: 22px; height: 22px; flex-shrink: 0; }
.chat-fab.is-hidden {
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .chat-fab { transition: none; }
}

.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 380px;
  max-width: 100vw;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 199;
}
.chat-panel.is-open { transform: translateX(0); }

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-panel-header h2 {
  margin: 0;
  font-size: 1rem;
}
.chat-panel-header p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.chat-panel-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.chat-panel-close:hover, .chat-panel-close:focus-visible { background: var(--bg-alt); color: var(--text); }
.chat-panel-close .icon { width: 18px; height: 18px; }

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

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
}
.chat-bubble-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-contrast);
}

.chat-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg-alt);
  border: 1px solid var(--border);
}
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: chat-typing-bounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing 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; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-typing span { animation: none; }
}

.chat-panel-form {
  display: flex;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-panel-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.92rem;
  background: var(--bg);
  color: var(--text);
  max-height: 100px;
}
.chat-panel-form textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chat-panel-form button {
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  width: 42px;
  flex-shrink: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.chat-panel-form button:hover:not(:disabled),
.chat-panel-form button:focus-visible:not(:disabled) { background: var(--accent-strong); }
.chat-panel-form button:disabled { opacity: 0.5; cursor: default; }
.chat-panel-form .icon { width: 18px; height: 18px; }

@media (max-width: 760px) {
  .chat-panel { width: 100vw; }
  .chat-fab { right: 16px; bottom: 16px; }
}
