/* ============================================================
   小智 AI 客服组件样式
   智能制造专属知识库 + 大模型 API 接入
   ============================================================ */

/* ── 悬浮触发按钮 ─────────────────────────── */
.ai-chat-fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 60px;
  height: 72px;
  background: linear-gradient(135deg, #0a5fc4 0%, #1e40af 100%);
  border-radius: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(10, 95, 196, 0.45);
  z-index: 9998;
  transition: transform 0.25s, box-shadow 0.25s;
  border: none;
  outline: none;
}
.ai-chat-fab-label {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.06em;
  line-height: 1;
  pointer-events: none;
}
.ai-chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px rgba(10, 95, 196, 0.6);
}
.ai-chat-fab.open {
  transform: scale(1.05);
  box-shadow: 0 8px 32px rgba(10, 95, 196, 0.7);
}
.ai-chat-fab-icon {
  width: 32px;
  height: 32px;
  transition: opacity 0.2s;
}
/* 脉冲提示圈 */
.ai-chat-fab::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(10, 95, 196, 0.35);
  animation: chatFabPulse 2.5s ease-out infinite;
}
@keyframes chatFabPulse {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.7); opacity: 0; }
}
/* 未读红点 */
.ai-chat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: #e02020;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 9px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: opacity 0.2s;
}

/* ── 聊天窗体 ─────────────────────────────── */
.ai-chat-window {
  position: fixed;
  bottom: 5.5rem;
  right: 2rem;
  width: 380px;
  height: 580px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 60px rgba(10, 95, 196, 0.18), 0 2px 12px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s ease;
  transform-origin: bottom right;
}
.ai-chat-window.visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ── 标题栏 ───────────────────────────────── */
.ai-chat-header {
  background: linear-gradient(135deg, #0a5fc4 0%, #1e40af 100%);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.ai-chat-avatar {
  width: 38px;
  height: 38px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.ai-chat-title-wrap { flex: 1; }
.ai-chat-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  display: block;
  line-height: 1.2;
}
.ai-chat-status {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.15rem;
}
.ai-chat-status-dot {
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  animation: chatDotBlink 2s ease-in-out infinite;
}
@keyframes chatDotBlink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
.ai-chat-header-actions { display: flex; gap: 0.5rem; }
.ai-chat-header-btn {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.ai-chat-header-btn:hover { background: rgba(255,255,255,0.3); }

/* ── 快捷提示词区 ──────────────────────────── */
.ai-quick-hints {
  padding: 0.75rem 1rem 0;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.ai-quick-hint-chip {
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-radius: 2rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.72rem;
  color: #1e40af;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.ai-quick-hint-chip:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

/* ── 消息流区 ─────────────────────────────── */
.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  scroll-behavior: smooth;
}
.ai-chat-body::-webkit-scrollbar { width: 4px; }
.ai-chat-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

/* 消息气泡 */
.ai-msg {
  display: flex;
  gap: 0.625rem;
  align-items: flex-end;
  max-width: 92%;
}
.ai-msg.user { flex-direction: row-reverse; align-self: flex-end; }
.ai-msg.bot  { align-self: flex-start; }

.ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
.ai-msg.bot .ai-msg-avatar { background: #eff6ff; }
.ai-msg.user .ai-msg-avatar { background: #1e40af; color: #fff; }

.ai-msg-bubble {
  padding: 0.625rem 0.875rem;
  border-radius: 14px;
  font-size: 0.82rem;
  line-height: 1.65;
  word-break: break-word;
}
.ai-msg.bot .ai-msg-bubble {
  background: #f8fafc;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  border: 1px solid #e2e8f0;
}
.ai-msg.user .ai-msg-bubble {
  background: linear-gradient(135deg, #0a5fc4, #1e40af);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* 打字指示器 */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.625rem 0.875rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.ai-typing-dot {
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: chatTyping 1.2s ease-in-out infinite;
}
.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatTyping {
  0%,60%,100% { transform: translateY(0); opacity: 0.5; }
  30%          { transform: translateY(-6px); opacity: 1; }
}

/* 来源引用标签 */
.ai-msg-sources {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.ai-msg-source-tag {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 0.25rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.68rem;
  color: #3b82f6;
  cursor: pointer;
}
.ai-msg-source-tag:hover { background: #dbeafe; }

/* ── 输入区 ───────────────────────────────── */
.ai-chat-footer {
  border-top: 1px solid #e2e8f0;
  padding: 0.875rem 1rem;
  flex-shrink: 0;
  background: #fff;
}
.ai-chat-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.ai-chat-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.625rem 0.875rem;
  font-size: 0.82rem;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.2s;
  background: #f8fafc;
}
.ai-chat-input:focus { border-color: #0a5fc4; background: #fff; }
.ai-chat-input::placeholder { color: #94a3b8; }
.ai-chat-send-btn {
  width: 38px;
  height: 38px;
  background: #0a5fc4;
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.ai-chat-send-btn:hover { background: #1e40af; transform: scale(1.05); }
.ai-chat-send-btn:disabled { background: #94a3b8; cursor: not-allowed; transform: none; }
.ai-chat-footer-tip {
  margin-top: 0.4rem;
  font-size: 0.68rem;
  color: #94a3b8;
  text-align: center;
}

/* ── 移动端适配 ──────────────────────────── */
@media (max-width: 480px) {
  .ai-chat-window {
    width: calc(100vw - 1.5rem);
    height: calc(100vh - 8rem);
    right: 0.75rem;
    bottom: 5rem;
    border-radius: 16px;
  }
  .ai-chat-fab {
    bottom: 1.25rem;
    right: 1.25rem;
    width: 52px;
    height: 62px;
    border-radius: 26px;
  }
  .ai-chat-fab-label {
    font-size: 11px;
  }
}

/* ── 留咨表单 ─────────────────────────────── */
.ai-consult-bar {
  margin-top: 0.625rem;
  padding: 0.625rem 0.75rem;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  font-size: 0.75rem;
  color: #9a3412;
  line-height: 1.5;
}
.ai-consult-bar b { color: #ea580c; }
.ai-consult-form {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.ai-consult-form input {
  border: 1.5px solid #fed7aa;
  border-radius: 8px;
  padding: 0.4rem 0.625rem;
  font-size: 0.75rem;
  outline: none;
  background: #fff;
  color: #1e293b;
  transition: border-color 0.2s;
}
.ai-consult-form input:focus { border-color: #ea580c; }
.ai-consult-submit {
  background: #ea580c;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.5rem;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 0.2rem;
}
.ai-consult-submit:hover { background: #c2410c; }
.ai-consult-submit:disabled { background: #94a3b8; cursor: not-allowed; }
