/* ============================================================
   WatuChurch AI Chat Assistant — Styles
   ============================================================ */

:root {
  --ai-primary: #0d6efd;
  --ai-primary-dark: #0b5ed7;
  --ai-bg: #ffffff;
  --ai-text: #212529;
  --ai-text-muted: #6c757d;
  --ai-border: #dee2e6;
  --ai-user-bg: var(--ai-primary);
  --ai-user-text: #ffffff;
  --ai-bot-bg: #f0f2f5;
  --ai-bot-text: #212529;
  --ai-radius: 16px;
}

/* ── Floating Action Button ─────────────────────────────────── */
.ai-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ai-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  font-size: 24px;
}
.ai-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
  background: var(--ai-primary-dark);
}
.ai-chat-fab.open {
  transform: rotate(90deg) scale(1.08);
}
.ai-chat-fab .fab-icon-open,
.ai-chat-fab .fab-icon-close {
  position: absolute;
  transition: opacity 0.2s, transform 0.2s;
}
.ai-chat-fab .fab-icon-close {
  opacity: 0;
  transform: scale(0.5);
}
.ai-chat-fab.open .fab-icon-open {
  opacity: 0;
  transform: scale(0.5);
}
.ai-chat-fab.open .fab-icon-close {
  opacity: 1;
  transform: scale(1) rotate(-90deg);
}

/* ── Chat Panel ─────────────────────────────────────────────── */
.ai-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 370px;
  height: 520px;
  background: var(--ai-bg);
  border-radius: var(--ai-radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.ai-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ─────────────────────────────────────────────────── */
.ai-chat-header {
  background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-dark));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ai-chat-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.ai-chat-header-info {
  flex: 1;
}
.ai-chat-header-title {
  font-weight: 600;
  font-size: 15px;
  margin: 0;
}
.ai-chat-header-subtitle {
  font-size: 11px;
  opacity: 0.85;
  margin: 0;
}
.ai-chat-lang-btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 12px;
  transition: background 0.2s, opacity 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
  white-space: nowrap;
}
.ai-chat-lang-btn i {
  font-size: 12px;
}
.ai-chat-lang-btn:hover {
  background: rgba(255,255,255,0.35);
}
.ai-chat-header-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  opacity: 0.8;
  transition: opacity 0.2s;
  line-height: 1;
}
.ai-chat-header-close:hover {
  opacity: 1;
}

/* ── Messages Area ──────────────────────────────────────────── */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.ai-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.ai-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.ai-chat-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

/* ── Message Bubbles ────────────────────────────────────────── */
.ai-chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.ai-chat-bubble.user {
  align-self: flex-end;
  background: var(--ai-user-bg);
  color: var(--ai-user-text);
  border-bottom-right-radius: 4px;
}
.ai-chat-bubble.ai {
  align-self: flex-start;
  background: var(--ai-bot-bg);
  color: var(--ai-bot-text);
  border-bottom-left-radius: 4px;
}
.ai-chat-bubble.error {
  align-self: flex-start;
  background: #fff3cd;
  color: #856404;
  border-bottom-left-radius: 4px;
  font-size: 12.5px;
}

/* ── Typing Indicator ───────────────────────────────────────── */
.ai-chat-typing {
  align-self: flex-start;
  display: none;
  padding: 10px 16px;
  background: var(--ai-bot-bg);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.ai-chat-typing.show {
  display: flex;
  gap: 4px;
  align-items: center;
}
.ai-chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ai-text-muted);
  animation: aiTypingDot 1.2s infinite;
}
.ai-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiTypingDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* ── Welcome Message ────────────────────────────────────────── */
.ai-chat-welcome {
  text-align: center;
  padding: 12px 16px 4px;
  color: var(--ai-text-muted);
}
.ai-chat-welcome-icon {
  font-size: 32px;
  margin-bottom: 4px;
}
.ai-chat-welcome h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--ai-text);
  margin-bottom: 2px;
}
.ai-chat-welcome p {
  font-size: 12px;
  margin: 0;
}

/* ── Quick Prompt Chips ────────────────────────────────────── */
.ai-chat-prompts {
  padding: 0 4px 8px;
}
.ai-prompt-category {
  margin-bottom: 8px;
}
.ai-prompt-cat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ai-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 0 4px 4px;
}
.ai-prompt-cat-label i {
  font-size: 10px;
  margin-right: 2px;
}
.ai-prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ai-prompt-chip {
  background: var(--ai-bot-bg);
  color: var(--ai-text);
  border: 1px solid var(--ai-border);
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 11.5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.3;
  text-align: left;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-prompt-chip:hover {
  background: var(--ai-primary);
  color: #fff;
  border-color: var(--ai-primary);
}

/* ── Input Area ─────────────────────────────────────────────── */
.ai-chat-input-area {
  padding: 12px;
  border-top: 1px solid var(--ai-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: var(--ai-bg);
}
.ai-chat-input {
  flex: 1;
  border: 1px solid var(--ai-border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13.5px;
  outline: none;
  resize: none;
  max-height: 80px;
  min-height: 36px;
  line-height: 1.4;
  font-family: inherit;
  transition: border-color 0.2s;
}
.ai-chat-input:focus {
  border-color: var(--ai-primary);
}
.ai-chat-input::placeholder {
  color: #adb5bd;
}
.ai-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--ai-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
  font-size: 16px;
}
.ai-chat-send:hover {
  background: var(--ai-primary-dark);
}
.ai-chat-send:active {
  transform: scale(0.92);
}
.ai-chat-send:disabled {
  background: #adb5bd;
  cursor: not-allowed;
}

/* ── Rate Limit Notice ──────────────────────────────────────── */
.ai-chat-rate-limit {
  text-align: center;
  font-size: 11px;
  color: var(--ai-text-muted);
  padding: 4px 12px 0;
}

/* ── Theme Variations ───────────────────────────────────────── */
.ai-chat-theme-pastor {
  --ai-primary: #6610f2;
  --ai-primary-dark: #520dc2;
}
.ai-chat-theme-member {
  --ai-primary: #0d6efd;
  --ai-primary-dark: #0b5ed7;
}
.ai-chat-theme-public {
  --ai-primary: #198754;
  --ai-primary-dark: #146c43;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 576px) {
  .ai-chat-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 120px);
    bottom: 88px;
    right: 8px;
    border-radius: 12px;
  }
  .ai-chat-fab {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
    font-size: 20px;
  }
}
