/* ================================================================
   AI Assistant – Chat Widget Styles
   Follows the site's CSS-var theming (dark / light)
   ================================================================ */

/* ── Floating trigger button ───────────────────────────────────── */
.assistant-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: var(--accent, #60a5fa);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.assistant-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
.assistant-fab svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

/* ── Chat window ───────────────────────────────────────────────── */
.assistant-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9998;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: var(--bg-elevated, #111c33);
  border: 1px solid var(--border-color, rgba(148, 163, 184, 0.2));
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.assistant-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ── Header ────────────────────────────────────────────────────── */
.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-primary, #0f172a);
  border-bottom: 1px solid var(--border-color);
}
.assistant-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.assistant-header-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
}
.assistant-header-text h4 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-sans);
}
.assistant-header-text span {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.assistant-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}
.assistant-close:hover {
  color: var(--text-primary);
}

/* ── Messages area ─────────────────────────────────────────────── */
.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.assistant-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.55;
  font-family: var(--font-sans);
  word-wrap: break-word;
  white-space: pre-wrap;
}
.assistant-msg.bot {
  align-self: flex-start;
  background: var(--bg-primary);
  color: var(--text-secondary);
  border-bottom-left-radius: 4px;
}
.assistant-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Source citations */
.assistant-sources {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border-color);
  font-size: 0.72rem;
  color: var(--text-muted);
}
.assistant-sources strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.assistant-sources a {
  color: var(--accent);
  text-decoration: none;
}
.assistant-sources a:hover {
  text-decoration: underline;
}

/* Typing indicator */
.assistant-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  align-self: flex-start;
}
.assistant-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingDot 1.2s infinite ease-in-out;
}
.assistant-typing span:nth-child(2) { animation-delay: 0.15s; }
.assistant-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ── Input area ────────────────────────────────────────────────── */
.assistant-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
}
.assistant-input-area input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s;
}
.assistant-input-area input::placeholder {
  color: var(--text-muted);
}
.assistant-input-area input:focus {
  border-color: var(--accent);
}
.assistant-send {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.assistant-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.assistant-send svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ── Welcome state ─────────────────────────────────────────────── */
.assistant-welcome {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.6;
}
.assistant-welcome h5 {
  margin: 0 0 6px;
  color: var(--text-primary);
  font-size: 0.95rem;
}

/* ── Scrollbar ─────────────────────────────────────────────────── */
.assistant-messages::-webkit-scrollbar {
  width: 5px;
}
.assistant-messages::-webkit-scrollbar-track {
  background: transparent;
}
.assistant-messages::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* ── Mobile adjustments ────────────────────────────────────────── */
@media (max-width: 480px) {
  .assistant-panel {
    right: 8px;
    bottom: 88px;
    width: calc(100vw - 16px);
    height: calc(100vh - 120px);
    border-radius: 14px;
  }
  .assistant-fab {
    bottom: 18px;
    right: 18px;
    width: 52px;
    height: 52px;
  }
}
