/* ============ AI 浮动客服 ============ */
.ai-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff;
  color: #1e88e5;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  z-index: 9998;
  transition: transform .2s, box-shadow .2s;
  border: 2px solid #e3e9f0;
  padding: 0;
  overflow: hidden;
}
.ai-fab:hover { transform: scale(1.06); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.ai-fab img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.ai-fab svg { width: 26px; height: 26px; }

.ai-greet {
  position: fixed;
  right: 92px;
  bottom: 36px;
  background: #fff;
  border: 1px solid #e3e9f0;
  border-radius: 12px;
  padding: 10px 14px;
  max-width: 240px;
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  font-size: 13px;
  color: #1f2d3d;
  z-index: 9997;
  display: none;
  animation: aiFade .3s;
}
.ai-greet::after {
  content: '';
  position: absolute;
  right: -8px;
  bottom: 18px;
  border: 8px solid transparent;
  border-left-color: #fff;
  border-right: none;
}
.ai-greet .close {
  position: absolute;
  top: 4px;
  right: 6px;
  color: #9aa7b4;
  cursor: pointer;
  font-size: 14px;
  background: none;
  border: none;
}

.ai-window {
  position: fixed;
  right: 24px;
  bottom: 92px;
  width: 380px;
  height: 560px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: aiSlideUp .25s ease;
}
.ai-window.open { display: flex; }

.ai-window-header {
  background: linear-gradient(135deg, #1e88e5, #1565c0);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.ai-window-header .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  overflow: hidden;
  flex-shrink: 0;
}
.ai-window-header .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.ai-window-header .titles h4 { margin: 0; font-size: 15px; }
.ai-window-header .titles span { font-size: 12px; opacity: .85; }
.ai-window-header .close {
  margin-left: auto;
  background: none; border: none;
  color: #fff; font-size: 20px;
  cursor: pointer; padding: 0 4px;
}

.ai-window-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f7f9fc;
}
.ai-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  animation: aiFade .25s;
}
.ai-msg .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #e3e9f0;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
}
.ai-msg .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.ai-msg.user .avatar { background: #5c6bc0; }
.ai-msg.bot .avatar { background: transparent; border: 2px solid #e3e9f0; }
.ai-msg.user { flex-direction: row-reverse; }
.ai-msg .bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 14px;
  word-break: break-word;
}
.ai-msg.bot .bubble { background: #fff; border: 1px solid #e3e9f0; color: #1f2d3d; border-top-left-radius: 4px; }
.ai-msg.user .bubble { background: #1e88e5; color: #fff; border-top-right-radius: 4px; }
.ai-msg.bot .bubble p { margin: 0 0 8px; }
.ai-msg.bot .bubble p:last-child { margin-bottom: 0; }
.ai-msg.bot .bubble a { color: #1565c0; text-decoration: underline; }
.ai-msg .typing .bubble {
  background: #fff; border: 1px solid #e3e9f0;
  padding: 12px 18px;
}
.ai-msg .typing-dots { display: flex; gap: 4px; }
.ai-msg .typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #b0bec5;
  animation: aiBounce 1.2s infinite;
}
.ai-msg .typing-dots span:nth-child(2) { animation-delay: .15s; }
.ai-msg .typing-dots span:nth-child(3) { animation-delay: .3s; }

.ai-suggestions {
  padding: 0 16px 8px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.ai-suggestions button {
  background: #fff;
  border: 1px solid #cfe2f7;
  color: #1e88e5;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.ai-suggestions button:hover { background: #e8f1fb; border-color: #1e88e5; }

.ai-window-footer {
  padding: 12px;
  border-top: 1px solid #e3e9f0;
  background: #fff;
}
.ai-input-row {
  display: flex;
  gap: 8px;
}
.ai-input-row textarea {
  flex: 1;
  border: 1px solid #e3e9f0;
  border-radius: 20px;
  padding: 10px 14px;
  resize: none;
  font-size: 14px;
  font-family: inherit;
  height: 40px;
  max-height: 120px;
  outline: none;
  transition: border-color .15s;
}
.ai-input-row textarea:focus { border-color: #1e88e5; }
.ai-input-row button {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #1e88e5;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ai-input-row button:hover { background: #1565c0; }
.ai-input-row button:disabled { background: #b0bec5; cursor: not-allowed; }
.ai-footer-note {
  font-size: 11px;
  color: #9aa7b4;
  text-align: center;
  margin-top: 6px;
}

@keyframes aiFade { from {opacity:0} to {opacity:1} }
@keyframes aiSlideUp { from {opacity:0; transform: translateY(20px)} to {opacity:1; transform: translateY(0)} }
@keyframes aiBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

@media (max-width: 480px) {
  .ai-window {
    right: 0; bottom: 0;
    width: 100%; height: 100%;
    max-width: 100vw; max-height: 100vh;
    border-radius: 0;
  }
  .ai-fab { right: 16px; bottom: 16px; }
}
