/* ============ 在线客服聊天窗 ============ */

.chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9990;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1A3A5C, #2E6BA6);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(26, 58, 92, 0.35);
  transition: transform 0.25s var(--ease-standard, ease), box-shadow 0.25s ease;
  overflow: visible;
  animation: launcher-float 2.2s ease-in-out infinite;
}
.chat-launcher:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(26, 58, 92, 0.55);
  animation-play-state: paused;
}
.chat-launcher:active {
  transform: scale(0.92);
}
/* 图标本体：hover 时轻微摇摆 + 呼吸 */
.chat-launcher svg {
  width: 28px;
  height: 28px;
  position: relative;
  z-index: 2;
  animation: icon-breathe 1.8s ease-in-out infinite;
}
.chat-launcher:hover svg {
  animation: icon-wiggle 0.5s ease-in-out;
}

/* 悬浮浮动（幅度加大） */
@keyframes launcher-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
/* 图标呼吸（缩放幅度加大） */
@keyframes icon-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
/* hover 摇摆 */
@keyframes icon-wiggle {
  0% { transform: rotate(0); }
  25% { transform: rotate(-16deg); }
  50% { transform: rotate(14deg); }
  75% { transform: rotate(-8deg); }
  100% { transform: rotate(0); }
}

/* 双层脉冲光环（错峰扩散，更大更亮） */
.chat-launcher .pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(124, 199, 232, 0.8);
  animation: chat-pulse 1.8s ease-out infinite;
  pointer-events: none;
}
.chat-launcher .pulse-2 {
  animation-delay: 0.9s;
  border-color: rgba(124, 199, 232, 0.5);
}
@keyframes chat-pulse {
  0% { transform: scale(1); opacity: 1; }
  70% { opacity: 0.3; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* 气泡内上浮的小点（更大更密） */
.chat-launcher .bubble-dot {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  z-index: 1;
  animation: bubble-rise 2s ease-in infinite;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.9);
}
.chat-launcher .bubble-dot.d1 { left: 30%; top: 42%; animation-delay: 0s; }
.chat-launcher .bubble-dot.d2 { left: 52%; top: 32%; animation-delay: 0.6s; width: 4px; height: 4px; }
.chat-launcher .bubble-dot.d3 { left: 70%; top: 46%; animation-delay: 1.2s; width: 4px; height: 4px; }
@keyframes bubble-rise {
  0% { opacity: 0; transform: translateY(8px); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-26px); }
}

.chat-window {
  position: fixed;
  right: 24px;
  bottom: 96px;
  z-index: 9995;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(16, 42, 66, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.28s var(--ease-standard, ease), transform 0.28s var(--ease-standard, ease);
}
.chat-window.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* 头部 */
.chat-header {
  background: linear-gradient(135deg, #1A3A5C, #2E6BA6);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}
.chat-avatar .online-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4ade80;
  border: 2px solid #2E6BA6;
}
.chat-avatar svg { width: 22px; height: 22px; }
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info .name { font-weight: 600; font-size: 15px; line-height: 1.3; }
.chat-header-info .status { font-size: 12px; opacity: 0.85; }
.chat-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s;
}
.chat-close:hover { background: rgba(255, 255, 255, 0.15); }
.chat-close svg { width: 20px; height: 20px; }

/* 消息区 */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f5f8fb;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  animation: msg-in 0.3s var(--ease-standard, ease);
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.chat-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: #1a2a3a;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(16, 42, 66, 0.08);
}
.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #1A3A5C, #2E6BA6);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg .quick-replies {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chat-msg .quick-btn {
  background: #eef4fa;
  color: #1A3A5C;
  border: 1px solid #d5e3f0;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.chat-msg .quick-btn:hover {
  background: #1A3A5C;
  color: #fff;
  border-color: #1A3A5C;
}

/* 打字指示 */
.chat-typing { display: flex; gap: 4px; padding: 4px 2px; }
.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a9bccd;
  animation: typing 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-4px); opacity: 1; }
}

/* 输入区 */
.chat-input-bar {
  flex-shrink: 0;
  border-top: 1px solid #e5ecf3;
  padding: 12px;
  display: flex;
  gap: 8px;
  background: #fff;
}
.chat-input-bar input {
  flex: 1;
  border: 1px solid #d5e3f0;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.chat-input-bar input:focus {
  border-color: #2E6BA6;
  box-shadow: 0 0 0 3px rgba(46, 107, 166, 0.12);
}
.chat-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1A3A5C, #2E6BA6);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chat-send:hover { transform: scale(1.06); box-shadow: 0 4px 12px rgba(26, 58, 92, 0.3); }
.chat-send svg { width: 20px; height: 20px; }

/* 线索收集表单（嵌入聊天窗） */
.chat-lead-form {
  background: #fff;
  border: 1px solid #e5ecf3;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
.chat-lead-form .lead-title {
  font-size: 13px;
  font-weight: 600;
  color: #1A3A5C;
}
.chat-lead-form input,
.chat-lead-form select,
.chat-lead-form textarea {
  border: 1px solid #d5e3f0;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fbfdff;
}
.chat-lead-form input:focus,
.chat-lead-form select:focus,
.chat-lead-form textarea:focus {
  border-color: #2E6BA6;
  box-shadow: 0 0 0 3px rgba(46, 107, 166, 0.12);
}
.chat-lead-form textarea { resize: none; height: 64px; }
.chat-lead-form .lead-submit {
  background: linear-gradient(135deg, #1A3A5C, #2E6BA6);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}
.chat-lead-form .lead-submit:hover { opacity: 0.92; transform: translateY(-1px); }
.chat-lead-form .lead-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* 移动端 */
@media (max-width: 640px) {
  .chat-window {
    right: 12px;
    bottom: 84px;
    left: 12px;
    width: auto;
    height: 520px;
  }
  .chat-launcher { right: 16px; bottom: 16px; }
}

/* 无障碍：减少动效 */
@media (prefers-reduced-motion: reduce) {
  .chat-launcher,
  .chat-launcher svg,
  .chat-launcher .pulse,
  .chat-launcher .bubble-dot {
    animation: none !important;
  }
}
