/* ===== 植愈所 AI客服 小愈 ===== */

.ai-chat-fab {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 2147483647 !important;
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: auto !important;
}

/* 适配移动端底部安全区 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .ai-chat-fab {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

/* 悬浮按钮 */
.ai-chat-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4a7c59 0%, #6b9e7a 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(74, 124, 89, 0.4);
  transition: all 0.3s ease;
  position: relative;
}
.ai-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(74, 124, 89, 0.5);
}
.ai-chat-btn:active {
  transform: scale(0.95);
}
.ai-chat-btn svg {
  width: 26px;
  height: 26px;
}

/* 红点提示 */
.ai-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-weight: 600;
}

/* 引导气泡 */
.ai-chat-tooltip {
  background: #fff;
  color: #333;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  max-width: 220px;
  animation: floatBubble 3s ease-in-out infinite;
  white-space: pre-line;
}
@keyframes floatBubble {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* 聊天窗口 */
.ai-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #faf7f2;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999;
  animation: slideUp 0.3s ease;
}
.ai-chat-panel.open {
  display: flex;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 顶部标题栏 */
.ai-chat-header {
  background: linear-gradient(135deg, #4a7c59 0%, #6b9e7a 100%);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.ai-chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.ai-chat-title-wrap {
  flex: 1;
  min-width: 0;
}
.ai-chat-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}
.ai-chat-subtitle {
  font-size: 12px;
  opacity: 0.85;
}
.ai-chat-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  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-close svg {
  width: 16px;
  height: 16px;
}

/* 消息列表 */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.ai-chat-messages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 2px;
}

/* 消息气泡 */
.msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  animation: msgIn 0.3s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg p { margin: 0 0 6px 0; }
.msg p:last-child { margin-bottom: 0; }
.msg strong { font-weight: 600; }
.msg ul, .msg ol {
  margin: 6px 0;
  padding-left: 20px;
  list-style: disc;
}
.msg li { margin-bottom: 3px; }

.msg-bot {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #4a7c59 0%, #6b9e7a 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* 打字指示器 */
.typing-indicator {
  align-self: flex-start;
  background: #fff;
  padding: 12px 16px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.typing-indicator span {
  width: 7px;
  height: 7px;
  background: #aaa;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* 快捷问题 */
.quick-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
  flex-shrink: 0;
}
.quick-q {
  padding: 6px 12px;
  background: #fff;
  border: 1px solid #e0ddd5;
  border-radius: 16px;
  font-size: 12px;
  color: #4a7c59;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.quick-q:hover {
  background: #4a7c59;
  color: #fff;
  border-color: #4a7c59;
}

/* 底部输入区 */
.ai-chat-input-area {
  padding: 12px;
  background: #fff;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.ai-chat-input {
  flex: 1;
  border: 1px solid #e0ddd5;
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  font-family: inherit;
  transition: border-color 0.2s;
}
.ai-chat-input:focus {
  border-color: #4a7c59;
}
.ai-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4a7c59 0%, #6b9e7a 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.ai-chat-send:hover:not(:disabled) {
  transform: scale(1.08);
}
.ai-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ai-chat-send svg {
  width: 18px;
  height: 18px;
}

/* 底部提示 */
.ai-chat-footer {
  padding: 6px 16px 8px;
  text-align: center;
  font-size: 11px;
  color: #999;
  background: #fff;
  flex-shrink: 0;
}
.ai-chat-footer a {
  color: #4a7c59;
  text-decoration: none;
  cursor: pointer;
}
.ai-chat-footer a:hover {
  text-decoration: underline;
}

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
  .ai-chat-fab {
    right: 16px;
    bottom: 20px;
  }
  .ai-chat-btn {
    width: 52px;
    height: 52px;
  }
  .ai-chat-btn svg {
    width: 24px;
    height: 24px;
  }

  .ai-chat-tooltip {
    display: none;
  }

  .ai-chat-panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 85vh;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    animation: slideUpMobile 0.3s ease;
  }
  @keyframes slideUpMobile {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .ai-chat-header {
    padding: 14px 16px;
  }
  .ai-chat-messages {
    padding: 14px;
  }
  .msg {
    max-width: 85%;
    font-size: 15px;
  }
}
