/* ============================================================
 *  AI 智能客服组件样式 · 客服小顺
 *  适用于 index.html / cases.html / shunhe-product-classification.html
 *  颜色体系沿用站点主色：--ink #0a1628 / --accent #1e6bff / --accent2 #00b8d4
 * ============================================================ */

/* ---------- 浮动触发按钮 (FAB) ---------- */
.ai-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'WorkSans', -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #0a1628;
  line-height: 1.5;
}
.ai-fab {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e6bff 0%, #00b8d4 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(30, 107, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
}
.ai-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 12px 32px rgba(30, 107, 255, 0.45);
}
.ai-fab:active { transform: scale(0.96); }
.ai-fab-icon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ai-icon-close { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.ai-widget[data-state="open"] .ai-icon-chat { opacity: 0; transform: rotate(90deg) scale(0.6); }
.ai-widget[data-state="open"] .ai-icon-close { opacity: 1; transform: rotate(0) scale(1); }
.ai-fab-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e6bff 0%, #00b8d4 100%);
  opacity: 0.45;
  animation: aiPulse 2.2s ease-out infinite;
  z-index: -1;
}
.ai-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff7a45;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 8px;
  border: 2px solid #fff;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(255, 122, 69, 0.4);
}
@keyframes aiPulse {
  0%   { transform: scale(1);   opacity: 0.45; }
  80%  { transform: scale(1.6); opacity: 0;    }
  100% { transform: scale(1.6); opacity: 0;    }
}

/* ---------- 聊天面板 ---------- */
.ai-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 110px);
  background: #ffffff;
  border-radius: 18px;
  box-shadow:
    0 24px 60px rgba(10, 22, 40, 0.22),
    0 0 1px rgba(10, 22, 40, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.ai-widget[data-state="open"] .ai-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- 头部 ---------- */
.ai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0a1628 0%, #112a52 60%, #1e3a7a 100%);
  color: #ffffff;
  flex-shrink: 0;
}
.ai-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e6bff 0%, #00b8d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(30, 107, 255, 0.3);
}
.ai-avatar::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #00d68f;
  border: 2px solid #112a52;
}
.ai-header-info { flex: 1; min-width: 0; }
.ai-header-info h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}
.ai-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1e6bff 0%, #00b8d4 100%);
  color: #fff;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.ai-header-info p {
  font-size: 11.5px;
  opacity: 0.85;
  margin: 3px 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ai-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00d68f;
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(0, 214, 143, 0.25);
  animation: aiBlink 2s ease-in-out infinite;
}
@keyframes aiBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.ai-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  padding: 0;
}
.ai-close:hover { background: rgba(255, 255, 255, 0.2); }

/* ---------- 对话区 ---------- */
.ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f4f6fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.ai-body::-webkit-scrollbar { width: 6px; }
.ai-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.ai-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: aiMsgIn 0.25s ease;
}
@keyframes aiMsgIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0);    }
}
.ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e6bff 0%, #00b8d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.ai-msg-content {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
}
.ai-msg-content p { margin: 0 0 6px; }
.ai-msg-content p:last-child { margin-bottom: 0; }
.ai-msg-content strong { color: #1e6bff; font-weight: 600; }
.ai-msg-content em { color: #00b8d4; font-style: normal; font-weight: 500; }
.ai-msg-content code {
  background: rgba(30, 107, 255, 0.08);
  color: #1e6bff;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'JetBrainsMono', 'Consolas', monospace;
  font-size: 12.5px;
}
.ai-msg-content ul, .ai-msg-content ol {
  margin: 4px 0 4px 18px;
  padding: 0;
}
.ai-msg-content li { margin: 2px 0; }
.ai-msg-content a {
  color: #1e6bff;
  text-decoration: none;
  border-bottom: 1px dashed rgba(30, 107, 255, 0.4);
}
.ai-msg-content a:hover { border-bottom-style: solid; }
.ai-msg-bot { align-self: flex-start; }
.ai-msg-bot .ai-msg-content {
  background: #fff;
  color: #0a1628;
  border-top-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(10, 22, 40, 0.04);
}
.ai-msg-user { align-self: flex-end; flex-direction: row-reverse; }
.ai-msg-user .ai-msg-content {
  background: linear-gradient(135deg, #1e6bff 0%, #00b8d4 100%);
  color: #fff;
  border-top-right-radius: 4px;
}
.ai-msg-user .ai-msg-avatar {
  background: #5a6478;
}

/* ---------- 快捷问题气泡 ---------- */
.ai-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 0;
}
.ai-quick {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #1e6bff;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.ai-quick:hover {
  background: #1e6bff;
  color: #fff;
  border-color: #1e6bff;
  transform: translateY(-1px);
}

/* ---------- 输入区 ---------- */
.ai-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.ai-input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13.5px;
  color: #0a1628;
  background: #f8fafc;
  resize: none;
  outline: none;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ai-input:focus {
  border-color: #1e6bff;
  background: #fff;
}
.ai-input::placeholder { color: #94a3b8; }
.ai-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e6bff 0%, #00b8d4 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
  padding: 0;
}
.ai-send:hover { transform: scale(1.05); }
.ai-send:active { transform: scale(0.95); }
.ai-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- 底部 ---------- */
.ai-panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-top: 1px solid #e2e8f0;
  font-size: 11.5px;
  color: #94a3b8;
  background: #fff;
  flex-shrink: 0;
}
.ai-panel-footer a {
  color: #1e6bff;
  text-decoration: none;
  font-weight: 500;
}
.ai-panel-footer a:hover { text-decoration: underline; }

/* ---------- "打字中" 动画 ---------- */
.ai-typing {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
}
.ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: aiTyping 1.2s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aiTyping {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1;   }
}

/* ---------- 移动端 ---------- */
@media (max-width: 480px) {
  .ai-widget { bottom: 16px; right: 16px; }
  .ai-fab    { width: 54px; height: 54px; }
  .ai-panel  {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    max-height: none;
    bottom: 70px;
  }
}

/* ---------- 转人工联系卡片 ---------- */
.ai-transfer-contact {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 0;
}
.ai-transfer-phone {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: linear-gradient(135deg, #1e6bff 0%, #00b8d4 100%);
  color: #ffffff !important;
  border-radius: 10px;
  text-decoration: none !important;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 3px 10px rgba(30, 107, 255, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: none !important;
  letter-spacing: 0.3px;
}
.ai-transfer-phone:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(30, 107, 255, 0.38);
  color: #ffffff !important;
}
.ai-transfer-phone-icon {
  font-size: 20px;
  line-height: 1;
}
.ai-transfer-phone-num {
  font-family: 'JetBrainsMono', 'Consolas', monospace;
  font-size: 16px;
  letter-spacing: 0.5px;
}
.ai-transfer-qr-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}
.ai-transfer-qr {
  width: 96px;
  height: 96px;
  border-radius: 6px;
  background: #ffffff;
  padding: 4px;
  box-shadow: 0 2px 6px rgba(10, 22, 40, 0.08);
  flex-shrink: 0;
}
.ai-transfer-qr-text {
  flex: 1;
  min-width: 0;
}
.ai-transfer-qr-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #07c160;
  font-weight: 600;
  margin-bottom: 4px;
}
.ai-transfer-qr-num {
  font-family: 'JetBrainsMono', 'Consolas', monospace;
  font-size: 15px;
  color: #0a1628;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
  word-break: break-all;
}
.ai-transfer-qr-hint {
  font-size: 11.5px;
  color: #5a6478;
  line-height: 1.5;
}
.ai-transfer-tip {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: #94a3b8;
  text-align: center;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
}
