/* ============================================================
 * 悬浮客服竖条 · 结构复刻截图，尺寸对齐 https://xsd.cn/index.html 线上实测值
 *   xsd.cn 基准：白卡 78px / 头像 74px / 图标 22px / 四入口 12px / 回顶部 44px
 *   小新AI 头像 → 诚邀合作 → 白卡四入口（人才端/企业端/中台端/官方客服）→ 回顶部圆钮
 *   配色统一为网站蓝紫渐变 var(--grad)，与顶部信息条、按钮同一色系
 *   逻辑沿用 xsd-float-service：关键词知识库 + 页面问答库 + 未命中自学习
 * ============================================================ */

.sf-rail-wrap {
  position: fixed; right: 12px; top: 50%; transform: translateY(-50%);
  z-index: 90; transform-origin: right center;
}
.sf-rail {
  width: 96px; box-sizing: border-box;
  padding: 12px 8px; border-radius: 20px;
  background: var(--grad);
  box-shadow: 0 12px 32px rgba(79, 70, 229, .28);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  position: relative; overflow: hidden;
}
/* 截图里的虚线圆弧装饰（随整体等比缩小） */
.sf-rail::before {
  content: ""; position: absolute; left: -50px; top: -22px;
  width: 150px; height: 150px; border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, .28); pointer-events: none;
}
.sf-rail::after {
  content: ""; position: absolute; right: -70px; bottom: -40px;
  width: 160px; height: 160px; border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, .18); pointer-events: none;
}
.sf-rail > * { position: relative; z-index: 1; }

/* ---------- 头像 + 诚邀合作（xsd.cn：74px / 12px） ---------- */
.sf-mascot {
  display: flex; flex-direction: column; align-items: center; text-decoration: none;
  width: 78px; animation: sfFloat 3.2s ease-in-out infinite;
}
.sf-mascot-box {
  position: relative; display: block; width: 74px; height: 74px;
  border-radius: 50%; padding: 3px; box-sizing: border-box;
  background: var(--grad);
  box-shadow: 0 6px 18px rgba(79, 70, 229, .4); transition: transform .25s;
}
.sf-mascot-img {
  width: 100%; height: 100%; border-radius: 50%; display: block;
  object-fit: cover; object-position: 50% 16%;
  border: 2px solid #fff; box-sizing: border-box; background: #eaf3ff;
}
.sf-mascot-ring {
  position: absolute; inset: -6px; border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, .75);
  animation: sfSpin 7s linear infinite;
}
.sf-mascot-flash {
  position: absolute; inset: -10px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(165, 243, 252, .6), rgba(165, 243, 252, 0) 68%);
  opacity: 0; animation: sfFlash 3.2s ease-in-out infinite;
}
.sf-mascot-txt {
  display: inline-block; margin-top: 7px; padding: 4px 11px; border-radius: 99px;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .6), 0 4px 12px rgba(79, 70, 229, .32);
  color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .5px; white-space: nowrap;
}
.sf-mascot:hover .sf-mascot-box { transform: scale(1.07); }
.sf-mascot:hover .sf-mascot-txt { filter: brightness(1.08); }
@keyframes sfFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes sfSpin { to { transform: rotate(360deg); } }
@keyframes sfFlash {
  0%, 70%, 100% { opacity: 0; transform: scale(.92); }
  80% { opacity: .85; transform: scale(1.1); }
  90% { opacity: 0; transform: scale(1.24); }
}
@media (prefers-reduced-motion: reduce) {
  .sf-mascot, .sf-mascot-ring, .sf-mascot-flash { animation: none; }
}

/* ---------- 白色主卡片：四入口（xsd.cn：78px / 12px / 22px） ---------- */
.sf-panel {
  width: 78px; background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 8px 22px rgba(13, 27, 46, .16);
}
.sf-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; padding: 13px 0; width: 100%;
  border: 0; border-bottom: 1px solid #e9edf4; background: #fff;
  color: #333b4d; font-size: 12px; font-family: inherit; font-weight: 400;
  text-decoration: none; cursor: pointer; transition: .18s;
}
.sf-item:last-child { border-bottom: 0; }
.sf-item:hover { background: #f2f0ff; color: var(--primary); }
.sf-ico { display: block; height: 22px; }
.sf-ico svg { width: 22px; height: 22px; stroke: var(--primary); }

/* ---------- 回顶部圆钮（xsd.cn：44px） ---------- */
.sf-top {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(13, 27, 46, .2); transition: .2s;
}
.sf-top svg { width: 20px; height: 20px; stroke: var(--primary); }
.sf-top:hover { transform: translateY(-3px); box-shadow: 0 9px 22px rgba(13, 27, 46, .3); }

/* ---------- 官方客服对话框（零成本本地智能客服） ---------- */
.sf-chatbox {
  position: fixed; right: 120px; bottom: 24px; z-index: 95;
  width: 330px; max-width: calc(100vw - 32px); height: 460px; max-height: calc(100vh - 48px);
  background: #fff; border-radius: 18px; overflow: hidden;
  box-shadow: 0 20px 56px rgba(79, 70, 229, .3);
  display: none; flex-direction: column;
}
.sf-chatbox.open { display: flex; }
.sf-chat-head {
  display: flex; align-items: center; gap: 11px; padding: 13px 15px;
  background: var(--grad); color: var(--on-grad);
}
.sf-chat-head .ava {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  border: 2px solid rgba(255,255,255,.6);
}
.sf-chat-head .ava img { width: 100%; height: 100%; object-fit: cover; }
.sf-chat-head .ttl { flex: 1; min-width: 0; line-height: 1.4; }
.sf-chat-head .ttl b { display: block; font-size: 14px; }
.sf-chat-head .ttl span { display: block; font-size: 11px; opacity: .85; }
.sf-chat-head .cls {
  background: rgba(255,255,255,.2); border: 0; color: #fff; width: 28px; height: 28px;
  border-radius: 50%; font-size: 19px; line-height: 1; cursor: pointer; flex-shrink: 0;
}
.sf-chat-head .cls:hover { background: rgba(255,255,255,.36); }
.sf-chat-body {
  flex: 1; overflow-y: auto; padding: 15px 13px; display: flex; flex-direction: column; gap: 10px;
  background: #f7f9fd;
}
.sf-msg { max-width: 86%; padding: 10px 12px; border-radius: 13px; font-size: 13px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.sf-msg.bot { background: #fff; border: 1px solid #e5eaf3; color: #33415c; border-top-left-radius: 4px; align-self: flex-start; }
.sf-msg.user { background: var(--grad); color: var(--on-grad); border-top-right-radius: 4px; align-self: flex-end; }
.sf-msg a { color: var(--primary); }
.sf-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 13px 10px; background: #f7f9fd; }
.sf-quick button {
  border: 1px solid rgba(79,70,229,.3); color: var(--primary); background: #fff;
  border-radius: 999px; padding: 6px 11px; font-size: 11.5px; cursor: pointer; font-family: inherit;
}
.sf-quick button:hover { background: #f2f0ff; }
.sf-chat-foot { display: flex; gap: 8px; padding: 10px 12px; background: #fff; border-top: 1px solid #e9edf4; }
.sf-chat-foot input {
  flex: 1; min-width: 0; padding: 10px 13px; border: 1px solid #dfe5f0; border-radius: 999px;
  font-size: 16px; font-family: inherit; outline: none;
}
.sf-chat-foot input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.sf-send {
  border: 0; border-radius: 999px; padding: 0 17px; background: var(--grad);
  color: var(--on-grad); font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.sf-chat-hot {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px; background: #f2f0ff; font-size: 11.5px; color: #4a5b7a;
}
.sf-chat-hot a { color: var(--primary); font-weight: 700; text-decoration: none; }

/* ---------- 移动端折叠圆钮（对齐 xsd.cn：平时只留小钮，点击展开竖条） ---------- */
.sf-fab {
  display: none; width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  padding: 0; place-items: center; position: relative;
  color: var(--on-grad); background: var(--grad);
  box-shadow: 0 8px 22px rgba(79, 70, 229, .4); transition: .2s;
}
.sf-fab svg { width: 24px; height: 24px; stroke: currentColor; }
.sf-fab-dot {
  position: absolute; top: 3px; right: 4px; width: 9px; height: 9px;
  border-radius: 50%; background: #ff5a5a; border: 2px solid #fff;
}
.sf-fab.on { filter: brightness(.88); transform: scale(.94); }
@media (max-width: 900px) {
  .sf-rail-wrap {
    top: auto; bottom: 76px; right: 10px; transform: none;
    display: flex; flex-direction: column; align-items: flex-end;
  }
  .sf-fab { display: grid; }
  .sf-rail {
    position: absolute; right: 0; bottom: 58px; transform-origin: bottom right;
    opacity: 0; transform: scale(.4) translateY(24px); pointer-events: none;
    transition: opacity .2s, transform .2s;
  }
  .sf-rail.open { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }
  .sf-chatbox { right: 10px; bottom: 10px; width: calc(100vw - 20px); height: 60vh; }
}
@media (max-width: 560px) {
  .sf-rail-wrap { right: 8px; bottom: 72px; }
}

/* 深色主题：渐变转深，保证白卡与白字仍有对比 */
html[data-theme="dark"] .sf-rail {
  background: linear-gradient(160deg, #3b2f8f 0%, #5b3fb0 50%, #1e4a7a 100%);
}
html[data-theme="dark"] .sf-item { background: #fff; color: #333b4d; }
