/* ═══════════════════════════════════
   CHAT WIDGET
   ═══════════════════════════════════ */
.chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  font-family: var(--font, 'Inter', sans-serif);
}

.chat-widget__fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent, #6366f1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 2;
}
.chat-widget__fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(99, 102, 241, 0.5);
}
.chat-widget__icon-close { display: none; }
.chat-widget.open .chat-widget__icon-chat { display: none; }
.chat-widget.open .chat-widget__icon-close { display: block; }

.chat-widget__window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  max-height: 520px;
  background: var(--bg-card, #18181b);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.chat-widget.open .chat-widget__window {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.chat-widget__header {
  background: var(--accent, #6366f1);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.chat-widget__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
}
.chat-widget__name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
}
.chat-widget__status {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
}

.chat-widget__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 250px;
  max-height: 320px;
  scrollbar-width: thin;
  scrollbar-color: var(--border, rgba(255,255,255,0.06)) transparent;
}

.chat-msg {
  display: flex;
  max-width: 85%;
  animation: chatFadeIn 0.3s ease;
}
.chat-msg--user {
  align-self: flex-end;
}
.chat-msg--bot {
  align-self: flex-start;
}
.chat-msg__bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  word-wrap: break-word;
}
.chat-msg--user .chat-msg__bubble {
  background: var(--accent, #6366f1);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg--bot .chat-msg__bubble {
  background: var(--bg-alt, #111113);
  color: var(--text, #e4e4e7);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.chat-msg__typing {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
}
.chat-msg__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim, #71717a);
  animation: typingBounce 1.4s infinite ease-in-out;
}
.chat-msg__typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-msg__typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-widget__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 8px;
  flex-shrink: 0;
}
.chat-widget__suggestion {
  padding: 6px 12px;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  border-radius: 100px;
  background: transparent;
  color: var(--accent-light, #818cf8);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.chat-widget__suggestion:hover {
  background: var(--accent-glow, rgba(99, 102, 241, 0.15));
  border-color: var(--accent, #6366f1);
}

.chat-widget__input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  flex-shrink: 0;
}
.chat-widget__input input {
  flex: 1;
  background: var(--bg-alt, #111113);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text, #e4e4e7);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}
.chat-widget__input input::placeholder {
  color: var(--text-dim, #71717a);
}
.chat-widget__input input:focus {
  border-color: var(--accent, #6366f1);
}
.chat-widget__input button {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: var(--accent, #6366f1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.chat-widget__input button:hover {
  background: var(--accent-light, #818cf8);
}

/* Light theme */
[data-theme="light"] .chat-widget__window {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .chat-msg--bot .chat-msg__bubble {
  background: #f3f4f6;
  border-color: #e5e7eb;
}
[data-theme="light"] .chat-widget__input input {
  background: #f9fafb;
  border-color: #e5e7eb;
}

/* Mobile */
@media (max-width: 480px) {
  .chat-widget {
    bottom: 16px;
    right: 16px;
  }
  .chat-widget__window {
    width: calc(100vw - 32px);
    right: 0;
    max-height: 70vh;
  }
}
