/**
 * Chatbot UI — Quiet Intelligence Design System
 * Floating chat widget — stays bottom-right on all screen sizes
 */

/* ═══════════════════════════════════════════════════════════════
   CONTAINER
   ═══════════════════════════════════════════════════════════════ */

#gmr-chatbot {
  position: fixed;
  bottom: 24px;
  right: 24px;
  font-family: var(--font-ui, 'Inter', sans-serif);
  z-index: 9998;
}

@media (max-width: 480px) {
  #gmr-chatbot { bottom: 16px; right: 16px; }
}

/* ═══════════════════════════════════════════════════════════════
   FLOATING TOGGLE BUTTON
   ═══════════════════════════════════════════════════════════════ */

.chatbot-toggle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9999;
  /* no box-shadow — the Lottie is the visual */
}

.chatbot-toggle:hover { transform: translateY(-4px) scale(1.08); }
.chatbot-toggle:active { transform: scale(0.95); }

.chatbot-toggle.open {
  opacity: 0;
  transform: scale(0.7) rotate(15deg);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

/* Lottie inside toggle */
.chatbot-toggle__lottie {
  display: none;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.chatbot-toggle__lottie.lottie-loaded { display: block; }

/* Fallback: dot + label shown if Lottie fails */
.chatbot-toggle__dot {
  display: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-accent, #c8a45e);
  box-shadow: 0 4px 20px rgba(200, 164, 94, 0.45);
  animation: chatbot-pulse 2.4s ease infinite;
}

.chatbot-toggle__label {
  display: none;
  font-size: 0.55rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

@keyframes chatbot-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(200,164,94,0.45); }
  50%       { box-shadow: 0 4px 32px rgba(200,164,94,0.75); }
}

@media (max-width: 480px) {
  .chatbot-toggle { width: 64px; height: 64px; }
}

/* ═══════════════════════════════════════════════════════════════
   CHAT WINDOW  — always a floating card, never full-screen
   ═══════════════════════════════════════════════════════════════ */

.chatbot-window {
  position: absolute;
  bottom: 88px;
  right: 0;
  width: 380px;
  max-height: 580px;
  min-height: 0;
  background: var(--color-surface-elevated, #fafaf8);
  border: 1px solid var(--color-border, #e8e5de);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 40px rgba(0,0,0,0.14), 0 2px 12px rgba(0,0,0,0.08);
  overflow: hidden;
  z-index: 9998;
}

.chatbot-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Mobile: compact floating card — NOT full screen */
@media (max-width: 480px) {
  .chatbot-window {
    width: calc(100vw - 32px);   /* 16px margin each side */
    max-height: 70vh;             /* never taller than 70% of viewport */
    bottom: 80px;
    right: 0;
    border-radius: 16px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   CHARACTER HEADER
   ═══════════════════════════════════════════════════════════════ */

.chatbot-character {
  width: 100%;
  height: 112px;
  background: linear-gradient(140deg, #0d0d0b 0%, #1c1a17 100%);
  border-bottom: 1px solid rgba(200,164,94,0.18);
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  border-radius: 20px 20px 0 0;
}

@media (max-width: 480px) {
  .chatbot-character { border-radius: 16px 16px 0 0; }
}

/* Accent glow */
.chatbot-character::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 180px 120px at 60px 50%, rgba(200,164,94,0.1) 0%, transparent 70%);
  pointer-events: none;
}

/* Lottie avatar */
.chatbot-character__lottie {
  display: none;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  margin-left: 10px;
}
.chatbot-character__lottie.lottie-loaded { display: block; }

/* Name + status */
.chatbot-character__overlay {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
  flex: 1;
  position: relative;
  z-index: 1;
}

.chatbot-character__name {
  font-family: var(--font-editorial, 'Playfair Display', serif);
  font-size: 0.95rem;
  font-weight: 500;
  color: #fff;
  line-height: 1.2;
}

.chatbot-character__status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.01em;
}

.chatbot-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(34,197,94,0.5);
}

/* ── Close button — clean circular X ── */
.chatbot-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;          /* perfect circle */
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
  z-index: 2;
  /* Remove any inherited min-width/padding that creates oval shapes */
  min-width: 0;
  line-height: 1;
}

.chatbot-close:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
  transform: rotate(90deg);
}

.chatbot-close svg {
  display: block;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════
   MESSAGES
   ═══════════════════════════════════════════════════════════════ */

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--color-surface, #fafaf8);
  overscroll-behavior: contain;
}

.chatbot-messages::-webkit-scrollbar        { width: 3px; }
.chatbot-messages::-webkit-scrollbar-track  { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb  { background: var(--color-border, #e8e5de); border-radius: 2px; }

.chatbot-message {
  display: flex;
  animation: chatbot-slideUp 0.22s ease-out;
}
.chatbot-message.user { justify-content: flex-end; }
.chatbot-message.bot  { justify-content: flex-start; }

.message-bubble {
  max-width: 82%;
  padding: 9px 13px;
  word-wrap: break-word;
}

.chatbot-message.user .message-bubble {
  background: var(--color-ink, #0a0a0a);
  color: var(--color-surface, #fafaf8);
  border-radius: 14px 14px 4px 14px;
}

.chatbot-message.bot .message-bubble {
  background: var(--color-surface-warm, #f5f3ef);
  color: var(--color-ink, #0a0a0a);
  border: 1px solid var(--color-border, #e8e5de);
  border-radius: 4px 14px 14px 14px;
}

.message-bubble p {
  margin: 0;
  font-size: 0.83rem;
  line-height: 1.55;
  color: inherit;
}

/* Typing indicator */
.chatbot-message.typing .message-bubble {
  padding: 11px 14px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-ink-muted, #8a8680);
  animation: chatbot-typing 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes chatbot-typing {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30%           { opacity: 1;    transform: translateY(-4px); }
}

@keyframes chatbot-slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════
   INPUT ROW
   ═══════════════════════════════════════════════════════════════ */

.chatbot-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px;
  border-top: 1px solid var(--color-border, #e8e5de);
  background: var(--color-surface, #fafaf8);
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1;
  padding: 9px 13px;
  border: 1px solid var(--color-border, #e8e5de);
  border-radius: 22px;
  font-family: var(--font-ui, 'Inter', sans-serif);
  font-size: 0.83rem;
  background: var(--color-surface-warm, #f5f3ef);
  color: var(--color-ink, #0a0a0a);
  outline: none;
  transition: border-color 0.15s ease;
  /* Prevent iOS zoom on focus */
  font-size: max(0.83rem, 16px);
}

.chatbot-input::placeholder { color: var(--color-ink-muted, #8a8680); }
.chatbot-input:focus { border-color: var(--color-accent, #c8a45e); box-shadow: 0 0 0 3px rgba(200,164,94,0.1); }

.chatbot-send {
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  background: var(--color-ink, #0a0a0a);
  color: var(--color-surface, #fafaf8);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.12s;
}
.chatbot-send:hover  { opacity: 0.8; }
.chatbot-send:active { transform: scale(0.9); }

/* ═══════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════ */

.chatbot-footer {
  padding: 7px 14px;
  border-top: 1px solid var(--color-border, #e8e5de);
  background: var(--color-surface-warm, #f5f3ef);
  text-align: center;
  font-size: 0.65rem;
  color: var(--color-ink-muted, #8a8680);
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

/* ═══════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════ */

@media print { #gmr-chatbot { display: none !important; } }
