/* AI聊天助手样式 */
:root {
  --ai-primary: #00e5ff;
  --ai-secondary: #7b2ff9;
  --ai-accent: #ff2a75;
  --ai-bg: rgba(10, 10, 20, 0.85);
  --ai-text: #ffffff;
  --ai-border: 1px solid rgba(0, 229, 255, 0.3);
  --ai-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  --ai-glow: 0 0 15px rgba(0, 229, 255, 0.5), 0 0 30px rgba(0, 229, 255, 0.2);
}

/* AI助手容器 */
.ai-assistant-container {
  position: fixed;
  bottom: 80px;
  left: 20px; /* 改为左侧定位，完全避开右侧停靠栏 */
  width: 60px;
  height: 60px;
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-assistant-container.open {
  width: 350px;
  height: 500px;
  bottom: 100px;
  left: 20px; /* 保持一致的左侧距离 */
}

/* AI助手触发按钮 */
.ai-assistant-button {
  position: absolute;
  top: -30px;
  right: 0;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--ai-primary), var(--ai-secondary));
  box-shadow: var(--ai-shadow);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 1001;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-assistant-button:hover {
  transform: scale(1.05);
  box-shadow: var(--ai-glow);
}

.ai-assistant-icon {
  width: 24px;
  height: 24px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6zm0 10c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z"/></svg>');
  transition: all 0.3s ease;
}

.open .ai-assistant-icon {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6zm0 10c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z"/></svg>');
}

.ai-assistant-container.open .ai-assistant-button {
  position: absolute;
  top: -25px;
  right: 15px; /* 增加右侧距离，避免与发送按钮重叠 */
  z-index: 1002;
  display: none; /* 完全隐藏按钮，避免与发送按钮产生任何冲突 */
  opacity: 0;
  pointer-events: none;
}

/* AI聊天界面 */
.ai-chat-interface {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 350px;
  height: 500px;
  background: var(--ai-bg);
  border-radius: 15px;
  border: var(--ai-border);
  backdrop-filter: blur(10px);
  box-shadow: var(--ai-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.9);
  transform-origin: bottom right;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.open .ai-chat-interface {
  opacity: 1;
  transform: scale(1);
  pointer-events: all;
}

/* 聊天界面头部 */
.ai-chat-header {
  padding: 15px;
  background: linear-gradient(45deg, var(--ai-primary), var(--ai-secondary));
  color: var(--ai-text);
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: var(--ai-border);
}

.ai-chat-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-minimize-button {
  width: 24px;
  height: 24px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M19 13H5v-2h14v2z"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: pointer;
  opacity: 0.8;
  transition: all 0.2s ease;
}

.ai-minimize-button:hover {
  opacity: 1;
  transform: scale(1.1);
}

.ai-chat-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-chat-title-icon {
  width: 24px;
  height: 24px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79s7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58s9.14-3.47 12.65 0L21 3v7.12zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8h1.5z"/></svg>');
}

/* 聊天消息区域 */
.ai-chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.ai-message {
  max-width: 80%;
  padding: 10px 15px;
  border-radius: 18px;
  animation: message-fade-in 0.3s ease;
}

@keyframes message-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-message-user {
  align-self: flex-end;
  background: linear-gradient(45deg, var(--ai-secondary), var(--ai-accent));
  color: var(--ai-text);
  border-bottom-right-radius: 5px;
}

.ai-message-bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ai-text);
  border-bottom-left-radius: 5px;
  border: var(--ai-border);
}

/* 打字指示器 */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 15px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  max-width: 80px;
  align-self: flex-start;
}

.ai-typing-dot {
  width: 8px;
  height: 8px;
  background: var(--ai-primary);
  border-radius: 50%;
  animation: typing-dot 1.4s infinite ease-in-out;
}

.ai-typing-dot:nth-child(1) {
  animation-delay: 0s;
}

.ai-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-dot {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-5px);
  }
}

/* 输入区域 */
.ai-chat-input-container {
  padding: 15px;
  border-top: var(--ai-border);
  display: flex;
  gap: 10px;
}

.ai-chat-input {
  flex: 1;
  padding: 12px 15px;
  border-radius: 20px;
  border: var(--ai-border);
  background: rgba(255, 255, 255, 0.1);
  color: var(--ai-text);
  outline: none;
  transition: all 0.3s ease;
}

.ai-chat-input:focus {
  box-shadow: var(--ai-glow);
  border-color: var(--ai-primary);
}

.ai-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--ai-primary), var(--ai-secondary));
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1003; /* 确保发送按钮在关闭按钮之上 */
}

.ai-chat-send:hover {
  transform: scale(1.05);
  box-shadow: var(--ai-glow);
}

.ai-send-icon {
  width: 20px;
  height: 20px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* 手机设备 */
@media (max-width: 480px) {
  .ai-assistant-container {
    bottom: 75px;
    left: 10px;
  }
  
  .ai-assistant-button {
    width: 40px;
    height: 40px;
    top: -25px;
    right: 25px; /* 进一步增加右侧距离，确保在移动设备上不会与发送按钮重叠 */
  }
  
  .ai-assistant-container.open {
    width: 280px;
    height: 380px;
    bottom: 85px;
  }
  
  .ai-chat-interface {
    width: 280px;
    height: 380px;
    border-radius: 12px;
  }
  
  .ai-assistant-icon {
    width: 22px;
    height: 22px;
  }
  
  .ai-chat-header {
    padding: 8px 10px;
    font-size: 14px;
  }
  
  .ai-chat-messages {
    padding: 8px;
  }
  
  .ai-message {
    max-width: 85%;
    padding: 7px 10px;
    font-size: 13px;
    margin-bottom: 6px;
    border-radius: 10px;
  }
  
  .ai-chat-input-container {
    padding: 8px;
  }
  
  .ai-chat-input {
    padding: 7px 10px;
    font-size: 13px;
    border-radius: 15px;
  }
  
  .ai-send-button {
    width: 30px;
    height: 30px;
  }
}

/* 智能位置调整 - 确保不会挡住侧边栏 */
.ai-assistant-container.smart-position {
  transition: all 0.5s ease;
}

/* 当屏幕宽度较小时，自动调整位置 */
@media (max-width: 1200px) {
  .ai-assistant-container.open {
    transform: translateX(0);
  }
}

/* 平板和小屏幕设备 */
@media (min-width: 481px) and (max-width: 768px) {
  .ai-assistant-container {
    bottom: 100px; /* 避开底部导航 */
    left: 15px;
  }
  
  .ai-assistant-button {
    top: -25px;
    right: 25px; /* 进一步增加右侧距离，避免与发送按钮重叠 */
    width: 40px;
    height: 40px;
  }
  
  .ai-assistant-container.open {
    width: 300px;
    height: 420px;
    bottom: 110px;
  }
  
  .ai-chat-interface {
    width: 300px;
    height: 420px;
  }
  
  .ai-message {
    font-size: 14px;
    padding: 8px 12px;
    margin-bottom: 8px;
  }
  
  .ai-chat-header {
    padding: 12px;
  }
  
  .ai-chat-input {
    padding: 8px 10px;
    font-size: 14px;
  }
}

/* 确保在所有设备上AI助手不会挡住内容 */
@media (max-width: 1024px) {
  .ai-assistant-container.open {
    bottom: 120px;
  }
  
  /* 确保AI助手不会与底部停靠栏重叠 */
  .dock + .ai-assistant-container {
    bottom: 80px;
  }
  
  .dock + .ai-assistant-container.open {
    bottom: 130px;
  }
}

/* 动画效果 */
.ai-pulse {
  animation: ai-pulse 2s infinite;
}

@keyframes ai-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 229, 255, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(0, 229, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 229, 255, 0);
  }
}