@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

:root {
  --ai-chat-primary: #4f77ff;
  --ai-chat-primary-hover: #3d5fcc;
  --border-radius: 10px;
}

#ai-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: flex-end;
}

#ai-chat-toggle,
#wechat-toggle,
#back-to-top {
  background: var(--ai-chat-primary);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  padding: 12px 16px;
  min-width: 120px;
  position: relative;
}

#ai-chat-toggle:hover,
#wechat-toggle:hover,
#back-to-top:hover {
  background: var(--ai-chat-primary-hover);
  transform: translateX(-5px);
}

#ai-chat-toggle .button-text,
#wechat-toggle .button-text,
#back-to-top .button-text {
  color: white;
  font-size: 14px;
  font-weight: 500;
  margin-left: 8px;
  white-space: nowrap;
}

#wechat-toggle {
  background: #07c160;
}

#wechat-toggle:hover {
  background: #06ad56;
}

#back-to-top {
  background: #666;
}

#back-to-top:hover {
  background: #555;
}

#ai-chat-window {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 350px;
  height: 500px;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#ai-chat-header {
  background: var(--ai-chat-primary);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#ai-chat-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: white;
}

#ai-chat-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#ai-chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #f8f9fa;
}

.ai-message,
.user-message {
  margin-bottom: 16px;
  display: flex;
}

.ai-message {
  justify-content: flex-start;
}

.user-message {
  justify-content: flex-end;
}

.message-content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
}

.ai-message .message-content {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
}

.user-message .message-content {
  background: var(--ai-chat-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

#ai-chat-input-area {
  padding: 16px 20px;
  background: white;
  border-top: 1px solid #e1e5e9;
  display: flex;
  gap: 12px;
  align-items: center;
}

#ai-chat-input {
  flex: 1;
  padding: 12px 16px;
  margin: 0;
  border: 1px solid #ddd;
  border-radius: var(--border-radius);
  outline: none;
  font-size: 14px;
  color: #333;
  resize: none;
  min-height: 20px;
  max-height: 60px;
  line-height: 20px;
  font-family: inherit;
  overflow-y: auto;
}

#ai-chat-input:focus {
  border-color: var(--ai-chat-primary);
}

#ai-chat-send {
  padding: 10px 20px !important;
  background: var(--ai-chat-primary);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
  flex-shrink: 0;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 40px !important;
  line-height: 1 !important;
}

#ai-chat-send:hover {
  background: var(--ai-chat-primary-hover);
}

#ai-chat-send:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  max-width: 80%;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.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);
  }
  30% {
    transform: translateY(-10px);
  }
}

/* 微信二维码弹窗样式 */
#wechat-qr-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-content {
  background: white;
  border-radius: 12px;
  width: auto;
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.qr-header {
  background: #07c160;
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.qr-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: white;
}

#wechat-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-body {
  padding: 20px;
  text-align: center;
}

.qr-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 15px;
  display: block;
}

.qr-body p {
  margin: 0;
  color: #666;
  font-size: 14px;
}

@media (max-width: 480px) {
  #ai-chat-window {
    width: 300px;
    height: 450px;
  }

  #ai-chat-widget {
    right: 15px;
    bottom: 15px;
  }

  .qr-content {
    width: 280px;
    margin: 20px;
  }

  .qr-body img {
    width: 180px;
    height: 180px;
  }
}
