/* ═══════════════════════════════════════════════════════════
   AMIABLE GROUP — AI Chat Widget Styles
   ═══════════════════════════════════════════════════════════ */

/* ── Widget Launcher ────────────────────────────────────── */
.chat-launcher {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-3);
}

.chat-launcher__tooltip {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  transition: all var(--transition-base);
  pointer-events: none;
}

.chat-launcher:hover .chat-launcher__tooltip,
.chat-launcher__tooltip.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.chat-launcher__btn {
  width: 60px;
  height: 60px;
  background: var(--gradient-brand);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(196,151,58,0.4), 0 0 0 0 rgba(196,151,58,0.4);
  transition: all var(--transition-base);
  position: relative;
  animation: chat-pulse 3s ease-in-out infinite 2s;
}

.chat-launcher__btn:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 40px rgba(196,151,58,0.5);
}

.chat-launcher__btn svg {
  width: 26px;
  height: 26px;
  color: white;
  transition: all var(--transition-base);
}

.chat-launcher__btn .icon-close { display: none; }
.chat-launcher.open .chat-launcher__btn .icon-chat { display: none; }
.chat-launcher.open .chat-launcher__btn .icon-close { display: block; }

@keyframes chat-pulse {
  0%, 100% { box-shadow: 0 4px 24px rgba(196,151,58,0.4), 0 0 0 0 rgba(196,151,58,0.4); }
  50% { box-shadow: 0 4px 24px rgba(196,151,58,0.4), 0 0 0 12px rgba(196,151,58,0); }
}

/* ── Notification Badge ─────────────────────────────────── */
.chat-launcher__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid var(--color-obsidian);
  font-size: 0.65rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes badge-pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* ── Chat Window ────────────────────────────────────────── */
.chat-window {
  position: fixed;
  bottom: 90px;
  right: var(--space-6);
  width: 380px;
  height: 580px;
  max-height: calc(100vh - 120px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card), 0 20px 80px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  z-index: 999;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* ── Chat Header ────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-header__avatar {
  width: 40px;
  height: 40px;
  background: var(--gradient-brand);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  position: relative;
}

.chat-header__status {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border: 2px solid var(--color-surface-2);
  border-radius: 50%;
}

.chat-header__info { flex: 1; min-width: 0; }

.chat-header__name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
}

.chat-header__sub {
  font-size: 0.75rem;
  color: #22c55e;
  font-weight: 500;
}

.chat-header__actions {
  display: flex;
  gap: var(--space-1);
}

.chat-header__action {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  font-size: 1rem;
}

.chat-header__action:hover {
  background: var(--color-surface-3);
  color: var(--color-text-primary);
}

/* ── Messages Area ──────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--color-surface-3); border-radius: 99px; }

/* ── Message Bubbles ────────────────────────────────────── */
.chat-message {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  animation: message-in 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes message-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message--user {
  flex-direction: row-reverse;
}

.chat-message__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  font-weight: 700;
}

.chat-message--user .chat-message__avatar {
  background: var(--color-surface-3);
  color: var(--color-text-muted);
}

.chat-message__bubble {
  max-width: 75%;
  padding: var(--space-3) var(--space-4);
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.chat-message--ai .chat-message__bubble {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  border-bottom-left-radius: 4px;
}

.chat-message--user .chat-message__bubble {
  background: var(--gradient-brand);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message__bubble p { color: inherit; margin: 0; }
.chat-message__bubble p + p { margin-top: var(--space-2); }

.chat-message__bubble strong { color: inherit; }

.chat-message__bubble a {
  color: inherit;
  text-decoration: underline;
  opacity: 0.85;
}

.chat-message__time {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  margin-top: var(--space-1);
  padding: 0 var(--space-1);
}

.chat-message--user .chat-message__time { text-align: right; }

/* ── Typing Indicator ───────────────────────────────────── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.chat-typing__dot {
  width: 6px;
  height: 6px;
  background: var(--color-text-muted);
  border-radius: 50%;
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.chat-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Quick Replies ──────────────────────────────────────── */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0 var(--space-5) var(--space-3);
}

.chat-quick-reply {
  padding: 0.375rem 0.875rem;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  color: var(--color-text-accent);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.chat-quick-reply:hover {
  background: rgba(196,151,58,0.1);
  border-color: rgba(196,151,58,0.4);
  color: var(--color-text-primary);
}

/* ── Input Area ─────────────────────────────────────────── */
.chat-input-area {
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-2);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--transition-fast);
}

.chat-input-wrapper:focus-within {
  border-color: var(--color-electric);
  box-shadow: 0 0 0 3px rgba(196,151,58,0.15);
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 0.9rem;
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  min-height: 24px;
}

.chat-input::placeholder { color: var(--color-text-muted); }

.chat-send {
  width: 34px;
  height: 34px;
  background: var(--gradient-brand);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  color: white;
}

.chat-send:hover { transform: scale(1.05); }
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.chat-send svg { width: 16px; height: 16px; }

.chat-footer-note {
  text-align: center;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

/* ── System Message ─────────────────────────────────────── */
.chat-system-msg {
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  margin: var(--space-2) auto;
  max-width: 260px;
}

/* ── Rate Limit Message ─────────────────────────────────── */
.chat-rate-limit {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: 0.8125rem;
  color: #fbbf24;
  text-align: center;
  margin: var(--space-2) var(--space-5);
}

/* ── Mobile Chat ────────────────────────────────────────── */
@media (max-width: 480px) {
  .chat-window {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 84px;
    height: calc(100vh - 120px);
    border-radius: var(--radius-lg);
  }

  .chat-launcher {
    right: 12px;
    bottom: 12px;
  }
}
