/* ==================== AI 客服 Chat Widget 样式 (优化版) ==================== */

/* 悬浮按钮 (改用品牌红) */
.ai-chat-bubble {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  width: 60px; height: 60px;
  background: linear-gradient(135deg, #e11d48, #ec4899);
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(225, 29, 72, 0.4);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: none;
}
.ai-chat-bubble:hover {
  transform: scale(1.05) translateY(-5px);
  box-shadow: 0 12px 28px rgba(225, 29, 72, 0.5);
}
.ai-chat-bubble svg { width: 32px; height: 32px; color: #fff; fill: currentColor;}

/* 新消息脉冲动画 */
@keyframes ai-pulse {
  0% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.6); }
  70% { box-shadow: 0 0 0 15px rgba(225, 29, 72, 0); }
  100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); }
}
.ai-chat-bubble.unread { animation: ai-pulse 2s infinite; }

/* 聊天窗口 */
.ai-chat-window {
  position: fixed; bottom: 100px; right: 24px; z-index: 9998;
  width: 380px; max-width: calc(100vw - 32px); height: 560px;
  max-height: calc(100vh - 140px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.05);
  display: flex; flex-direction: column;
  transform: translateY(20px) scale(0.95);
  opacity: 0; pointer-events: none;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow: hidden;
  border: 1px solid #f3f4f6;
}
.ai-chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1; pointer-events: auto;
}

/* 头部 (拟人化) */
.ai-chat-header {
  background: linear-gradient(135deg, #e11d48, #be123c);
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  color: #fff; flex-shrink: 0;
}
.ai-chat-header .header-left { display: flex; align-items: center; gap: 12px; }
.ai-chat-avatar {
  width: 44px; height: 44px;
  background: #fff; border-radius: 50%; padding: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.ai-chat-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover;}
.ai-chat-header h3 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: 0.5px;}
.ai-chat-header .status { font-size: 12px; opacity: 0.9; margin-top: 2px; display: flex; align-items: center; gap: 4px;}
.ai-chat-header .status::before { content: ''; display: block; width: 6px; height: 6px; background: #4ade80; border-radius: 50%; box-shadow: 0 0 4px #4ade80;}
.ai-chat-close {
  background: rgba(255,255,255,0.1); border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.ai-chat-close:hover { background: rgba(255,255,255,0.25); }

/* 消息列表 */
.ai-chat-messages {
  flex: 1; overflow-y: auto; padding: 20px 16px;
  background: #f8fafc; display: flex; flex-direction: column; gap: 16px;
}
.ai-chat-messages::-webkit-scrollbar { width: 6px; }
.ai-chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* 消息时间戳 */
.msg-time { text-align: center; font-size: 11px; color: #94a3b8; margin-bottom: -4px; }

/* 消息气泡 */
.ai-msg { display: flex; gap: 10px; animation: msg-in 0.3s ease forwards; opacity: 0; transform: translateY(10px); }
@keyframes msg-in { to { opacity: 1; transform: translateY(0); } }
.ai-msg.bot { justify-content: flex-start; }
.ai-msg.user { justify-content: flex-end; }

.ai-msg .avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.ai-msg.bot .avatar { background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="50" fill="%23ffe4e6"/><path d="M50 20a18 18 0 1 0 0 36 18 18 0 0 0 0-36zm0 40c-15.5 0-28 10-28 22v3h56v-3c0-12-12.5-22-28-22z" fill="%23e11d48"/></svg>') no-repeat center/cover; }
.ai-msg.user .avatar { background: #e2e8f0; order: 2; display: flex; align-items: center; justify-content: center; color: #64748b; font-size: 14px;}

.ai-msg .bubble {
  max-width: 80%; padding: 12px 16px; border-radius: 16px;
  font-size: 14px; line-height: 1.6; word-break: break-word; white-space: pre-wrap;
}
.ai-msg.bot .bubble { background: #fff; color: #334155; border-top-left-radius: 4px; box-shadow: 0 2px 5px rgba(0,0,0,0.02); border: 1px solid #f1f5f9;}
.ai-msg.user .bubble { background: #e11d48; color: #fff; border-top-right-radius: 4px; box-shadow: 0 2px 5px rgba(225, 29, 72, 0.2);}

/* 正在输入动画 */
.ai-msg.typing .bubble { padding: 14px 18px; }
.ai-msg.typing .dots { display: flex; gap: 5px; align-items: center; height: 10px;}
.ai-msg.typing .dots span { width: 6px; height: 6px; background: #cbd5e1; border-radius: 50%; animation: dot-bounce 1.4s infinite ease-in-out; }
.ai-msg.typing .dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-msg.typing .dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes dot-bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); background: #e11d48; } }

/* 内嵌留资表单卡片 */
.ai-lead-card {
  background: #fff; border: 1px solid #ffe4e6; border-radius: 12px; padding: 16px; width: 240px;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.05); margin-top: 8px;
}
.ai-lead-card h4 { margin: 0 0 12px 0; font-size: 14px; color: #1e293b; text-align: center;}
.ai-lead-card input {
  width: 100%; padding: 10px 12px; margin-bottom: 10px; border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 13px; outline: none; transition: border 0.2s; box-sizing: border-box;
}
.ai-lead-card input:focus { border-color: #e11d48; }
.ai-lead-card button {
  width: 100%; background: #e11d48; color: #fff; border: none; padding: 10px; border-radius: 8px;
  font-size: 13px; font-weight: bold; cursor: pointer; transition: background 0.2s;
}
.ai-lead-card button:hover { background: #be123c; }
.ai-lead-card button:disabled { background: #fda4af; cursor: not-allowed; }

/* 快捷问题 & 功能栏 */
.ai-quick-qs {
  display: flex; gap: 8px; padding: 10px 16px;
  background: #fff; border-top: 1px solid #f1f5f9; flex-shrink: 0;
  overflow-x: auto; white-space: nowrap;
}
.ai-quick-qs::-webkit-scrollbar { height: 0px; }
.ai-quick-qs button {
  background: #fff; border: 1px solid #e2e8f0; color: #475569;
  padding: 6px 14px; border-radius: 20px; font-size: 12px;
  cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}
.ai-quick-qs button:hover { background: #fff1f2; color: #e11d48; border-color: #fda4af; }
.ai-quick-qs button.highlight { background: #fff1f2; color: #e11d48; border-color: #fda4af; font-weight: 500;}

/* 输入区 */
.ai-chat-input {
  display: flex; gap: 10px; padding: 12px 16px 16px;
  background: #fff; flex-shrink: 0; align-items: center;
}
.ai-chat-input input {
  flex: 1; padding: 12px 16px; border: 1px solid #e2e8f0; background: #f8fafc;
  border-radius: 24px; font-size: 14px; outline: none; transition: all 0.2s;
}
.ai-chat-input input:focus { border-color: #e11d48; background: #fff; box-shadow: 0 0 0 3px #fff1f2;}
.ai-chat-input button {
  background: #e11d48; border: none; color: #fff; width: 44px; height: 44px;
  border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s, background 0.2s; flex-shrink: 0;
}
.ai-chat-input button svg { width: 20px; height: 20px; transform: translateX(-1px) translateY(1px); }
.ai-chat-input button:hover { transform: scale(1.05); background: #be123c; }

/* 移动端适配 */
@media (max-width: 480px) {
  .ai-chat-window {
    width: 100%; max-width: 100%; height: 100%; max-height: 100%; bottom: 0; right: 0; border-radius: 0;
  }
  .ai-chat-bubble { bottom: 16px; right: 16px; width: 54px; height: 54px; }
}