/* 社区智能助手 · 右下角悬浮组件样式（小悦多状态 IP 形象版 v92.86）
 * 主题色沿用站点主绿 #5E8B7E；z-index 低于登录门(300)/通用弹窗(400)/灯箱(9999)，
 * 但高于播放控件(250)与底部导航。
 * v92.86 新增：每态光晕差异化（idle绿/welcome粉/feedback红）、280ms过渡、预加载配合。 */

.ai-root {
  position: fixed;
  right: 14px;
  bottom: 10px;
  z-index: 260;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
.ai-root * { box-sizing: border-box; }

/* ---------- 悬浮球（小悦多态形象） ---------- */
.ai-fab {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #f0f6f3 0%, #e0f0e8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
  box-shadow:
    0 6px 20px rgba(94, 139, 126, 0.30),
    0 2px 6px rgba(94, 139, 126, 0.12),
    inset 0 1px 0 rgba(255,255,255,0.6);
  transition: box-shadow .3s ease, transform .2s ease;
  /* 呼吸浮动 + 轻微晃动 */
  animation: ai-breathe 3s ease-in-out infinite, ai-sway 5s ease-in-out infinite;
}
.ai-fab img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  border-radius: 50%;
  /* 状态切换淡入淡出过渡（v92.86 加长至 280ms） */
  transition: opacity .28s ease, transform .28s ease;
}
/* 状态切换中的半透明过渡 */
.ai-fab img.ai-fab-switching {
  opacity: 0;
  transform: scale(.94);
}

/* ====== v92.86 每态光晕差异化 ====== */
/* 待机态：默认绿调阴影（静谧感） */
.ai-fab.ai-fab-state-idle {
  box-shadow:
    0 6px 20px rgba(94, 139, 126, 0.30),
    0 2px 6px rgba(94, 139, 126, 0.12),
    inset 0 1px 0 rgba(255,255,255,0.6);
}
/* 欢迎态：暖粉色调外发光（活泼亲切） */
.ai-fab.ai-fab-state-welcome {
  box-shadow:
    0 6px 24px rgba(232, 106, 154, 0.35),
    0 2px 8px rgba(232, 106, 154, 0.18),
    0 0 0 2px rgba(232, 106, 154, 0.15),
    inset 0 1px 0 rgba(255,255,255,0.65);
}
/* 反馈态：珊瑚红/爱心色外发光（比心呼应） */
.ai-fab.ai-fab-state-feedback {
  box-shadow:
    0 6px 26px rgba(240, 98, 102, 0.40),
    0 2px 10px rgba(240, 98, 102, 0.22),
    0 0 0 2px rgba(240, 98, 102, 0.18),
    inset 0 1px 0 rgba(255,255,255,0.7);
}

.ai-fab:hover {
  transform: scale(1.05);
}
.ai-fab:active { transform: scale(.96); }
.ai-fab.active {
  background: linear-gradient(135deg, #c8e5d8 0%, #b5dcc8 100%);
  box-shadow:
    0 4px 14px rgba(94, 139, 126, 0.35),
    inset 0 1px 0 rgba(255,255,255,0.4);
}
.ai-fab.dragging {
  cursor: grabbing;
  animation: none !important; /* 拖拽时暂停动画 */
  opacity .92;
}

/* ---------- 动画关键帧 ---------- */
@keyframes ai-breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.04); }
}
@keyframes ai-sway {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(2.5deg); }
  75% { transform: rotate(-2.5deg); }
}

/* ---------- 引导气泡（小悦话术 · 精致版） ---------- */
.ai-tip {
  position: absolute;
  bottom: 78px;
  right: -4px;
  background: linear-gradient(135deg, #fff 0%, #fdfafc 100%);
  border-radius: 16px;
  padding: 10px 18px;
  font-size: 13.5px;
  color: #3a5a4c;
  box-shadow:
    0 6px 24px rgba(20, 40, 34, 0.12),
    0 2px 6px rgba(20, 40, 34, 0.06),
    0 0 0 1px rgba(240, 128, 160, 0.15); /* 淡粉描边呼应小悦高亮 */
  white-space: nowrap;
  opacity: 0;
  transform: translateY(10px) scale(.92);
  transition: all .4s cubic-bezier(.22, 1, .36, 1);
  pointer-events: none;
  z-index: 259;
  font-weight: 500;
  letter-spacing: .3px;
}
/* 普通文字保持深绿 */
.ai-tip span {
  color: #3a5a4c;
}
/* "小悦" 粉红高亮 —— 需求文档核心视觉标识 */
.ai-tip .ai-tip-name {
  color: #e86a9a;
  font-weight: 700;
  font-size: 1.06em;
  text-shadow: 0 1px 3px rgba(232, 106, 154, 0.2);
}
.ai-tip.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
/* 气泡小三角（指向悬浮球） */
.ai-tip i {
  position: absolute;
  bottom: -8px;
  right: 22px;
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, #fff 0%, #fdfafc 100%);
  transform: rotate(45deg);
  box-shadow: 3px 3px 8px rgba(20,40,34,0.06);
  border-radius: 0 0 3px 0;
}

/* ---------- 聊天面板（可缩放） ---------- */
.ai-panel {
  position: absolute;
  right: 0;
  bottom: 80px;
  width: 360px;
  min-width: 300px;
  max-width: calc(100vw - 28px);
  height: 520px;
  min-height: 360px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(20, 40, 34, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(94, 139, 126, 0.18);
}
.ai-panel[hidden] { display: none; }

/* 缩放手柄（左上角） */
.ai-panel::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 4px;
  width: 14px;
  height: 14px;
  background: linear-gradient(135deg, rgba(94,139,126,.25) 50%, transparent 50%);
  border-radius: 14px 0 0 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.ai-panel:hover::after { opacity: 1; }

/* 左上角自定义缩放拖拽区 */
.ai-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  cursor: nwse-resize;
  z-index: 10;
  border-radius: 16px 0 8px 0;
}
.ai-resize-handle:hover { background: rgba(94,139,126,.12); }

/* ---------- 面板头部（可拖拽移动面板） ---------- */
.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(135deg, #5E8B7E 0%, #4a7568 100%);
  color: #fff;
  cursor: grab;
  flex-shrink: 0;
}
.ai-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; cursor: default; }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: #8ff0b0; box-shadow: 0 0 0 3px rgba(143, 240, 176, 0.35); }
.ai-head-ops { display: flex; gap: 4px; }
.ai-ic {
  width: 30px; height: 30px; border: none; background: rgba(255,255,255,0.14);
  color: #fff; border-radius: 8px; cursor: pointer; font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.ai-ic:hover { background: rgba(255,255,255,0.28); }

/* ---------- 消息区 ---------- */
.ai-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  background: #f6f8f7;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.ai-msg { display: flex; max-width: 100%; }
.ai-msg.me { justify-content: flex-end; }
.ai-bubble {
  max-width: 84%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: normal;
}
.ai-msg.ai .ai-bubble {
  background: #fff;
  border: 1px solid #e3eae7;
  border-bottom-left-radius: 4px;
  color: #233;
}
.ai-msg.me .ai-bubble {
  background: linear-gradient(135deg, #5E8B7E, #4a7568);
  color: #fff;
  border-bottom-right-radius: 4px;
}
/* 轻量 markdown 渲染 */
.ai-bubble p { margin: 0 0 6px; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble ul { margin: 4px 0; padding-left: 18px; }
.ai-bubble li { margin: 2px 0; }
.ai-bubble blockquote {
  margin: 6px 0; padding: 6px 10px; border-left: 3px solid #5E8B7E;
  background: rgba(94,139,126,0.08); color: #4a5a54; border-radius: 0 6px 6px 0; font-size: 13px;
}
.ai-bubble strong { font-weight: 700; }
.ai-bubble a.ai-link { color: #2f7d63; text-decoration: underline; cursor: pointer; }
.ai-bubble a.ai-link:hover { color: #1f5f49; }
.ai-msg.me .ai-bubble a.ai-link { color: #eafff4; }

.ai-err { color: #b3261e !important; background: #fdecea !important; border: 1px solid #f5c2bd !important; }

/* 操作按钮（转人工 / 站内跳转） */
.ai-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ai-act {
  display: inline-block; padding: 5px 10px; font-size: 13px; line-height: 1.3;
  border-radius: 16px; background: rgba(94,139,126,0.12); color: #2f7d63;
  text-decoration: none; cursor: pointer; border: 1px solid rgba(94,139,126,0.25);
}
.ai-act:hover { background: rgba(94,139,126,0.22); }
.ai-act.ghost { background: transparent; }

/* 打字光标 + 加载三点 */
.ai-caret { color: #5E8B7E; font-weight: 700; }
.ai-typing { display: inline-flex; gap: 4px; align-items: center; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: #b3c6bf; animation: ai-blink 1.2s infinite both; }
.ai-typing i:nth-child(2) { animation-delay: .2s; }
.ai-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes ai-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- 快捷问题 ---------- */
.ai-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; background: #f6f8f7; flex-shrink: 0; }
.ai-quick[hidden] { display: none; }
.ai-q {
  padding: 5px 11px; font-size: 12.5px; border-radius: 14px; cursor: pointer;
  background: #fff; border: 1px solid #d8e3df; color: #3c6a57; transition: all .15s;
}
.ai-q:hover { background: #eef5f2; border-color: #5E8B7E; }

/* ---------- 底部栏 ---------- */
.ai-foot { padding: 6px 12px 2px; background: #f6f8f7; flex-shrink: 0; }
.ai-human {
  width: 100%; padding: 7px; font-size: 13px; cursor: pointer;
  background: #fff; border: 1px dashed #b9cdc6; color: #4a7568; border-radius: 10px; transition: all .15s;
}
.ai-human:hover { background: #eef5f2; border-color: #5E8B7E; }

/* ---------- 输入框 ---------- */
.ai-input { display: flex; gap: 8px; padding: 8px 12px 12px; background: #f6f8f7; border-top: 1px solid #e7eeeb; flex-shrink: 0; }
.ai-input textarea {
  flex: 1; resize: none; border: 1px solid #d3e0db; border-radius: 12px; padding: 9px 11px;
  font-size: 14px; line-height: 1.4; max-height: 90px; font-family: inherit; outline: none;
}
.ai-input textarea:focus { border-color: #5E8B7E; box-shadow: 0 0 0 2px rgba(94,139,126,0.15); }
.ai-send {
  flex: 0 0 auto; align-self: end; padding: 0 16px; height: 38px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #5E8B7E, #4a7568); color: #fff; font-size: 14px; cursor: pointer;
  transition: opacity .15s;
}
.ai-send:hover { opacity: .9; }
.ai-send:active { transform: scale(.97); }

/* ---------- 转人工工单浮层 ---------- */
.ai-ticket {
  position: fixed; inset: 0; z-index: 400; background: rgba(20, 30, 26, 0.5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.ai-ticket[hidden] { display: none; }
.ai-ticket-box {
  width: 360px; max-width: 100%; background: #fff; border-radius: 16px; padding: 18px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.3);
}
.ai-ticket-h { font-size: 16px; font-weight: 700; margin-bottom: 12px; color: #233; }
.ai-sel, .ai-tarea {
  width: 100%; border: 1px solid #d3e0db; border-radius: 10px; padding: 9px 11px; font-size: 14px;
  font-family: inherit; margin-bottom: 10px; outline: none;
}
.ai-sel:focus, .ai-tarea:focus { border-color: #5E8B7E; box-shadow: 0 0 0 2px rgba(94,139,126,0.15); }
.ai-tarea { min-height: 90px; resize: vertical; }
.ai-ticket-ops { display: flex; justify-content: flex-end; gap: 8px; }
.btn { padding: 8px 16px; border-radius: 10px; border: 1px solid #d3e3df; background: #fff; color: #333; cursor: pointer; font-size: 14px; }
.btn:hover { background: #f3f6f5; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.primary { background: linear-gradient(135deg, #5E8B7E, #4a7568); color: #fff; border: none; }
.btn.primary:hover { opacity: .92; }
.btn.primary:disabled { opacity: .55; cursor: default; }

/* ---------- 移动端适配 ---------- */
@media (max-width: 480px) {
  .ai-root { right: 8px; bottom: 6px; }
  .ai-panel {
    right: -6px; bottom: 72px;
    width: calc(100vw - 20px);
    height: calc(100vh - 86px);
    max-height: calc(100vh - 86px);
    border-radius: 14px 14px 0 0;
    resize: none;
  }
  .ai-fab { width: 56px; height: 56px; }
  .ai-tip { bottom: 68px; right: -4px; font-size: 12px; padding: 7px 13px; }
}
