/* =========================================================
   chatbot.css — Floating AI Chat Widget
   Dark theme aligned · Smooth animations · Mobile-friendly
   ========================================================= */

/* ── Widget Container ── */
.ege-chatbot {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (max-width: 900px) {
  .ege-chatbot { bottom: 72px; right: 12px; }
}

/* ── Toggle Button ── */
.ege-chatbot__toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent, #8b5cf6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.ege-chatbot__toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(139, 92, 246, 0.5);
}

.ege-chatbot__toggle-icon--close {
  display: none;
}

.ege-chatbot--open .ege-chatbot__toggle-icon--chat {
  display: none;
}

.ege-chatbot--open .ege-chatbot__toggle-icon--close {
  display: block;
}

/* ── Badge ── */
.ege-chatbot__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: chatBadgePulse 2s ease-in-out infinite;
}

@keyframes chatBadgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ── Chat Window ── */
.ege-chatbot__window {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 380px;
  max-height: 520px;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #1a1a24);
  border: 1px solid var(--border-glass, rgba(139, 92, 246, 0.18));
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.ege-chatbot--open .ege-chatbot__window {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

@media (max-width: 480px) {
  .ege-chatbot__window {
    width: calc(100vw - 24px);
    right: -8px;
    max-height: 70vh;
  }
}

/* ── Header ── */
.ege-chatbot__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--accent, #8b5cf6), #6d28d9);
  color: #fff;
  flex-shrink: 0;
}

.ege-chatbot__header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ege-chatbot__avatar {
  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;
}

.ege-chatbot__header-title {
  font-size: 14px;
  font-weight: 700;
}

.ege-chatbot__header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  opacity: 0.9;
}

.ege-chatbot__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.ege-chatbot__minimize {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 8px;
  color: #fff;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.ege-chatbot__minimize:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ── Messages ── */
.ege-chatbot__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 280px;
  max-height: 340px;
  background: var(--bg-body, #0e0e16);
  scrollbar-width: thin;
  scrollbar-color: var(--accent, #8b5cf6) transparent;
}

.ege-chatbot__messages::-webkit-scrollbar {
  width: 4px;
}
.ege-chatbot__messages::-webkit-scrollbar-track {
  background: transparent;
}
.ege-chatbot__messages::-webkit-scrollbar-thumb {
  background: var(--accent, #8b5cf6);
  border-radius: 4px;
}

/* ── Message Bubbles ── */
.ege-chatbot__msg {
  display: flex;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.ege-chatbot__msg--visible {
  opacity: 1;
  transform: translateY(0);
}

.ege-chatbot__msg--bot {
  justify-content: flex-start;
}

.ege-chatbot__msg--user {
  justify-content: flex-end;
}

.ege-chatbot__msg-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  position: relative;
}

.ege-chatbot__msg--bot .ege-chatbot__msg-bubble {
  background: var(--bg-card, #1a1a24);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  border-bottom-left-radius: 4px;
  color: var(--text-primary, #e8e8ef);
}

.ege-chatbot__msg--user .ege-chatbot__msg-bubble {
  background: var(--accent, #8b5cf6);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ege-chatbot__msg-text {
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

.ege-chatbot__msg-time {
  font-size: 10px;
  opacity: 0.5;
  margin-top: 4px;
  text-align: right;
}

/* ── Message Actions ── */
.ege-chatbot__msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ege-chatbot__action-btn {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-glass, rgba(139,92,246,0.18));
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ege-chatbot__action-btn--wa {
  background: #25d366;
  color: #fff;
  border-color: #25d366;
}
.ege-chatbot__action-btn--wa:hover {
  background: #1da851;
}

.ege-chatbot__action-btn--appt,
.ege-chatbot__action-btn--lead {
  background: transparent;
  color: var(--accent, #8b5cf6);
  border-color: var(--accent, #8b5cf6);
}
.ege-chatbot__action-btn--appt:hover,
.ege-chatbot__action-btn--lead:hover {
  background: var(--accent-glow, rgba(139,92,246,0.3));
}

/* ── Typing Indicator ── */
.ege-chatbot__typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: var(--bg-body, #0e0e16);
}

.ege-chatbot__typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent, #8b5cf6);
  animation: typingDot 1.4s ease-in-out infinite;
}
.ege-chatbot__typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ege-chatbot__typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* ── Input Area ── */
.ege-chatbot__input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  background: var(--bg-card, #1a1a24);
  flex-shrink: 0;
}

.ege-chatbot__input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-glass, rgba(139,92,246,0.18));
  background: var(--bg-body, #0e0e16);
  color: var(--text-primary, #e8e8ef);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.ege-chatbot__input:focus {
  border-color: var(--accent, #8b5cf6);
}

.ege-chatbot__input::placeholder {
  color: var(--text-muted, #6b6b80);
}

.ege-chatbot__send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent, #8b5cf6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ege-chatbot__send:hover {
  background: var(--accent-light, #a78bfa);
  transform: scale(1.05);
}

/* ── Quick Actions ── */
.ege-chatbot__quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-card, #1a1a24);
  border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
}

.ege-chatbot__quick-actions:empty {
  display: none;
}

.ege-chatbot__quick-btn {
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-glass, rgba(139,92,246,0.18));
  background: transparent;
  color: var(--text-secondary, #9d9db5);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.ege-chatbot__quick-btn:hover {
  border-color: var(--accent, #8b5cf6);
  color: var(--accent, #8b5cf6);
  background: var(--accent-glow, rgba(139,92,246,0.3));
}

/* ── Light Theme ── */
[data-theme="light"] .ege-chatbot__window {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .ege-chatbot__toggle {
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.25);
}

/* ── Pulse Animation (conversion trigger) ── */
@keyframes chatbot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7); }
  50%  { box-shadow: 0 0 0 16px rgba(139, 92, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

.ege-chatbot__toggle--pulse {
  animation: chatbot-pulse 1.5s ease-in-out 4;
}
