/* ============================================================
   StorePilot 官网在线客服（右侧抽屉）
   ============================================================ */

.sp-cs-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 11px;
  border: 0;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, #0b2352 0%, #2e75ff 100%);
  border-radius: 14px 0 0 14px;
  box-shadow: 0 10px 30px rgba(11, 27, 51, 0.28);
  font-family: inherit;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
.sp-cs-tab:hover { transform: translateY(-50%) translateX(-3px); box-shadow: 0 14px 36px rgba(11, 27, 51, 0.34); }
.sp-cs-tab .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7dffb0;
  box-shadow: 0 0 0 0 rgba(125, 255, 176, 0.7);
  animation: sp-pulse 2s infinite;
}
@keyframes sp-pulse {
  0% { box-shadow: 0 0 0 0 rgba(125, 255, 176, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(125, 255, 176, 0); }
  100% { box-shadow: 0 0 0 0 rgba(125, 255, 176, 0); }
}
.sp-cs-tab .txt {
  writing-mode: vertical-rl;
  letter-spacing: 0.18em;
  font-size: 13px;
  font-weight: 600;
}

.sp-cs-mask {
  position: fixed;
  inset: 0;
  background: rgba(7, 23, 51, 0.32);
  backdrop-filter: blur(3px);
  z-index: 9001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sp-cs-mask.open { opacity: 1; pointer-events: auto; }

.sp-cs {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 400px;
  max-width: 100vw;
  z-index: 9002;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: -18px 0 50px rgba(11, 27, 51, 0.18);
  transform: translateX(102%);
  transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
.sp-cs.open { transform: translateX(0); }

/* 顶部 */
.sp-cs-head {
  position: relative;
  padding: 20px 20px 18px;
  color: #fff;
  background: linear-gradient(135deg, #071733 0%, #0d2a5c 55%, #1b4bb3 100%);
  overflow: hidden;
  flex: 0 0 auto;
}
.sp-cs-head::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -60px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(46, 117, 255, 0.55), transparent 70%);
  pointer-events: none;   /* 关键：装饰层不能拦截关闭按钮的点击 */
}
.sp-cs-head-row { position: relative; z-index: 2; display: flex; align-items: center; gap: 12px; }
.sp-cs-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.42);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  flex: 0 0 auto;
  background: #0b1b33;
}
.sp-cs-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 16%; display: block; }
.sp-cs-name { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; }
.sp-cs-sub { margin-top: 3px; font-size: 11.5px; color: rgba(255, 255, 255, 0.62); }
.sp-cs-sub .live { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #7dffb0; margin-right: 5px; vertical-align: middle; }
.sp-cs-close {
  position: relative;
  z-index: 5;
  margin-left: auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.sp-cs-close:hover { background: rgba(255, 255, 255, 0.26); }
.sp-cs-close:active { background: rgba(255, 255, 255, 0.36); transform: scale(0.94); }

/* 消息区 */
.sp-cs-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 16px 8px;
  background: #f6f8fc;
  scroll-behavior: smooth;
}
.sp-cs-msg { display: flex; gap: 9px; margin-bottom: 14px; animation: sp-in 0.28s ease both; }
@keyframes sp-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sp-cs-msg .av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: #e8efff;
  flex: 0 0 auto;
  box-shadow: 0 2px 8px rgba(11, 27, 51, 0.12);
}
.sp-cs-msg .av img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; display: block; }
.sp-cs-bubble {
  max-width: 78%;
  padding: 11px 13px;
  border-radius: 4px 14px 14px 14px;
  background: #fff;
  color: #0b1b33;
  font-size: 14px;
  line-height: 1.65;
  box-shadow: 0 2px 10px rgba(11, 27, 51, 0.06);
  white-space: pre-wrap;
  word-break: break-word;
}
.sp-cs-msg.user { flex-direction: row-reverse; }
.sp-cs-msg.user .sp-cs-bubble {
  background: linear-gradient(135deg, #2e75ff, #1b5ae0);
  color: #fff;
  border-radius: 14px 4px 14px 14px;
  box-shadow: 0 4px 14px rgba(46, 117, 255, 0.28);
}
.sp-cs-msg.user .av { display: none; }

.sp-cs-typing { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.sp-cs-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9fb0c9;
  animation: sp-bounce 1.1s infinite;
}
.sp-cs-typing i:nth-child(2) { animation-delay: 0.15s; }
.sp-cs-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes sp-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* 快捷问题 */
.sp-cs-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 16px 39px; }
.sp-cs-quick button {
  border: 1px solid #d7e3fb;
  background: #fff;
  color: #1b4bb3;
  font-size: 12.5px;
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.18s ease;
}
.sp-cs-quick button:hover { border-color: #2e75ff; background: #eef4ff; }

/* CTA 卡片 */
.sp-cs-cta {
  margin: 2px 0 16px 39px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #eef4ff;
  border: 1px solid #d7e3fb;
  color: #1b4bb3;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.sp-cs-cta span { transition: transform 0.18s ease; }
.sp-cs-cta:hover span { transform: translateX(3px); }

/* 输入区 */
.sp-cs-foot {
  flex: 0 0 auto;
  padding: 12px 14px 14px;
  border-top: 1px solid #e9eef7;
  background: #fff;
}
.sp-cs-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid #dde5f2;
  border-radius: 14px;
  padding: 8px 8px 8px 12px;
  background: #fff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.sp-cs-input-wrap:focus-within { border-color: #2e75ff; box-shadow: 0 0 0 3px rgba(46, 117, 255, 0.12); }
.sp-cs-input {
  flex: 1 1 auto;
  border: 0;
  outline: 0;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  max-height: 96px;
  color: #0b1b33;
  background: transparent;
}
.sp-cs-input::placeholder { color: #a9b6cc; }
.sp-cs-send {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #2e75ff, #1b5ae0);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: opacity 0.18s ease;
}
.sp-cs-send:disabled { opacity: 0.45; cursor: default; }
.sp-cs-note {
  margin-top: 9px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: #a9b6cc;
}
.sp-cs-note a { color: #2e75ff; text-decoration: none; }

@media (max-width: 480px) {
  .sp-cs { width: 100%; }
  .sp-cs-tab { padding: 14px 9px; }
  .sp-cs-tab .txt { font-size: 12px; }
}

/* 转人工留言表单 */
.sp-cs-form {
  margin: 0 0 16px 39px;
  padding: 13px;
  background: #fff;
  border: 1px solid #dde5f2;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(11, 27, 51, 0.07);
}
.sp-cs-form-t { font-size: 13px; font-weight: 600; color: #0b1b33; margin-bottom: 9px; }
.sp-cs-form input,
.sp-cs-form textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e3e8f0;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 8px;
  outline: 0;
}
.sp-cs-form input:focus,
.sp-cs-form textarea:focus { border-color: #2e75ff; }
.sp-cs-form textarea { resize: vertical; }
.sp-cs-form-row { display: flex; gap: 8px; }
.sp-cs-form-row button {
  flex: 1;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: #2e75ff;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.sp-cs-form-row button.ghost { background: #f1f4fa; color: #5f6d85; }
.sp-cs-form-row button:disabled { opacity: 0.6; cursor: default; }
.sp-cs-note a { cursor: pointer; }