/* ============ CHATBOT WIDGET ============ */

/* --- Toggle Button --- */
.chatbot-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 10000;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--violet-700), var(--violet-500));
  color: #fff;
  box-shadow: 0 6px 28px rgba(109, 40, 217, 0.4), 0 0 0 0 rgba(109, 40, 217, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  animation: chatPulse 3s ease-in-out 4s 3;
  padding: 0;
}
.chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 34px rgba(109, 40, 217, 0.5);
}
.chatbot-toggle .icon-chat,
.chatbot-toggle .icon-close {
  position: absolute;
  transition: transform 0.35s var(--ease), opacity 0.25s ease;
}
.chatbot-toggle .icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}
.chatbot-toggle.active .icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}
.chatbot-toggle.active .icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

@keyframes chatPulse {
  0%, 100% { box-shadow: 0 6px 28px rgba(109, 40, 217, 0.4), 0 0 0 0 rgba(109, 40, 217, 0.25); }
  50% { box-shadow: 0 6px 28px rgba(109, 40, 217, 0.4), 0 0 0 14px rgba(109, 40, 217, 0); }
}

/* --- Notification Badge --- */
.chatbot-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  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;
  border: 2.5px solid var(--bg);
  animation: badgePop 0.4s var(--ease);
  pointer-events: none;
}
@keyframes badgePop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* --- Chat Window --- */
.chatbot-window {
  position: fixed;
  bottom: 102px;
  right: 28px;
  z-index: 10000;
  width: 390px;
  max-height: 560px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 20px 70px rgba(46, 16, 101, 0.18), 0 0 0 1px rgba(124, 58, 237, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
.chatbot-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* --- Header --- */
.chatbot-header {
  background: linear-gradient(135deg, var(--violet-900), var(--violet-700) 80%);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.chatbot-header-text h4 {
  margin: 0;
  color: #fff;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.chatbot-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 1px;
}
.chatbot-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}
.chatbot-minimize {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.chatbot-minimize:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* --- Messages Area --- */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 300px;
  max-height: 340px;
  scroll-behavior: smooth;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(237, 233, 254, 0.5) 0%, transparent 50%),
    var(--bg);
}
.chatbot-messages::-webkit-scrollbar {
  width: 5px;
}
.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--violet-300);
  border-radius: 10px;
}

/* --- Message Bubbles --- */
.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: msgIn 0.35s var(--ease);
}
.chat-msg.bot {
  align-self: flex-start;
}
.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

@keyframes msgIn {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

.chat-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  overflow: hidden;
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.bot .chat-bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(46, 16, 101, 0.04);
}
.user .chat-bubble {
  background: linear-gradient(135deg, var(--violet-700), var(--violet-600));
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 3px 12px rgba(109, 40, 217, 0.2);
}

/* --- Typing Indicator --- */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
  align-items: center;
}
.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--violet-400, #a78bfa);
  opacity: 0.5;
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

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

/* --- Quick Replies --- */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 6px 38px;
  animation: msgIn 0.35s var(--ease);
}
.quick-reply-btn {
  background: var(--violet-50);
  color: var(--violet-700);
  border: 1.5px solid var(--violet-300);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
}
.quick-reply-btn:hover {
  background: var(--violet-100);
  border-color: var(--violet-600);
  color: var(--violet-900);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(109, 40, 217, 0.12);
}
.quick-reply-btn:active {
  transform: translateY(0);
}
.quick-reply-primary {
  background: linear-gradient(135deg, var(--violet-700), var(--violet-600));
  color: #fff;
  border-color: var(--violet-700);
  box-shadow: 0 3px 12px rgba(109, 40, 217, 0.22);
}
.quick-reply-primary:hover {
  background: linear-gradient(135deg, var(--violet-600), var(--violet-500));
  border-color: var(--violet-600);
  color: #fff;
  box-shadow: 0 5px 16px rgba(109, 40, 217, 0.3);
}

/* --- Input Area --- */
.chatbot-input-area {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  flex-shrink: 0;
}
.chatbot-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 11px 16px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chatbot-input:focus {
  border-color: var(--violet-500);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}
.chatbot-input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}
.chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--violet-700), var(--violet-500));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
  flex-shrink: 0;
}
.chatbot-send:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(109, 40, 217, 0.3);
}
.chatbot-send:active {
  transform: scale(0.96);
}
.chatbot-send svg {
  width: 18px;
  height: 18px;
}

/* --- Service Detail Cards inside Chat --- */
.chat-service-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.chat-service-item {
  background: var(--violet-50);
  border: 1px solid var(--violet-200, #ddd6fe);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.chat-service-item:hover {
  background: var(--violet-100);
  border-color: var(--violet-400, #a78bfa);
  transform: translateX(3px);
}
.chat-service-item h5 {
  margin: 0 0 3px;
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--violet-900);
}
.chat-service-item p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* --- Lead Capture Success --- */
.chat-success-card {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.1), rgba(52, 211, 153, 0.05));
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 12px;
  padding: 14px;
  margin-top: 6px;
  text-align: center;
}
.chat-success-card .success-icon {
  font-size: 28px;
  margin-bottom: 6px;
}
.chat-success-card p {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}



/* --- Responsive --- */
@media (max-width: 480px) {
  .chatbot-window {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  .chatbot-toggle {
    bottom: 18px;
    right: 18px;
    width: 56px;
    height: 56px;
  }
  .chatbot-window.open ~ .chatbot-toggle {
    display: none;
  }
}
