/* ================================================================
   凡逢予你 · AI 在线客服「小遇」—— 悬浮球 + 聊天面板
   独立成文件（不塞进 app.css，避免主样式表越来越臃肿）
   动效原则与全站一致：只动 transform / opacity，不做会触发布局的动画
   ================================================================ */

/* ---------- 悬浮球 ---------- */
.bot-fab {
  position: fixed;
  right: 16px;
  bottom: calc(104px + env(safe-area-inset-bottom, 0px));
  z-index: 140;
  width: 54px; height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .5);
  background: linear-gradient(135deg, rgba(78, 168, 222, .94), rgba(63, 193, 160, .94));
  box-shadow: 0 10px 26px rgba(17, 80, 70, .32), inset 0 1px 0 rgba(255, 255, 255, .45);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transform: translate3d(0, 0, 0) scale(1);
  transition: transform .28s var(--ease-out-ios, cubic-bezier(.22, 1, .36, 1)), box-shadow .28s ease, opacity .2s ease;
  opacity: 0;
  pointer-events: none;
}
.bot-fab.show { opacity: 1; pointer-events: auto; }
.bot-fab:active { transform: translate3d(0, 0, 0) scale(.92); }
.bot-fab .bot-fab-dot {
  position: absolute; top: 3px; right: 3px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #3FC1A0; border: 2px solid #fff;
  animation: botPulse 2.2s ease-out infinite;
}
@keyframes botPulse {
  0%   { box-shadow: 0 0 0 0 rgba(53, 208, 127, .55); }
  70%  { box-shadow: 0 0 0 9px rgba(53, 208, 127, 0); }
  100% { box-shadow: 0 0 0 0 rgba(53, 208, 127, 0); }
}

/* 引导气泡（第一次进来提示点一下） */
.bot-tip {
  position: fixed;
  right: 78px;
  bottom: calc(118px + env(safe-area-inset-bottom, 0px));
  z-index: 140;
  max-width: 200px;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .95);
  color: var(--text-main, #1E3A47);
  font-size: 13px;
  box-shadow: 0 8px 22px rgba(20, 60, 52, .18);
  opacity: 0;
  transform: translate3d(6px, 0, 0);
  transition: opacity .3s ease, transform .3s var(--ease-out-ios, cubic-bezier(.22, 1, .36, 1));
  pointer-events: none;
}
.bot-tip.show { opacity: 1; transform: translate3d(0, 0, 0); }

/* ---------- 聊天面板 ---------- */
.bot-panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 260;
  height: min(80vh, 660px);
  max-height: calc(100dvh - 24px);
  display: flex; flex-direction: column;
  background: rgba(252, 255, 254, .95);
  backdrop-filter: blur(14px) saturate(1.45);
  -webkit-backdrop-filter: blur(14px) saturate(1.45);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  border-top: 1px solid rgba(255, 255, 255, .6);
  box-shadow: 0 -12px 44px rgba(18, 58, 50, .22);
  transform: translate3d(0, 102%, 0);
  opacity: 0;
  pointer-events: none;
  /* ★ 2026-09-23 性能：只用 transform+opacity 隐藏时，元素**仍在渲染树里**，
     那 14px 的 backdrop-filter 会一直参与合成（实测它是页面里常驻的滤镜元素之一）。
     加 visibility:hidden 让关闭状态真正移出渲染；延迟到动画结束再切，避免打断滑入/滑出。 */
  visibility: hidden;
  transition: transform .36s var(--ease-out-ios, cubic-bezier(.22, 1, .36, 1)), opacity .26s ease;
  overflow: hidden;
}
.bot-panel.open { transform: translate3d(0, 0, 0); opacity: 1; pointer-events: auto; visibility: visible; transition-delay: 0s, 0s, 0s; }
@media (min-width: 760px) {
  .bot-panel {
    left: auto; right: 20px; bottom: 20px;
    width: 404px;
    height: min(70vh, 640px);
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, .6);
  }
}

/* 头部 */
.bot-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(20, 60, 52, .08);
  background: linear-gradient(135deg, rgba(78, 168, 222, .10), rgba(63, 193, 160, .10));
}
.bot-ava {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #4EA8DE, #3FC1A0);
  color: #fff; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.bot-head-txt { flex: 1; min-width: 0; }
.bot-name { font-size: 15px; font-weight: 600; color: var(--text-main, #1E3A47); line-height: 1.2; }
.bot-sub { font-size: 11px; color: var(--text-light, #96AEB9); display: flex; align-items: center; gap: 4px; }
.bot-sub i { width: 6px; height: 6px; border-radius: 50%; background: #3FC1A0; display: inline-block; }
.bot-mini {
  flex: 0 0 auto;
  border: 1px solid rgba(78, 168, 222, .28);
  background: rgba(255, 255, 255, .75);
  color: var(--primary-dark, #3B8FC4);
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  cursor: pointer;
  transition: transform .18s var(--ease-out-ios, cubic-bezier(.22, 1, .36, 1));
}
.bot-mini:active { transform: scale(.95); }
.bot-x {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  border: none; background: rgba(20, 60, 52, .07); color: var(--text-sub, #63838F);
  font-size: 15px; cursor: pointer; line-height: 1;
}

/* 消息区 */
.bot-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px 14px 6px;
}
.bot-row { display: flex; margin-bottom: 12px; }
.bot-row.me { justify-content: flex-end; }
.bot-bubble {
  max-width: 84%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  background: #fff;
  color: var(--text-main, #1E3A47);
  border: 1px solid rgba(20, 60, 52, .06);
  box-shadow: 0 2px 10px rgba(20, 60, 52, .07);
  animation: botIn .26s var(--ease-out-ios, cubic-bezier(.22, 1, .36, 1));
}
.bot-row.me .bot-bubble {
  background: linear-gradient(135deg, #4EA8DE, #3FC1A0);
  color: #fff;
  border-color: transparent;
}
@keyframes botIn {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
.bot-bubble b { font-weight: 600; }
.bot-src { font-size: 10px; color: var(--text-light, #96AEB9); margin: -6px 0 10px 4px; }
.bot-src.me { text-align: right; margin-right: 4px; }

/* 打字中 */
.bot-typing { display: inline-flex; gap: 4px; align-items: center; padding: 3px 0; }
.bot-typing i {
  width: 6px; height: 6px; border-radius: 50%; background: #96AEB9;
  animation: botDot 1.3s infinite ease-in-out;
}
.bot-typing i:nth-child(2) { animation-delay: .16s; }
.bot-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes botDot {
  0%, 60%, 100% { transform: translate3d(0, 0, 0); opacity: .45; }
  30%           { transform: translate3d(0, -4px, 0); opacity: 1; }
}

/* 快捷问题 */
.bot-quick {
  flex: 0 0 auto;
  display: flex; gap: 8px; overflow-x: auto;
  padding: 6px 14px 8px;
  scrollbar-width: none;
}
.bot-quick::-webkit-scrollbar { display: none; }
.bot-quick button {
  flex: 0 0 auto;
  border: 1px solid rgba(78, 168, 222, .3);
  background: rgba(255, 255, 255, .88);
  color: var(--primary-dark, #3B8FC4);
  font-size: 12.5px; padding: 6px 12px; border-radius: 999px;
  cursor: pointer; white-space: nowrap;
  transition: transform .18s var(--ease-out-ios, cubic-bezier(.22, 1, .36, 1));
}
.bot-quick button:active { transform: scale(.94); }

/* 输入区 */
.bot-foot {
  flex: 0 0 auto;
  display: flex; gap: 8px; align-items: flex-end;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(20, 60, 52, .08);
  background: rgba(255, 255, 255, .75);
}
.bot-input {
  flex: 1; min-width: 0;
  resize: none;
  max-height: 96px;
  padding: 9px 12px;
  border: 1px solid rgba(20, 60, 52, .14);
  border-radius: 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-main, #1E3A47);
  background: #fff;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.bot-input:focus {
  border-color: rgba(78, 168, 222, .5);
  box-shadow: 0 0 0 3px rgba(78, 168, 222, .12);
}
.bot-send {
  flex: 0 0 auto;
  height: 40px; padding: 0 16px;
  border: none; border-radius: 13px;
  background: linear-gradient(135deg, #4EA8DE, #3FC1A0);
  color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: transform .18s var(--ease-out-ios, cubic-bezier(.22, 1, .36, 1)), opacity .2s ease;
}
.bot-send:active { transform: scale(.95); }
.bot-send[disabled] { opacity: .5; cursor: default; }

/* 关掉动态效果的用户：一律不要动画 */
@media (prefers-reduced-motion: reduce) {
  .bot-fab, .bot-tip, .bot-panel, .bot-bubble, .bot-quick button, .bot-mini { transition: none !important; animation: none !important; }
  .bot-fab .bot-fab-dot, .bot-typing i { animation: none !important; }
}
