/* ===== AI Chat Widget ===== */
.ai-chat-toggle {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0A2540 0%, #1a3a5c 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(10,37,64,0.4);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: all 0.3s ease;
}
.ai-chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(10,37,64,0.5);
}
.ai-chat-toggle .pulse-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #00D4FF;
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.ai-chat-window {
  position: fixed;
  bottom: 160px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 200px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}
.ai-chat-window.active { display: flex; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-chat-header {
  background: linear-gradient(135deg, #0A2540 0%, #1a3a5c 100%);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ai-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0,212,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.ai-chat-title { font-size: 15px; font-weight: 600; }
.ai-chat-subtitle { font-size: 11px; opacity: 0.7; }
.ai-chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  padding: 4px 8px;
}
.ai-chat-close:hover { opacity: 1; }

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f7f8fa;
}
.ai-chat-messages::-webkit-scrollbar { width: 6px; }
.ai-chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.chat-msg {
  display: flex;
  margin-bottom: 12px;
  animation: msgIn 0.3s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-msg.ai { justify-content: flex-start; }
.chat-msg.user { justify-content: flex-end; }
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  word-wrap: break-word;
}
.chat-msg.ai .chat-bubble {
  background: #fff;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.chat-msg.user .chat-bubble {
  background: #0A2540;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.typing-dot {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.ai-chat-input-area {
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.ai-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 13px;
  outline: none;
  resize: none;
  max-height: 80px;
  font-family: inherit;
  transition: border-color 0.2s;
}
.ai-chat-input:focus { border-color: #0A2540; }
.ai-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #0A2540;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.ai-chat-send:hover { background: #1a3a5c; }
.ai-chat-send:disabled { background: #ccc; cursor: not-allowed; }

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.quick-reply-btn {
  padding: 6px 12px;
  background: rgba(10,37,64,0.08);
  border: 1px solid rgba(10,37,64,0.2);
  border-radius: 16px;
  font-size: 12px;
  color: #0A2540;
  cursor: pointer;
  transition: all 0.2s;
}
.quick-reply-btn:hover {
  background: #0A2540;
  color: #fff;
}

.lead-card {
  background: linear-gradient(135deg, #f0f7ff 0%, #e6f7ff 100%);
  border: 1px solid #b3e5fc;
  border-radius: 12px;
  padding: 14px;
  margin: 8px 0;
}
.lead-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #0A2540;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.lead-card-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(0,0,0,0.06);
}
.lead-card-row:last-child { border-bottom: none; }
.lead-card-label { color: #888; }
.lead-card-value { color: #333; font-weight: 500; text-align: right; max-width: 60%; }
.lead-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.lead-badge.hot { background: #ffebee; color: #c62828; }
.lead-badge.warm { background: #fff3e0; color: #e65100; }
.lead-badge.cold { background: #e3f2fd; color: #1565c0; }

.whatsapp-cta {
  display: block;
  width: 100%;
  padding: 12px;
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  text-align: center;
  text-decoration: none;
  transition: all 0.2s;
}
.whatsapp-cta:hover { background: #128C7E; }

.ai-chat-footer {
  padding: 8px 16px;
  background: #fafafa;
  border-top: 1px solid #eee;
  font-size: 10px;
  color: #aaa;
  text-align: center;
}

@media (max-width: 480px) {
  .ai-chat-window {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 100px;
    height: calc(100vh - 140px);
    max-height: none;
  }
  .ai-chat-toggle { bottom: 80px; right: 16px; width: 48px; height: 48px; font-size: 20px; }
}
