/* =====================================================================
 * 在线客服样式（沿用 app.css 的设计令牌，自动适配深色模式）
 * ===================================================================== */

/* 顶栏标题 + 状态副标题 */
.nav-titles { display: flex; flex-direction: column; align-items: center; line-height: 1.25; max-width: 70%; }
.nav-sub { font-size: 11px; font-weight: 400; color: var(--text-3); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; animation: fadeIn .2s ease both; }
.nav-sub .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); flex-shrink: 0; }
.nav-sub.tone-on .dot { background: var(--brand); box-shadow: 0 0 0 3px rgba(7,193,96,.18); }
.nav-sub.tone-wait .dot { background: var(--warning); animation: dotPulse 1.4s ease-in-out infinite; }

/* 未读角标 */
.cs-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--card); font-family: var(--font-num);
}
.cs-badge.inline { position: static; box-shadow: none; margin-right: 4px; }
.cs-badge.pop { animation: popBadge .35s var(--spring) both; }

/* 首页悬浮客服按钮 */
.cs-fab {
  position: absolute; right: 12px; bottom: calc(var(--tabbar) + 64px + 16px); z-index: 6;
  width: 56px; height: 56px; border: none; border-radius: 50%; padding: 0;
  background: var(--brand-gradient); color: #fff; box-shadow: 0 8px 24px rgba(7,193,96,.35), 0 2px 6px rgba(0,0,0,.08);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  touch-action: none; -webkit-user-select: none; user-select: none;
  transition: left .28s var(--ease-out), right .28s var(--ease-out), transform .15s ease, box-shadow .2s ease;
  animation: fadeUp .4s var(--ease-out) .3s backwards;
}
.cs-fab svg { width: 28px; height: 28px; margin-top: -2px; }
.cs-fab-t { font-size: 10px; line-height: 1; margin-top: -2px; font-weight: 500; }
.cs-fab.dragging { transition: none; transform: scale(1.06); box-shadow: 0 14px 32px rgba(7,193,96,.4); cursor: grabbing; }
.cs-fab:active:not(.dragging) { transform: scale(.94); }
@media (hover: hover) { .cs-fab:not(.dragging):hover { box-shadow: 0 10px 28px rgba(7,193,96,.45); } }

/* FAQ 底部 / 结果页入口 */
.faq-cs, .link-cs {
  width: 100%; border: none; background: none; display: flex; align-items: center; justify-content: center; gap: 4px;
  font-size: 13px; color: var(--text-3); height: 48px; border-top: 1px solid var(--line);
}
.faq-cs b, .link-cs b { color: var(--brand-text); font-weight: 500; }
.faq-cs .ic { font-size: 12px; color: var(--brand-text); }
.link-cs { border-top: none; margin-top: 8px; }
.link-cs .ic { font-size: 16px; color: var(--brand-text); }
@media (hover: hover) { .faq-cs:hover b, .link-cs:hover b { text-decoration: underline; } }

/* ---------------- 客服页布局 ---------------- */
#pgCs { padding-bottom: var(--kb, 0px); transition: padding-bottom .2s ease; }
#pgCs > .scroll.cs-scroll { padding: calc(var(--hdr) + 8px) 12px 16px; background: transparent; }
.cs-conn {
  position: absolute; left: 0; right: 0; top: var(--hdr); z-index: 7; height: 28px;
  display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: var(--warning-text);
  background: var(--warning-light); animation: slideDown .25s var(--ease-out) both;
}
.cs-conn .spinner { width: 12px; height: 12px; border-width: 2px; border-top-color: var(--warning); }
.cs-older { min-height: 8px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: var(--text-3); padding: 4px 0 8px; }
.cs-older .line { width: 32px; height: 1px; background: var(--line); }

/* 时间 / 会话分隔 / 系统事件 */
.cs-time { text-align: center; margin: 16px 0 8px; font-size: 11px; color: var(--text-3); }
.cs-time.boundary { display: flex; align-items: center; gap: 12px; margin: 24px 8px 12px; }
.cs-time.boundary::before, .cs-time.boundary::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.cs-event { text-align: center; margin: 8px 0; animation: fadeIn .25s ease both; }
.cs-event span { display: inline-block; max-width: 80%; padding: 4px 12px; border-radius: var(--r-full); background: var(--fill-2); color: var(--text-3); font-size: 12px; line-height: 1.5; }

/* 消息行 */
.cs-row { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; animation: msgIn .28s var(--ease-out) both; }
.cs-row.right { justify-content: flex-end; }
.cs-row.no-anim, .cs-event.no-anim, .cs-time.no-anim { animation: none; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.cs-av { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.cs-av svg { width: 100%; height: 100%; display: block; }
.cs-col { display: flex; flex-direction: column; max-width: calc(100% - 96px); min-width: 0; }
.cs-row.right .cs-col { align-items: flex-end; }
.cs-name { font-size: 11px; color: var(--text-3); margin: 0 0 4px 4px; }
.cs-line { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.cs-bubble {
  padding: 10px 12px; border-radius: 4px 16px 16px 16px; background: var(--card); color: var(--text-1);
  font-size: 15px; line-height: 1.55; word-break: break-word; overflow-wrap: anywhere; box-shadow: var(--shadow-card); white-space: normal;
}
.cs-row.right .cs-bubble { border-radius: 16px 4px 16px 16px; background: var(--brand-gradient); color: #fff; box-shadow: 0 4px 12px rgba(7,193,96,.22); }
.cs-bubble a { color: var(--info); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.cs-row.right .cs-bubble a { color: #fff; }
.cs-sub { margin-top: 6px; font-size: 12px; color: var(--text-3); }
.cs-read { font-size: 11px; color: var(--text-3); margin: 4px 4px 0 0; }
.cs-sending { width: 14px; height: 14px; flex-shrink: 0; }
.cs-fail {
  width: 20px; height: 20px; flex-shrink: 0; border: none; border-radius: 50%; padding: 0; background: var(--danger); color: #fff;
  font-size: 13px; font-weight: 700; line-height: 20px; animation: popBadge .3s var(--spring) both;
}
@media (hover: hover) { .cs-fail:hover { filter: brightness(1.1); } }

/* 图片消息 */
.cs-img { position: relative; border-radius: 12px; overflow: hidden; background: var(--fill-2); max-width: 200px; min-width: 64px; min-height: 64px; cursor: zoom-in; box-shadow: var(--shadow-card); }
.cs-img img { display: block; max-width: 200px; max-height: 240px; width: auto; height: auto; object-fit: cover; }
.cs-img.up img { filter: brightness(.6); }
.cs-prog { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; font-weight: 600; font-family: var(--font-num); text-shadow: 0 1px 4px rgba(0,0,0,.4); }
.cs-img-bad { display: flex; align-items: center; justify-content: center; width: 120px; height: 80px; font-size: 12px; color: var(--text-3); }

/* 订单卡片 */
.cs-order {
  width: 232px; max-width: 100%; padding: 12px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow-card);
  cursor: pointer; transition: transform .15s ease, box-shadow .2s ease; text-align: left; border: 1px solid var(--line);
}
.cs-order:active { transform: scale(.98); }
@media (hover: hover) { .cs-order:hover { box-shadow: var(--shadow-2); } }
.cs-order-hd { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); padding-bottom: 8px; border-bottom: 1px dashed var(--line); margin-bottom: 8px; }
.cs-order-hd .ic { font-size: 14px; color: var(--brand); }
.cs-order-st { margin-left: auto; color: var(--brand-text); font-weight: 500; }
.cs-order-title { font-size: 15px; font-weight: 600; color: var(--text-1); margin-bottom: 4px; }
.cs-order-title .num { font-size: 18px; }
.cs-order-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-3); line-height: 20px; }
.cs-order-row span:last-child { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 评价卡片 */
.cs-rate { width: 248px; max-width: 100%; padding: 16px; border-radius: 4px 16px 16px 16px; background: var(--card); box-shadow: var(--shadow-card); text-align: center; }
.cs-rate-title { font-size: 14px; font-weight: 600; color: var(--text-1); display: inline-flex; align-items: center; gap: 6px; }
.cs-rate-title .ic { color: var(--brand); font-size: 16px; }
.cs-stars { display: flex; justify-content: center; gap: 4px; margin: 12px 0 4px; }
.cs-star { border: none; background: none; padding: 2px; width: 34px; height: 34px; cursor: pointer; transition: transform .15s var(--spring); }
.cs-star svg { width: 100%; height: 100%; fill: var(--fill-2); stroke: var(--text-4); stroke-width: 1; transition: fill .15s ease, stroke .15s ease; }
.cs-star.on svg { fill: #FFB020; stroke: #FFB020; }
.cs-star:not(:disabled):active { transform: scale(.85); }
@media (hover: hover) { .cs-star:not(:disabled):hover { transform: scale(1.12); } }
.cs-star:disabled { cursor: default; }
.cs-rate-label { font-size: 12px; color: var(--text-3); min-height: 18px; }
.cs-rate-input {
  width: 100%; margin: 8px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--fill);
  font: inherit; font-size: 13px; color: var(--text-1); resize: none; outline: none; transition: border-color .15s;
}
.cs-rate-input:focus { border-color: var(--brand); }
.cs-rate-submit { width: 100%; height: 36px; font-size: 14px; }
.cs-rate.done { padding: 12px 16px; }
.cs-rate.done .cs-stars { margin: 8px 0 0; }
.cs-rate.done .cs-star { width: 24px; height: 24px; }

/* 新消息提示 */
.cs-new {
  position: absolute; right: 16px; bottom: calc(var(--kb, 0px) + 88px + var(--safe-b)); z-index: 6;
  height: 32px; padding: 0 12px; border: none; border-radius: var(--r-full); background: var(--card); color: var(--brand-text);
  font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; box-shadow: var(--shadow-2);
  animation: fadeUp .25s var(--ease-out) both;
}
.cs-new .ic { font-size: 14px; }

/* 加载 / 维护 */
.cs-state { min-height: 60%; display: flex; align-items: center; justify-content: center; }
.cs-down { text-align: center; padding: 48px 24px; animation: fadeUp .3s var(--ease-out) backwards; }
.cs-down-ic { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 16px; background: var(--brand-light); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 34px; }
.cs-down-t { font-size: 17px; font-weight: 600; }
.cs-down-s { margin: 8px 0 24px; font-size: 13px; color: var(--text-3); line-height: 1.7; }
.cs-skel { width: 100%; padding-top: 8px; }
.cs-sk { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.cs-sk.r { align-items: flex-end; }
.cs-sk .sk { height: 36px; width: 140px; border-radius: 14px; }

/* ---------------- 输入区 ---------------- */
.cs-compose {
  flex-shrink: 0; position: relative; z-index: 4;
  background: var(--bar-bg); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -.5px 0 var(--line); padding-bottom: var(--safe-b);
}
#pgCs.kb .cs-compose { padding-bottom: 0; }
.cs-bar { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px; }
.cs-tool {
  width: 40px; height: 40px; flex-shrink: 0; border: none; border-radius: 50%; background: none; color: var(--text-2);
  font-size: 26px; display: flex; align-items: center; justify-content: center; transition: transform .2s var(--spring), color .15s, background-color .15s;
}
.cs-tool.on { color: var(--brand); }
#csPlus.on { transform: rotate(45deg); }
@media (hover: hover) { .cs-tool:hover { background: var(--fill); } }
.cs-input {
  flex: 1; min-width: 0; height: 40px; max-height: 120px; padding: 9px 12px; border: none; border-radius: 20px; outline: none; resize: none;
  background: var(--card); color: var(--text-1); font: inherit; font-size: 15px; line-height: 22px; box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow .15s ease;
}
.cs-input:focus { box-shadow: inset 0 0 0 1.5px var(--brand); }
.cs-input::placeholder { color: var(--text-4); }
.cs-send { height: 40px; padding: 0 16px; font-size: 15px; flex-shrink: 0; animation: popBadge .25s var(--spring) both; }

/* 猜你想问 / 订单提示条 */
.cs-faq { display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px 0; scrollbar-width: none; align-items: center; }
.cs-faq::-webkit-scrollbar { display: none; }
.cs-faq-t { flex-shrink: 0; font-size: 12px; color: var(--text-3); }
.cs-chip {
  flex-shrink: 0; height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-full); background: var(--card);
  color: var(--text-1); font-size: 13px; white-space: nowrap; transition: border-color .15s, color .15s, transform .15s;
}
.cs-chip:active { transform: scale(.96); }
@media (hover: hover) { .cs-chip:hover { border-color: var(--brand); color: var(--brand-text); } }
.cs-order-tip {
  display: flex; align-items: center; gap: 8px; margin: 8px 12px 0; padding: 8px 4px 8px 12px; border-radius: var(--r-lg);
  background: var(--card); box-shadow: var(--shadow-card); border: 1px solid var(--line); animation: fadeUp .25s var(--ease-out) both;
}
.cs-tip-ic { width: 32px; height: 32px; border-radius: 10px; background: var(--brand-light); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.cs-tip-main { flex: 1; min-width: 0; }
.cs-tip-t { font-size: 13px; font-weight: 500; }
.cs-tip-s { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-order-tip .btn-sm { flex-shrink: 0; }
.cs-order-tip .icon-btn { font-size: 16px; }

/* 表情 / 更多面板 */
.cs-panel { border-top: 1px solid var(--line); animation: fadeIn .2s ease both; }
.cs-emoji { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; padding: 12px; max-height: 216px; overflow-y: auto; }
.cs-emo { height: 40px; border: none; background: none; border-radius: var(--r-md); font-size: 24px; line-height: 1; padding: 0; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; transition: transform .15s var(--spring), background-color .15s; }
.cs-emo:active { transform: scale(1.25); }
@media (hover: hover) { .cs-emo:hover { background: var(--fill); } }
.cs-emo.del { font-size: 20px; color: var(--text-2); display: flex; align-items: center; justify-content: center; }
.cs-more { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; padding: 16px 16px 20px; }
.cs-more-it { border: none; background: none; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.cs-more-it span { width: 56px; height: 56px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow-card); display: flex; align-items: center; justify-content: center; font-size: 26px; color: var(--text-1); transition: transform .15s ease; }
.cs-more-it:active span { transform: scale(.94); }
.cs-more-it:disabled { opacity: .4; cursor: not-allowed; }
@media (hover: hover) { .cs-more-it:not(:disabled):hover span { color: var(--brand); } }

/* 选择订单弹层 */
.cs-pick-list { overflow-y: auto; min-height: 160px; }
.cs-pick-loading { display: flex; align-items: center; justify-content: center; gap: 8px; height: 120px; font-size: 13px; color: var(--text-3); }
.cs-pick {
  width: 100%; border: none; background: none; display: flex; align-items: center; gap: 12px; padding: 12px 4px; text-align: left;
  border-bottom: 1px solid var(--line); border-radius: var(--r-md); transition: background-color .15s;
}
.cs-pick:last-child { border-bottom: none; }
@media (hover: hover) { .cs-pick:hover { background: var(--fill); } }
.cs-pick:active { background: var(--fill-2); }
.cs-pick-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cs-pick-t { font-size: 14px; font-weight: 600; color: var(--text-1); }
.cs-pick-s { font-size: 12px; color: var(--text-3); }
.cs-pick-r { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 15px; font-weight: 600; color: var(--text-1); }

/* 图片全屏预览 */
.cs-viewer {
  position: absolute; inset: 0; z-index: 250; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s ease; cursor: zoom-out; padding: var(--safe-t) 0 var(--safe-b);
}
.cs-viewer.show { opacity: 1; }
.cs-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; transform: scale(.94); transition: transform .25s var(--ease-out); }
.cs-viewer.show img { transform: none; }
.cs-viewer-x { position: absolute; right: 12px; top: calc(var(--safe-t) + 12px); width: 40px; height: 40px; border: none; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: 20px; display: flex; align-items: center; justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  .cs-fab, .cs-row, .cs-event { animation: none !important; }
}
