@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

:root {
  --ai-chat-primary: #022be2;
  --ai-chat-primary-hover: #7813dd;
  --ai-chat-gradient: linear-gradient(135deg, var(--ai-chat-primary) 0%, var(--ai-chat-primary-hover) 80%);
  --ai-chat-shadow: 0 20px 40px var(--ai-chat-primary);
  --ai-chat-glow: 0 0 20px var(--ai-chat-primary);
  --wechat-color: #07c160;
}

#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按钮容器 */
.ai-button-container {
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: flex-end;
}

/* AI按钮样式 width和height在smartion.cn中设置60px，其他设置40px 已在chat-widget.php动态设置*/
#ai-chat-toggle,
#wechat-toggle,
#back-to-top {
  background: white;
  border-radius: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  padding: 10px;
  width: 60px;
  height: 60px;
  position: relative;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(102, 126, 234, 0.3);
  flex-direction: column;
  text-align: center;
}

/* AI展示文本框样式 */
#ai-display-text {
  background: linear-gradient(90deg, var(--ai-chat-primary) 5%, var(--ai-chat-primary-hover) 100%);
  color: white;
  padding: 8px 30px;
  border-radius: 50px;
  font-size: 14px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin-bottom: 5px;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 300px;
  text-align: left;
  word-break: break-word;
  line-height: 1.6;
  align-self: center;
  cursor: pointer;
  transform: translateY(0);
  animation-duration: 0.5s;
  animation-fill-mode: both;
}

/* AI头部按钮样式 */
.ai-head-button {
  background: linear-gradient(45deg, #515be3 5%, #f2295b 100%) !important;
  padding: 0;
  overflow: hidden;
}

/* AI头部图标容器 */
.ai-head-icon {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* AI眼睛样式 */
.eye {
  position: absolute;
  width: 6px;
  height: 15px;
  border-radius: 6px; /* 圆形眼睛 */
  top: 15%;
  overflow: hidden;
  /* 内部渐变叠加 */
  background-image: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4) 0%, transparent 40%),
    linear-gradient(0deg, var(--ai-chat-primary) 0%, var(--ai-chat-primary-hover) 90%);
}

/* 眼睛发光动画 */
@keyframes eyeGlow {
  0% {
    box-shadow: 0 0 2px var(--ai-chat-primary);
  }
  100% {
    box-shadow: 0 0 6px var(--ai-chat-primary), 0 0 10px var(--ai-chat-primary-hover);
  }
}

/* 眼睛闪烁效果 */
@keyframes blink {
  0% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(0.1);
  }
  100% {
    transform: scaleY(1);
  }
}

.eye.blink {
  animation: blink 0.2s ease-out;
}

.left-eye {
  left: 20%;
  transform: translate(0, 0);
}

.right-eye {
  right: 20%;
  transform: translate(0, 0);
}

/* 眼睛高光效果 */
.eye::before {
  content: '';
  position: absolute;
  width: 2px;
  height: 2px;
  background: #ffffff;
  border-radius: 50%;
  top: 20%;
  left: 20%;
  opacity: 1;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
}

/* 眼睛内层高光 */
.eye::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  top: 30%;
  left: 30%;
  opacity: 0.8;
}

#ai-chat-toggle:hover {
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
  transform: translateY(-3px);
}

.ai-head-button:hover {
  transform: scale(1.2);
  box-shadow: 0 8px 25px var(--ai-chat-primary);
  background: linear-gradient(135deg, var(--ai-chat-primary) 0%, var(--ai-chat-primary-hover) 100%);
}

.ai-head-button:hover .eye {
  transform: scale(1.2);
  box-shadow: 0 0 15px var(--ai-chat-primary), 0 0 25px var(--ai-chat-primary-hover);
}

#ai-chat-toggle .button-text {
  color: white;
  font-size: 14px;
  font-weight: 600;
  margin-left: 10px;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#back-to-top {
  background: rgb(255, 255, 255, 0) !important;
  border: 2px solid rgba(102, 126, 234, 0.3) !important;
  backdrop-filter: none !important;
}

#wechat-toggle .button-text,
#back-to-top .button-text {
  color: #333;
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
  white-space: nowrap;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  line-height: 1.2;
}

#wechat-toggle {
  background: white;
}

#wechat-toggle:hover {
  box-shadow: 0 6px 20px rgba(7, 193, 96, 0.3);
  transform: translateY(-3px);
}

#back-to-top:hover {
  box-shadow: 0 6px 20px rgba(79, 119, 255, 0.3);
  transform: translateY(-3px);
}

#back-to-top {
  background: white;
}

#ai-chat-window {
  position: absolute;
  bottom: 0px;
  right: -10px;
  width: 380px;
  height: 520px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#ai-chat-header {
  background: var(--ai-chat-gradient);
  color: white;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

#ai-chat-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
  pointer-events: none;
}

#ai-chat-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.header-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

#ai-chat-clear,
#ai-chat-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

#ai-chat-close {
  font-size: 20px;
}

#ai-chat-clear:hover,
#ai-chat-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

#ai-chat-messages {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  position: relative;
}

#ai-chat-messages::-webkit-scrollbar {
  width: 6px;
}

#ai-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

#ai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(79, 119, 255, 0.3);
  border-radius: 3px;
}

.ai-message,
.user-message {
  margin-bottom: 20px;
  display: flex;
  animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-message {
  justify-content: flex-start;
}

.user-message {
  justify-content: flex-end;
}

.message-content {
  max-width: 85%;
  padding: 15px 20px;
  border-radius: 20px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ai-message .message-content {
  background: white;
  color: #2d3748;
  border-bottom-left-radius: 8px;
  border: 1px solid rgba(79, 119, 255, 0.1);
  padding: 8px 20px;
}

/* Markdown样式 */
.ai-message .message-content h1,
.ai-message .message-content h2,
.ai-message .message-content h3,
.ai-message .message-content h4,
.ai-message .message-content h5,
.ai-message .message-content h6 {
  margin: 12px 0 8px 0;
  font-weight: 600;
  color: #1a202c;
}

.ai-message .message-content p {
  margin: 8px 0;
  line-height: 1.6;
}

.ai-message .message-content ul,
.ai-message .message-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.ai-message .message-content li {
  margin: 4px 0;
}

.ai-message .message-content code {
  background: #f7fafc;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #e53e3e;
}

.ai-message .message-content pre {
  background: #f7fafc;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  border-left: 4px solid var(--ai-chat-primary);
}

.ai-message .message-content pre code {
  background: none;
  padding: 0;
  color: #2d3748;
}

.ai-message .message-content blockquote {
  border-left: 4px solid var(--ai-chat-primary);
  padding-left: 16px;
  margin: 8px 0;
  color: #4a5568;
  font-style: italic;
}

.ai-message .message-content strong {
  font-weight: 600;
  color: #1a202c;
}

.ai-message .message-content em {
  font-style: italic;
}

.ai-message .message-content a {
  color: var(--ai-chat-primary);
  text-decoration: none;
}

.ai-message .message-content a:hover {
  text-decoration: underline;
}

.user-message .message-content {
  background: var(--ai-chat-gradient);
  color: white;
  border-bottom-right-radius: 8px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#ai-chat-input-area {
  padding: 20px 24px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(79, 119, 255, 0.1);
  display: flex;
  gap: 12px;
  align-items: center;
}

#ai-chat-input {
  flex: 1;
  padding: 14px 18px;
  margin: 0;
  border: 2px solid rgba(79, 119, 255, 0.2);
  border-radius: 16px;
  outline: none;
  font-size: 14px;
  color: #2d3748;
  resize: none;
  min-height: 20px;
  max-height: 60px;
  line-height: 20px;
  font-family: inherit;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.8);
  transition: all 0.3s ease;
}

#ai-chat-input:focus {
  border-color: var(--ai-chat-primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(79, 119, 255, 0.1);
}

#ai-chat-send {
  padding: 10px 20px !important;
  background: var(--ai-chat-gradient);
  color: white;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  height: 48px !important;
  line-height: 1 !important;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79, 119, 255, 0.3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#ai-chat-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(79, 119, 255, 0.4);
}

#ai-chat-send:disabled {
  background: #e2e8f0;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 16px 20px;
  background: white;
  border-radius: 20px;
  border-bottom-left-radius: 8px;
  max-width: 80%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(79, 119, 255, 0.1);
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--ai-chat-primary);
  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);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* 微信二维码弹窗样式 */
#wechat-qr-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.qr-content {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  width: auto;
  max-width: 350px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.3);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.qr-header {
  background: linear-gradient(135deg, #07c160 0%, #00a854 100%);
  color: white;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.qr-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
  pointer-events: none;
}

.qr-header h4 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#wechat-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

#wechat-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.qr-body {
  padding: 30px;
  text-align: center;
}

.qr-body img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin-bottom: 20px;
  display: block;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.qr-body p {
  margin: 0;
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
}

/* 建议问题样式 */
.suggested-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  animation: messageSlide 0.3s ease-out;
}

.suggestion-btn {
  color: white;
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 13px;
  font-weight: 500;
  height: 32px !important;
  line-height: 1 !important;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  background: var(--ai-chat-gradient);
}

.suggestion-btn:hover {
  color: white;
  transform: translateY(-1px);
}

/* 跳动动画 */
@keyframes jump {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* 小屏幕适配 */
@media (max-width: 480px) {
  #ai-chat-window {
    width: 340px;
    height: 480px;
  }

  #ai-chat-widget {
    right: 15px;
    bottom: 15px;
    gap: 25px;
  }

  .ai-head-button {
    width: 35px;
    height: 35px;
  }

  .ai-head-button::before {
    width: 110%;
    height: 110%;
  }

  .eye {
    width: 6px;
    height: 12px;
    top: 28%;
    /* 内部渐变叠加 */
    background-image: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4) 0%, transparent 40%),
      linear-gradient(0deg, var(--ai-chat-primary) 0%, var(--ai-chat-primary-hover) 90%);
  }

  @keyframes eyeGlow {
    0% {
      box-shadow: 0 0 2px var(--ai-chat-primary);
    }
    100% {
      box-shadow: 0 0 6px var(--ai-chat-primary), 0 0 10px var(--ai-chat-primary-hover);
    }
  }

  @keyframes blink {
    0% {
      transform: scaleY(1);
    }
    50% {
      transform: scaleY(0.1);
    }
    100% {
      transform: scaleY(1);
    }
  }

  .eye::before {
    width: 1px;
    height: 1px;
    top: 15%;
    left: 15%;
  }

  .eye::after {
    width: 2px;
    height: 2px;
    top: 25%;
    left: 25%;
  }

  .ai-head-button:hover {
    transform: scale(1.15);
    box-shadow: 0 8px 25px var(--ai-chat-primary);
    background: linear-gradient(135deg, var(--ai-chat-primary) 0%, var(--ai-chat-primary-hover) 100%);
  }

  .ai-head-button:hover .eye {
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--ai-chat-primary), 0 0 25px var(--ai-chat-primary-hover);
  }

  .qr-content {
    width: 300px;
    margin: 20px;
  }

  .suggestion-btn {
    font-size: 12px;
    padding: 6px 12px;
  }
}
