/* ========== AI 智能选型 Widget ========== */

/* 浮动气泡按钮 */
.ai-bubble {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00d4ff 0%, #1a8cff 100%);
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4), 0 0 0 0 rgba(0, 212, 255, 0.5);
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  transition: all 0.3s ease;
  animation: ai-pulse 2.5s infinite;
  user-select: none;
}

.ai-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 212, 255, 0.55);
}

.ai-bubble.active {
  animation: none;
  transform: rotate(90deg);
}

@keyframes ai-pulse {
  0% { box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4), 0 0 0 0 rgba(0, 212, 255, 0.4); }
  70% { box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4), 0 0 0 16px rgba(0, 212, 255, 0); }
  100% { box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4), 0 0 0 0 rgba(0, 212, 255, 0); }
}

/* 气泡上方文字提示 */
.ai-bubble-hint {
  position: fixed;
  bottom: 104px;
  right: 16px;
  z-index: 9998;
  background: rgba(7, 17, 31, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 212, 255, 0.25);
  color: #e0e6ed;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: all 0.3s ease;
  animation: ai-hint-bounce 3s ease-in-out infinite;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-bubble-hint::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 22px;
  width: 10px;
  height: 10px;
  background: rgba(7, 17, 31, 0.92);
  border-right: 1px solid rgba(0, 212, 255, 0.25);
  border-bottom: 1px solid rgba(0, 212, 255, 0.25);
  transform: rotate(45deg);
}
.ai-bubble-hint:hover {
  border-color: rgba(0, 212, 255, 0.5);
  color: #00d4ff;
}
.ai-bubble-hint .hint-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00d4ff;
  animation: hint-dot-blink 1.5s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes ai-hint-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes hint-dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* 对话窗口 */
.ai-chat-window {
  position: fixed;
  bottom: 108px;
  right: 32px;
  width: 420px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 160px);
  background: linear-gradient(160deg, #0a1628 0%, #0d1f3a 100%);
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 212, 255, 0.15);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s ease;
}

.ai-chat-window.show {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* 头部 */
.ai-chat-header {
  padding: 16px 20px;
  background: rgba(0, 212, 255, 0.06);
  border-bottom: 1px solid rgba(0, 212, 255, 0.12);
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-chat-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #00d4ff 0%, #1a8cff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.ai-chat-header-text {
  flex: 1;
}

.ai-chat-header-text h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.ai-chat-header-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #00d4ff;
}

.ai-chat-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: #e0e6ed;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* 消息区域 */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 212, 255, 0.3) transparent;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 212, 255, 0.2);
  border-radius: 3px;
}

/* 消息气泡 */
.ai-msg {
  max-width: 88%;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.ai-msg-bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px 16px 16px 16px;
  padding: 14px 16px;
  color: #e0e6ed;
}

.ai-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.15) 0%, rgba(26, 140, 255, 0.15) 100%);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 16px 4px 16px 16px;
  padding: 12px 16px;
  color: #fff;
}

/* Markdown 渲染 */
.ai-msg-bot h2 {
  font-size: 15px;
  font-weight: 700;
  color: #00d4ff;
  margin: 0 0 10px;
}

.ai-msg-bot h3 {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin: 12px 0 6px;
}

.ai-msg-bot p {
  margin: 4px 0;
}

.ai-msg-bot ul, .ai-msg-bot ol {
  margin: 4px 0;
  padding-left: 18px;
}

.ai-msg-bot li {
  margin: 2px 0;
}

.ai-msg-bot strong {
  color: #00d4ff;
}

.ai-msg-bot code {
  background: rgba(0, 212, 255, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}

/* 证据折叠 */
.ai-evidence {
  margin-top: 12px;
  border-top: 1px dashed rgba(0, 212, 255, 0.15);
  padding-top: 8px;
}

.ai-evidence-toggle {
  font-size: 12px;
  color: #00d4ff;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.2s;
}

.ai-evidence-toggle:hover {
  opacity: 0.8;
}

.ai-evidence-list {
  display: none;
  margin-top: 8px;
  font-size: 12px;
  color: #8a9bb0;
}

.ai-evidence-list.show {
  display: block;
}

.ai-evidence-item {
  padding: 6px 10px;
  margin: 4px 0;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  border-left: 2px solid rgba(0, 212, 255, 0.3);
}

.ai-evidence-item .src {
  color: #00d4ff;
  font-weight: 600;
}

/* 加载动画 */
.ai-typing {
  align-self: flex-start;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px 16px 16px 16px;
  display: flex;
  gap: 4px;
}

.ai-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00d4ff;
  animation: ai-bounce 1.4s infinite ease-in-out both;
}

.ai-typing span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes ai-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* 输入区域 */
.ai-chat-input-wrap {
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(0, 212, 255, 0.1);
  background: rgba(0, 0, 0, 0.15);
}

.ai-chat-suggestions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.ai-suggestion-chip {
  padding: 5px 12px;
  font-size: 12px;
  color: #00d4ff;
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.15);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.ai-suggestion-chip:hover {
  background: rgba(0, 212, 255, 0.15);
}

.ai-chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ai-chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 14px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 42px;
  max-height: 100px;
  outline: none;
  transition: border-color 0.2s;
}

.ai-chat-input::placeholder {
  color: #5a6a80;
}

.ai-chat-input:focus {
  border-color: rgba(0, 212, 255, 0.4);
}

.ai-chat-send {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #00d4ff 0%, #1a8cff 100%);
  color: #0a1628;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-chat-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(0, 212, 255, 0.3);
}

.ai-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* 响应式 */
@media (max-width: 768px) {
  .ai-bubble {
    bottom: 20px;
    right: 20px;
    width: 52px;
    height: 52px;
    font-size: 24px;
  }

  .ai-bubble-hint {
    bottom: 84px;
    right: 8px;
    font-size: 12px;
    padding: 6px 12px;
  }

  .ai-bubble-hint::after {
    right: 18px;
  }

  .ai-chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  .ai-chat-suggestions {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .ai-suggestion-chip {
    flex-shrink: 0;
  }
}
