/* ===== AI Chat Widget ===== */
.ai-chat-widget {
  position: fixed;
  bottom: 90px;
  right: 20px;
  z-index: 999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.ai-chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1.6rem;
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-ai 2s infinite;
}

@keyframes pulse-ai {
  0%, 100% { box-shadow: 0 4px 16px rgba(99,102,241,0.4); }
  50% { box-shadow: 0 4px 28px rgba(99,102,241,0.7); }
}

.ai-chat-toggle:hover {
  transform: scale(1.08);
}

.ai-chat-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 380px;
  height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.ai-chat-panel.open { display: flex; }

.ai-chat-header {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-chat-header .ai-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.ai-chat-header .ai-info { flex: 1; }
.ai-chat-header .ai-name { font-weight: 600; font-size: 0.95rem; }
.ai-chat-header .ai-status { font-size: 0.75rem; opacity: 0.8; }

.ai-chat-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.3rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.ai-chat-close:hover { opacity: 1; }

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f9fafb;
}

.ai-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  animation: msgSlide 0.3s ease;
}

@keyframes msgSlide {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg.bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
  color: #1f2937;
}

.ai-msg.user {
  align-self: flex-end;
  background: #6366f1;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-msg .typing { display: flex; gap: 4px; padding: 4px 0; }
.ai-msg .typing span {
  width: 6px; height: 6px; background: #9ca3af; border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}
.ai-msg .typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-msg .typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-8px); } }

.ai-chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.ai-chat-option {
  padding: 6px 14px;
  background: #fff;
  border: 1.5px solid #6366f1;
  color: #6366f1;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.2s;
}

.ai-chat-option:hover {
  background: #6366f1;
  color: #fff;
}

.ai-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
  background: #fff;
}

.ai-chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 24px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.ai-chat-input-area input:focus { border-color: #6366f1; }

.ai-chat-input-area button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #6366f1;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.ai-chat-input-area button:hover { background: #4f46e5; }
.ai-chat-input-area button:disabled { background: #c7d2fe; cursor: not-allowed; }

/* Lead form inside chat */
.ai-lead-form {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 12px;
  padding: 14px;
  margin-top: 8px;
}

.ai-lead-form label {
  display: block;
  font-size: 0.78rem;
  color: #166534;
  font-weight: 500;
  margin-bottom: 4px;
  margin-top: 8px;
}

.ai-lead-form input {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.85rem;
  outline: none;
  box-sizing: border-box;
}

.ai-lead-form input:focus { border-color: #22c55e; }

.ai-lead-form button {
  width: 100%;
  padding: 10px;
  background: #22c55e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: background 0.2s;
}

.ai-lead-form button:hover { background: #16a34a; }

@media (max-width: 480px) {
  .ai-chat-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    border-radius: 0;
  }
  .ai-chat-toggle { bottom: 80px; }
}
