/* =========================================================
   AifoBeta Chatbot Widget Styles
   ========================================================= */

/* --- Floating Button --- */
#chat-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(99,102,241,0.5), 0 0 0 0 rgba(99,102,241,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.3s;
  animation: chat-pulse 3s ease-in-out infinite;
}

@keyframes chat-pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(99,102,241,0.5), 0 0 0 0 rgba(99,102,241,0.3); }
  50% { box-shadow: 0 8px 32px rgba(99,102,241,0.5), 0 0 0 12px rgba(99,102,241,0); }
}

#chat-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(99,102,241,0.65);
}

#chat-trigger.open {
  transform: scale(0.9) rotate(15deg);
}

.chat-trigger-icon {
  font-size: 26px;
  transition: all 0.25s;
  display: block;
}

.chat-trigger-close {
  display: none;
  font-size: 22px;
  font-weight: 300;
  transition: all 0.25s;
}

#chat-trigger.open .chat-trigger-icon { display: none; }
#chat-trigger.open .chat-trigger-close { display: block; }

/* Notification badge */
.chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #EF4444;
  border-radius: 50%;
  border: 2px solid var(--bg-0, #05050A);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: badge-pop 0.3s 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: 104px;
  right: 28px;
  z-index: 8999;
  width: 380px;
  max-height: 580px;
  display: flex;
  flex-direction: column;
  background: #0A0A14;
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04);
  overflow: hidden;
  transform: scale(0.85) translateY(20px);
  transform-origin: bottom right;
  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;
}

/* Header */
.chat-header {
  background: linear-gradient(135deg, #1A1A30 0%, #12122A 100%);
  border-bottom: 1px solid rgba(99,102,241,0.2);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  position: relative;
}

.chat-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #10B981;
  border-radius: 50%;
  border: 2px solid #0A0A14;
}

.chat-header-info { flex: 1; }

.chat-header-name {
  font-size: 15px;
  font-weight: 700;
  color: #F0F2FF;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}

.chat-header-status {
  font-size: 12px;
  color: #10B981;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #10B981;
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.chat-header-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: none;
  color: rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-header-close:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(99,102,241,0.3);
  border-radius: 2px;
}

/* Message bubbles */
.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msg-slide-in 0.3s cubic-bezier(0.16,1,0.3,1) forwards;
  opacity: 0;
}

@keyframes msg-slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.bot { justify-content: flex-start; }
.chat-msg.user { justify-content: flex-end; }

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.chat-bubble {
  max-width: 260px;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.bot .chat-bubble {
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.2);
  color: #E2E8F0;
  border-bottom-left-radius: 4px;
}

.user .chat-bubble {
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(99,102,241,0.3);
}

/* Typing indicator */
.chat-typing {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msg-slide-in 0.3s forwards;
  opacity: 0;
}

.typing-bubble {
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 13px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: rgba(99,102,241,0.7);
  border-radius: 50%;
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

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

/* Quick replies */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 16px;
  animation: msg-slide-in 0.3s 0.2s forwards;
  opacity: 0;
}

.quick-reply-btn {
  padding: 8px 14px;
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 20px;
  color: #A78BFA;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.quick-reply-btn:hover {
  background: rgba(99,102,241,0.2);
  border-color: rgba(99,102,241,0.5);
  color: #C4B5FD;
  transform: translateY(-2px);
}

/* Input area */
.chat-input-area {
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 10px 14px;
  color: #F0F2FF;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 100px;
  min-height: 40px;
  transition: border-color 0.2s;
  line-height: 1.4;
}

.chat-input:focus {
  border-color: rgba(99,102,241,0.5);
}

.chat-input::placeholder {
  color: rgba(255,255,255,0.25);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.chat-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(99,102,241,0.45);
}

.chat-send-btn:active { transform: scale(0.97); }

.chat-input-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.2);
  text-align: center;
  margin-top: 8px;
}

/* CTA button inside chat */
.chat-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 4px 16px rgba(99,102,241,0.35);
  font-family: inherit;
  text-decoration: none;
}

.chat-cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99,102,241,0.5);
}

/* --- Mobile responsive --- */
@media (max-width: 480px) {
  #chat-window {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 88px;
    max-height: 70vh;
  }

  #chat-trigger {
    right: 16px;
    bottom: 16px;
  }
}
