/* ═══════════════════════════════════════════
   CHAT WIDGET
═══════════════════════════════════════════ */

/* Bubble button */
.chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 58px;
  height: 58px;
  background: var(--sage);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(91,140,90,0.45);
  z-index: 9000;
  transition: transform 0.2s, background 0.2s;
  border: none;
}
.chat-bubble:hover {
  background: var(--sage-light);
  transform: scale(1.08);
}
.chat-bubble svg {
  width: 26px;
  height: 26px;
  fill: white;
}
.chat-bubble .chat-close-icon { display: none; }
.chat-bubble.open .chat-icon { display: none; }
.chat-bubble.open .chat-close-icon { display: block; }

/* Notification dot */
.chat-notif {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #E05C4B;
  border-radius: 50%;
  border: 2px solid white;
  display: none;
}
.chat-notif.show { display: block; }

/* Window */
.chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 360px;
  max-height: 520px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(44,95,93,0.22);
  display: flex;
  flex-direction: column;
  z-index: 8999;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.97);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid var(--rule);
}
.chat-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header */
.chat-header {
  background: var(--primary);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.chat-avatar {
  width: 38px;
  height: 38px;
  background: var(--sage);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.chat-header-info { flex: 1; }
.chat-header-name {
  font-family: var(--tight);
  font-size: 14px;
  font-weight: 700;
  color: white;
  line-height: 1.2;
}
.chat-header-status {
  font-family: var(--tight);
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.chat-status-dot {
  width: 7px;
  height: 7px;
  background: #5BE094;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }

/* Message bubbles */
.chat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 88%;
}
.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-msg-avatar {
  width: 26px;
  height: 26px;
  background: var(--sage);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.chat-msg.user .chat-msg-avatar { background: var(--sand-dark); }
.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--charcoal);
  background: var(--sand);
  border-bottom-left-radius: 4px;
}
.chat-msg.user .chat-msg-bubble {
  background: var(--primary);
  color: white;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 88%;
}
.chat-typing-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  background: var(--sand);
  display: flex;
  gap: 4px;
  align-items: center;
}
.chat-typing-dot {
  width: 7px;
  height: 7px;
  background: var(--sage-pale);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}
.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  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: 6px;
  padding: 0 16px 12px;
}
.chat-quick-btn {
  background: white;
  border: 1.5px solid var(--rule);
  border-radius: 20px;
  padding: 6px 13px;
  font-family: var(--tight);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chat-quick-btn:hover {
  background: var(--sage);
  color: white;
  border-color: var(--sage);
}

/* Input area */
.chat-input-area {
  border-top: 1px solid var(--rule);
  padding: 12px 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  background: white;
}
.chat-input {
  flex: 1;
  border: 1.5px solid var(--rule);
  border-radius: 24px;
  padding: 9px 16px;
  font-family: var(--body);
  font-size: 13px;
  color: var(--charcoal);
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  line-height: 1.4;
  max-height: 80px;
  overflow-y: auto;
}
.chat-input:focus { border-color: var(--sage); }
.chat-input::placeholder { color: var(--light); }
.chat-send {
  width: 36px;
  height: 36px;
  background: var(--sage);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.chat-send:hover { background: var(--sage-light); transform: scale(1.08); }
.chat-send:disabled { background: var(--rule); cursor: not-allowed; transform: none; }
.chat-send svg { width: 16px; height: 16px; fill: white; }

/* Lead captured confirmation */
.chat-lead-confirm {
  background: rgba(91,140,90,0.1);
  border: 1px solid rgba(91,140,90,0.3);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--sage);
  text-align: center;
  margin: 0 16px 8px;
  font-family: var(--tight);
  font-weight: 600;
}

/* Mobile */
@media (max-width: 480px) {
  .chat-window {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 75vh;
    border-radius: 16px 16px 0 0;
  }
  .chat-bubble {
    right: 16px;
    bottom: 16px;
  }
}
