/* ============ 设计变量 ============ */
:root {
  --primary: #3370ff;
  --primary-hover: #2b62e6;
  --primary-active: #2154cc;
  --primary-soft: #ebf1ff;
  --primary-ring: rgba(51, 112, 255, 0.16);
  --success: #12a150;
  --success-soft: #e7f7ee;
  --warning: #e08a00;
  --warning-soft: #fff5e3;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --text: #1f2329;
  --text-2: #4e5969;
  --text-3: #86909c;
  --text-4: #c2c8d0;
  --border: #e3e5e9;
  --border-2: #f0f1f3;
  --bg: #f3f4f6;
  --bg-2: #f7f8fa;
  --panel: #ffffff;
  --bubble-mine: var(--primary);
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 10px rgba(31, 35, 41, 0.08);
  --shadow-lg: 0 12px 40px rgba(31, 35, 41, 0.16);
  --font: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[v-cloak] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--primary); }
.ui-icon { display: block; flex-shrink: 0; }
.muted { color: var(--text-3); }
.ml-auto { margin-left: auto; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 14px; white-space: nowrap; cursor: pointer;
  text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-primary:active { background: var(--primary-active); }
.btn-primary:disabled:hover { background: var(--primary); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #d63a3f; border-color: #d63a3f; color: #fff; }
.btn-text { border-color: transparent; background: transparent; padding: 0 8px; }
.btn-text:hover { background: var(--bg); border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 42px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-dashed { border-style: dashed; color: var(--text-2); }

.icon-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-2); border-radius: 6px; cursor: pointer;
  transition: background .15s, color .15s; padding: 0;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.xs { width: 22px; height: 22px; border-radius: 4px; }
.link-btn { border: none; background: none; color: var(--primary); cursor: pointer; font-size: 12px; padding: 4px 8px; }

/* ============ 表单 ============ */
.input, .textarea, .select {
  width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; font-size: 14px;
}
.textarea { height: auto; padding: 8px 12px; resize: vertical; line-height: 1.55; display: block; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.input-sm { height: 30px; font-size: 13px; padding: 0 10px; }
.input-lg { height: 42px; font-size: 15px; }
.form-item { margin-bottom: 16px; }
.form-item > label { display: block; margin-bottom: 6px; color: var(--text-2); font-size: 13px; }
.form-tip { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.form-error { color: var(--danger); font-size: 13px; margin: -4px 0 12px; }

.switch { position: relative; display: inline-flex; width: 40px; height: 22px; flex-shrink: 0; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--text-4); border-radius: 11px; transition: background .2s; }
.switch span::after { content: ''; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-ring); }

/* ============ 标签 / 徽标 / 头像 ============ */
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px;
  font-weight: 600; line-height: 1; flex-shrink: 0;
}
.badge-warn { background: var(--warning); }
.badge-muted { background: var(--text-4); }
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 4px;
  font-size: 12px; background: var(--bg); color: var(--text-2); white-space: nowrap; flex-shrink: 0;
}
.tag-primary { background: var(--primary-soft); color: var(--primary); }
.tag-success { background: var(--success-soft); color: var(--success); }
.tag-warning { background: var(--warning-soft); color: var(--warning); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }

.avatar {
  position: relative; width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 14px; user-select: none;
}
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }
.avatar .dot {
  position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid #fff; background: var(--text-4);
}
.avatar .dot.on { background: var(--success); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: var(--text-4); }
.s-online { background: var(--success); }
.s-busy { background: var(--danger); }
.s-away { background: var(--warning); }
.s-offline { background: var(--text-4); }

/* ============ 弹窗 / 提示 / 预览 ============ */
.modal-mask {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(15, 18, 24, 0.45); animation: fade-in .15s;
}
.modal {
  width: 460px; max-width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: pop-in .18s ease-out;
}
.modal-sm { width: 380px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; font-size: 16px; font-weight: 600; }
.modal-body { padding: 6px 20px 8px; overflow-y: auto; }
.confirm-body { color: var(--text-2); line-height: 1.6; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; }

.ui-toast-wrap {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 3000;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.ui-toast {
  max-width: min(420px, 86vw); padding: 9px 16px; border-radius: 8px; font-size: 14px; color: #fff;
  background: rgba(31, 35, 41, 0.9); box-shadow: var(--shadow); animation: toast-in .2s ease-out; transition: opacity .2s;
}
.ui-toast.success { background: var(--success); }
.ui-toast.error { background: var(--danger); }
.ui-toast.leave { opacity: 0; }

.lightbox {
  position: fixed; inset: 0; z-index: 1500; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.86); cursor: zoom-out; animation: fade-in .15s;
}
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 4px; box-shadow: 0 8px 40px rgba(0, 0, 0, .5); }

.emoji-panel {
  position: absolute; bottom: calc(100% + 6px); left: 8px; z-index: 50;
  width: 336px; max-width: calc(100vw - 24px); max-height: 232px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.emoji-panel button { height: 36px; padding: 0; border: none; background: transparent; border-radius: 6px; font-size: 22px; line-height: 1; cursor: pointer; }
.emoji-panel button:hover { background: var(--bg); }

.drop-mask {
  position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--primary); background: rgba(51, 112, 255, 0.08); color: var(--primary);
  font-size: 15px; pointer-events: none;
}

.scroll { overflow-y: auto; }
.scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .14); border-radius: 3px; }
.scroll::-webkit-scrollbar-track { background: transparent; }

.spinner {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(0, 0, 0, .1); border-top-color: var(--primary); animation: spin .8s linear infinite;
}
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 40px 16px; color: var(--text-3); text-align: center; }
.empty.small { padding: 28px 16px; font-size: 13px; }
.load-more { display: flex; justify-content: center; padding: 4px 0; }
.conn-bar { flex-shrink: 0; padding: 6px 12px; text-align: center; font-size: 12px; color: #9a5b00; background: var(--warning-soft); }

/* ============ 消息气泡（访客端 / 客服端共用） ============ */
.msg-list { display: flex; flex-direction: column; gap: 14px; padding: 16px; }
.msg-divider { align-self: center; font-size: 12px; color: var(--text-3); }
.msg-system {
  align-self: center; max-width: 86%; padding: 4px 12px; border-radius: 12px;
  font-size: 12px; color: var(--text-3); background: rgba(0, 0, 0, .045); text-align: center;
}
.msg { display: flex; align-items: flex-start; gap: 8px; max-width: 100%; }
.msg.mine { flex-direction: row-reverse; }
.msg-main { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: min(74%, 560px); }
.msg.mine .msg-main { align-items: flex-end; }
.msg-name { margin-bottom: 4px; font-size: 12px; color: var(--text-3); }
.msg-time { margin-left: 6px; color: var(--text-4); }
.msg-row { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.msg.mine .msg-row { flex-direction: row-reverse; }
.bubble {
  padding: 9px 12px; border-radius: 12px; background: #fff; color: var(--text);
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; line-height: 1.6; font-size: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04); min-width: 0;
}
.msg:not(.mine) .bubble { border-top-left-radius: 4px; }
.msg.mine .bubble { background: var(--bubble-mine); color: #fff; border-top-right-radius: 4px; }
.bubble a { color: inherit; text-decoration: underline; }
.msg:not(.mine) .bubble a { color: var(--primary); }
.msg .bubble.bubble-img { position: relative; padding: 0; overflow: hidden; background: var(--border-2); border-radius: 10px; cursor: zoom-in; }
.bubble-img img { display: block; max-width: 220px; max-height: 260px; object-fit: cover; }
.upload-mask { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .45); color: #fff; font-size: 13px; }
.msg .bubble.bubble-file {
  display: flex; align-items: center; gap: 10px; width: 250px; max-width: 100%;
  background: #fff; color: var(--text); border: 1px solid var(--border); text-decoration: none; cursor: pointer;
}
.file-icon { width: 38px; height: 38px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); }
.file-info { flex: 1; min-width: 0; white-space: normal; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.file-size { font-size: 12px; color: var(--text-3); }
.msg-state { display: flex; align-items: center; min-height: 18px; }
.msg-failed { display: flex; padding: 0; border: none; background: none; color: var(--danger); cursor: pointer; }
.msg-read { margin-top: 3px; font-size: 11px; color: var(--text-3); }
.msg-read.unread { color: var(--primary); }

.typing-dots { display: inline-flex; align-items: center; gap: 4px; height: 18px; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: dot-blink 1.2s infinite both; }
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }

@keyframes dot-blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 登录页（客服端、管理后台共用） ============ */
.login-page {
  min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px;
  background:
    radial-gradient(900px 500px at 10% 0%, #dfe8ff 0%, transparent 60%),
    radial-gradient(800px 500px at 100% 100%, #e3f0ff 0%, transparent 60%),
    var(--bg);
}
.login-card { width: 380px; max-width: 100%; padding: 36px 32px 32px; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); }
.login-logo {
  width: 50px; height: 50px; margin-bottom: 18px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2f66f5, #5b8dff); color: #fff; box-shadow: 0 6px 16px rgba(51, 112, 255, .3);
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-sub { margin: 6px 0 24px; color: var(--text-3); }


/* ============ 语音消息、商品卡片、通话浮窗（访客端、客服端共用） ============ */
.voice-bubble {
  display: inline-flex; align-items: center; gap: 8px; min-width: 80px; max-width: 100%; height: 38px; padding: 0 12px;
  border: none; border-radius: 10px; background: var(--bg-2); color: var(--text); cursor: pointer; font: inherit; font-size: 13px;
}
.voice-bubble .voice-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 14px; overflow: hidden; }
.voice-bubble .voice-wave i { width: 2px; border-radius: 1px; background: currentColor; opacity: .55; }
.voice-bubble .voice-wave i:nth-child(3n+1) { height: 6px; } .voice-bubble .voice-wave i:nth-child(3n+2) { height: 12px; } .voice-bubble .voice-wave i:nth-child(3n) { height: 9px; }
.voice-bubble.playing .voice-wave i { animation: voice-bar .8s ease-in-out infinite; }
.voice-bubble.playing .voice-wave i:nth-child(2n) { animation-delay: .2s; }
.voice-bubble .voice-sec { flex-shrink: 0; opacity: .8; font-variant-numeric: tabular-nums; }
@keyframes voice-bar { 0%, 100% { transform: scaleY(.5); } 50% { transform: scaleY(1.2); } }

.msg-card {
  display: flex; gap: 10px; width: 260px; max-width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text); text-decoration: none; text-align: left;
}
a.msg-card:hover { border-color: var(--primary); }
.msg-card-img { flex-shrink: 0; width: 64px; height: 64px; border-radius: 6px; object-fit: cover; background: var(--bg-2); }
.msg-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.msg-card-title { font-size: 13px; font-weight: 500; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all; }
.msg-card-desc { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-card-price { margin-top: auto; font-size: 14px; font-weight: 600; color: var(--danger); }
.msg-card-kind { font-size: 11px; color: var(--text-3); }

.record-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 13px;
}
.record-bar .rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: dot-blink 1s infinite; }
.record-bar .rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.record-bar .grow { flex: 1; }

.translated { margin-top: 6px; padding-top: 6px; border-top: 1px dashed currentColor; opacity: .85; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.translated small { display: block; font-size: 11px; opacity: .7; }

.kf-call {
  position: fixed; z-index: 3000; right: 20px; bottom: 20px; width: 320px; max-width: calc(100vw - 24px); overflow: hidden;
  border-radius: 16px; background: #1f2329; color: #fff; box-shadow: 0 16px 48px rgba(0, 0, 0, .35); animation: pop-in .2s ease;
}
.kf-call.kf-call-video:not(.kf-call-mini) { width: 480px; }
.kf-call-remote { display: block; width: 100%; max-height: 60vh; aspect-ratio: 4 / 3; object-fit: contain; background: #000; }
.kf-call-peer { display: flex; align-items: center; gap: 12px; padding: 22px 18px 8px; }
.kf-call-mini .kf-call-peer { padding: 12px 14px 4px; }
.kf-call-avatar {
  flex-shrink: 0; width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--primary); font-size: 20px; font-weight: 600;
}
.kf-call-mini .kf-call-avatar { width: 36px; height: 36px; font-size: 15px; }
.kf-call-avatar.ring { animation: call-ring 1.4s ease-out infinite; }
@keyframes call-ring { 0% { box-shadow: 0 0 0 0 rgba(51, 112, 255, .6); } 100% { box-shadow: 0 0 0 16px rgba(51, 112, 255, 0); } }
.kf-call-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.kf-call-info b, .kf-call-top b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kf-call-info span, .kf-call-top span { font-size: 12px; color: rgba(255, 255, 255, .7); font-variant-numeric: tabular-nums; }
.kf-call-top { position: absolute; left: 0; right: 0; top: 0; display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; background: linear-gradient(rgba(0, 0, 0, .55), transparent); }
.kf-call-local { position: absolute; right: 10px; top: 10px; width: 96px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: #000; border: 1px solid rgba(255, 255, 255, .25); }
.kf-call:not(.kf-call-video) .kf-call-local { position: static; display: block; width: calc(100% - 36px); margin: 8px 18px 0; }
.kf-call-actions { display: flex; justify-content: center; gap: 12px; padding: 14px 12px 16px; }
.kf-call-mini .kf-call-actions { padding: 8px 10px 12px; gap: 8px; }
.kf-call-btn {
  width: 42px; height: 42px; border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .14); color: #fff; cursor: pointer; transition: background .15s;
}
.kf-call-btn:hover { background: rgba(255, 255, 255, .24); }
.kf-call-btn.on { background: #fff; color: #1f2329; }
.kf-call-btn.off { background: rgba(229, 72, 77, .35); }
.kf-call-btn.danger { background: #e5484d; }
.kf-call-btn.ok { background: #12a150; }
.kf-call-incoming .kf-call-btn { width: 50px; height: 50px; }
@media (max-width: 520px) {
  .kf-call, .kf-call.kf-call-video:not(.kf-call-mini) { left: 12px; right: 12px; bottom: 12px; width: auto; }
}

/* ---------- 快捷回复里的图片：缩略图、删除按钮、添加按钮 ---------- */
.qr-imgs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.qr-thumb { position: relative; flex: none; width: 56px; height: 56px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--bg-2); }
.qr-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.qr-thumb.sm { width: 36px; height: 36px; border-radius: 4px; }
.qr-thumb-x {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; padding: 0; border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: rgba(31, 35, 41, .62); color: #fff; cursor: pointer;
}
.qr-thumb-x:hover { background: rgba(31, 35, 41, .82); }
.qr-add {
  flex: none; width: 56px; height: 56px; padding: 0; border: 1px dashed var(--border); border-radius: 6px; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-3); font-size: 11px; white-space: nowrap; cursor: pointer;
}
.qr-add:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.qr-add:disabled { cursor: default; opacity: .6; }
.qr-more { font-size: 12px; color: var(--text-3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
