/* 智能助手悬浮 Widget —— 沿用站点主色与卡片风格 */
/* 默认定位在登录/注册按钮正下方；位置由 JS 写入 left/top，支持拖动 */
.asst-root {
  position: fixed;
  top: 72px; right: 16px;
  z-index: 95;
  pointer-events: none;
}
.asst-root > * { pointer-events: auto; }

/* 悬浮按钮（启动器，可拖动） */
.asst-fab {
  position: fixed;
  right: 16px; top: 72px;
  height: 44px; padding: 0 14px 0 12px;
  border: none; border-radius: 22px;
  background: var(--primary, #00c853);
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 150, 70, .35);
  cursor: grab;
  display: flex; align-items: center; gap: 6px;
  transition: box-shadow .2s ease, transform .12s ease;
  touch-action: none;
  user-select: none;
}
.asst-fab:hover { box-shadow: 0 12px 26px rgba(0, 150, 70, .45); }
.asst-fab:active { cursor: grabbing; }
.asst-fab.dragging { transition: none; }
.asst-mascot { font-size: 22px; line-height: 1; display: block; transition: transform .2s; flex: 0 0 auto; }
.asst-fab.flip .asst-mascot { animation: asst-flip .65s cubic-bezier(.5, .05, .5, 1); }
@keyframes asst-flip {
  0%   { transform: rotate(0deg)   translateY(0); }
  45%  { transform: rotate(180deg) translateY(-12px); }
  55%  { transform: rotate(180deg) translateY(-12px); }
  100% { transform: rotate(360deg) translateY(0); }
}
.asst-fab-label { font-size: 14px; font-weight: 600; white-space: nowrap; letter-spacing: .5px; }
/* 在线小圆点（替代原“问”字角标） */
.asst-fab-dot {
  position: absolute; top: -3px; right: -3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #ff6b35; border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}
.asst-root.open .asst-fab-dot { display: none; }

/* 对话窗口（left/top 由 JS 依据悬浮按钮位置计算并写入） */
.asst-panel {
  position: fixed;
  width: 366px;
  max-height: 72vh;
  background: var(--card, #fff);
  color: var(--text, #1f2733);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(20, 30, 60, .28);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0; transform: translateY(16px) scale(.96);
  visibility: hidden; pointer-events: none;
  transition: opacity .22s ease, transform .22s ease, visibility .22s;
}
.asst-root.open .asst-panel { opacity: 1; transform: translateY(0) scale(1); visibility: visible; pointer-events: auto; }

.asst-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: var(--primary, #00c853);
  color: #fff;
}
.asst-head-info { display: flex; align-items: center; gap: 10px; }
.asst-head-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.asst-head-title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.asst-head-sub { font-size: 12px; opacity: .9; line-height: 1.3; }
.asst-head-actions { display: flex; gap: 6px; }
.asst-ic {
  width: 34px; height: 34px; border: none; border-radius: 8px;
  background: rgba(255, 255, 255, .18); color: #fff; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.asst-ic:hover { background: rgba(255, 255, 255, .32); }

/* 消息区 */
.asst-msgs {
  flex: 1; overflow-y: auto;
  padding: 14px; display: flex; flex-direction: column; gap: 12px;
  background: var(--card-alt, #f8fafc);
}
.asst-msg { display: flex; gap: 8px; max-width: 92%; }
.asst-msg .asst-ava {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-light, #e8f5e9); display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.asst-bubble {
  padding: 9px 12px; border-radius: 12px; font-size: 14px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.asst-msg.bot { align-self: flex-start; }
.asst-msg.bot .asst-bubble { background: var(--card, #fff); border: 1px solid rgba(0, 0, 0, .06); border-top-left-radius: 2px; }
.asst-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.asst-msg.user .asst-ava { background: #fff; }
.asst-msg.user .asst-bubble { background: var(--primary, #00c853); color: #fff; border-top-right-radius: 2px; }
.asst-sources { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.asst-src {
  font-size: 12px; color: var(--text-light, #606f80);
  background: var(--card-alt, #f1f5f9); border-left: 3px solid var(--primary, #00c853);
  padding: 6px 10px; border-radius: 6px;
}
.asst-src-title { font-weight: 600; color: var(--text, #1f2733); margin-bottom: 4px; }
.asst-src-kp { font-size: 12px; line-height: 1.55; color: var(--text, #1f2733); margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.asst-src mark { background: #fff3bf; color: inherit; padding: 0 1px; border-radius: 3px; }
.asst-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.asst-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-light, #94a3b8); animation: asst-blink 1s infinite; }
.asst-typing i:nth-child(2) { animation-delay: .2s; }
.asst-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes asst-blink { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

/* 推荐问题 */
.asst-reco { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px; border-top: 1px solid rgba(0, 0, 0, .06); }
.asst-reco-label { width: 100%; font-size: 12px; color: var(--text-light, #606f80); }
.asst-chip {
  font-size: 13px; line-height: 1.3;
  border: 1px solid var(--primary, #00c853); color: var(--primary, #00c853);
  background: var(--card, #fff); border-radius: 999px; padding: 8px 14px; cursor: pointer;
  min-height: 32px; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.asst-chip:hover { background: var(--primary, #00c853); color: #fff; }
.asst-root.busy .asst-chip { opacity: .5; pointer-events: none; }

/* 登录门禁 */
.asst-login {
  padding: 12px 14px; border-top: 1px solid rgba(0, 0, 0, .06);
  background: var(--primary-light, #e8f5e9);
  text-align: center;
}
.asst-login.hidden { display: none; }
.asst-login-tip { font-size: 13px; color: var(--text, #1f2733); margin-bottom: 10px; line-height: 1.5; }
.asst-login-btn { background: var(--primary, #00c853); color: #fff; border: none; border-radius: 10px; padding: 8px 18px; font-size: 14px; cursor: pointer; }

/* 输入区 */
.asst-input-row { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid rgba(0, 0, 0, .06); align-items: flex-end; background: var(--card, #fff); }
.asst-input {
  flex: 1; resize: none; border: 1px solid rgba(0, 0, 0, .15); border-radius: 10px;
  padding: 9px 11px; font-size: 14px; line-height: 1.5; max-height: 96px;
  font-family: inherit; color: var(--text, #1f2733); background: var(--card, #fff);
  outline: none;
}
.asst-input:focus { border-color: var(--primary, #00c853); }
.asst-send {
  flex: 0 0 auto; width: 40px; height: 40px; border: none; border-radius: 10px;
  background: var(--primary, #00c853); color: #fff; font-size: 16px; cursor: pointer;
}
.asst-send:disabled { opacity: .5; cursor: not-allowed; }

/* 移动端：按钮置于页眉下方右上角；对话窗仍为底部抽屉 */
@media (max-width: 768px) {
  .asst-root { top: 60px; right: 12px; }
  .asst-fab { right: 12px; top: 60px; height: 40px; padding: 0 11px 0 10px; }
  .asst-fab-label { font-size: 13px; }
  .asst-mascot { font-size: 20px; }
  .asst-panel {
    right: 0; left: 0; bottom: 0; width: auto;
    max-height: 78vh; border-radius: 16px 16px 0 0;
    transform-origin: bottom center;
    transform: translateY(100%);
  }
  .asst-root.open .asst-panel { transform: translateY(0); }
  .asst-head { border-radius: 16px 16px 0 0; }
}
