/* web-kefu 工作台 components.css —— 导航栏 / 连接条 / Toast / 对话框 / 会话列表 / 聊天区 / 气泡 / 输入区 / 访客栏 */

/* ---- 左导航栏 64px ---- */
.rail { width: 64px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 0; background: var(--surface); border-right: 1px solid var(--border); }
.rail-brand { width: 40px; height: 40px; border-radius: var(--r-card); background: var(--brand-600); color: var(--brand-contrast); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: var(--fs-lg); margin-bottom: 12px; }
.rail-item { position: relative; width: 52px; height: 52px; border-radius: var(--r-btn); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-secondary); cursor: pointer; transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.rail-item svg { width: 22px; height: 22px; }
.rail-label { font-size: 10px; line-height: 1; }
.rail-item:hover { background: var(--bg-sunken); color: var(--text); }
.rail-item.is-active { background: var(--brand-50); color: var(--brand-600); }
.rail-badge { position: absolute; top: 4px; right: 4px; }
.rail-spacer { flex: 1; }
.rail-me { padding: 6px 0; }

/* ---- 连接状态条 ---- */
.conn-bar { display: flex; align-items: center; gap: 10px; padding: 6px 16px; font-size: var(--fs-sm); background: var(--accent-soft); color: var(--text); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.conn-bar.is-connecting { background: var(--bg-sunken); color: var(--text-secondary); }
.conn-bar.is-unsupported, .conn-bar.is-closed { background: var(--danger-soft); }
.conn-bar .btn { margin-left: auto; height: 26px; }

/* ---- Toast ---- */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--brand-600); border-radius: var(--r-card); box-shadow: var(--shadow-md); pointer-events: auto; font-size: var(--fs-sm); }
.toast > svg { margin-top: 1px; color: var(--brand-600); }
.toast-success { border-left-color: var(--success); } .toast-success > svg { color: var(--success); }
.toast-error { border-left-color: var(--danger); } .toast-error > svg { color: var(--danger); }
.toast-warn { border-left-color: var(--accent); } .toast-warn > svg { color: var(--accent); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-msg { color: var(--text-secondary); word-break: break-word; }
.toast-close { color: var(--text-muted); width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-sm); flex-shrink: 0; }
.toast-close:hover { background: var(--bg-sunken); color: var(--text); }
.toast-enter-active, .toast-leave-active { transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease); }
.toast-enter-from, .toast-leave-to { opacity: 0; transform: translateY(-6px); }

/* ---- 遮罩 / 确认框 ---- */
.overlay { position: fixed; inset: 0; z-index: 900; background: rgba(28, 25, 23, 0.4); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-md); padding: 22px 22px 18px; }
.dialog-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--brand-50); color: var(--brand-600); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.dialog-icon.is-danger { background: var(--danger-soft); color: var(--danger); }
.dialog-title { font-size: var(--fs-lg); margin-bottom: 6px; }
.dialog-msg { color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.fade-enter-active, .fade-leave-active { transition: opacity var(--dur-fast) var(--ease); }
.fade-enter-from, .fade-leave-to { opacity: 0; }

/* ---- 会话列表 320px ---- */
.convlist { width: 320px; flex-shrink: 0; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); min-height: 0; }
.convlist-head { padding: 14px 14px 0; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.convlist-titlebar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.convlist-title { font-size: var(--fs-lg); }
.tabs { display: flex; gap: 2px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; padding: 8px 10px 9px; font-size: var(--fs-sm); font-weight: 500; color: var(--text-secondary); border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; transition: color var(--dur-fast) var(--ease); margin-bottom: -1px; border-radius: var(--r-sm) var(--r-sm) 0 0; }
.tab:hover { color: var(--text); background: var(--surface-hover); }
.tab.is-active { color: var(--brand-600); border-bottom-color: var(--brand-600); }
.tab-count { min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-full); background: var(--accent-soft); color: var(--text); font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.tab.is-active .tab-count { background: var(--accent); color: #fff; }
.convlist-body { flex: 1; overflow-y: auto; min-height: 0; }
.conv { display: flex; gap: 10px; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid var(--border); position: relative; transition: background-color var(--dur-fast) var(--ease); }
.conv:hover { background: var(--surface-hover); }
.conv:focus-visible { box-shadow: inset var(--focus-ring); }
.conv.is-active { background: var(--brand-50); }
.conv.is-active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-600); }
.conv-avatar { position: relative; flex-shrink: 0; }
.conv-dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border: 2px solid var(--surface); }
.conv.is-active .conv-dot { border-color: var(--brand-50); }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.conv-top, .conv-bottom { display: flex; align-items: center; gap: 8px; }
.conv-name { flex: 1; font-weight: 500; }
.conv-time { flex-shrink: 0; }
.conv-preview { flex: 1; font-size: var(--fs-sm); color: var(--text-muted); }
.conv.is-unread .conv-preview { color: var(--text-secondary); font-weight: 500; }
.conv.is-unread .conv-name { font-weight: 600; }
.conv-typing { color: var(--brand-600); }
.conv.is-closed .conv-name { color: var(--text-secondary); }
.conv-bottom .tag { max-width: 96px; }
.conv-skeleton .conv { cursor: default; }
.conv-skeleton .conv-top { justify-content: space-between; }
.convlist-more { padding: 12px; text-align: center; }

/* ---- 聊天区 ---- */
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--bg); }
.chat-empty { height: 100%; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 0 12px 0 16px; height: 60px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-back { display: none; margin-left: -8px; }
.chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.chat-title strong { font-weight: 600; font-size: var(--fs-md); }
.chat-sub { display: flex; align-items: center; gap: 5px; min-width: 0; }
.chat-typing { color: var(--brand-600); }
.chat-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chat-body { flex: 1; overflow-y: auto; padding: 12px 20px 16px; display: flex; flex-direction: column; gap: 2px; position: relative; min-height: 0; overscroll-behavior: contain; }
.chat-more { text-align: center; padding: 4px 0 8px; min-height: 30px; }
.chat-body > .state { margin: auto 0; }
.date-sep { display: flex; align-items: center; justify-content: center; margin: 10px 0 8px; }
.date-sep span { font-size: var(--fs-xs); color: var(--text-muted); background: var(--bg-sunken); padding: 2px 10px; border-radius: var(--r-full); }
.msg-system { text-align: center; margin: 6px 0; font-size: var(--fs-xs); color: var(--bubble-system-text); }
.msg-system span { display: inline-block; max-width: 80%; line-height: 1.6; }

/* ---- 气泡 ---- */
.msg { display: flex; gap: 8px; margin: 3px 0; max-width: 100%; animation: kf-fade-up var(--dur-base) var(--ease) both; }
.msg.is-own { flex-direction: row-reverse; }
.msg-avatar { flex-shrink: 0; align-self: flex-end; margin-bottom: 20px; }
.msg-main { display: flex; flex-direction: column; max-width: min(72%, 560px); min-width: 0; }
.msg.is-own .msg-main { align-items: flex-end; }
.msg-name { font-size: var(--fs-xs); color: var(--text-muted); margin: 0 4px 3px; }
.msg-row { display: flex; align-items: center; gap: 6px; max-width: 100%; }
.msg.is-own .msg-row { flex-direction: row-reverse; }
.msg-fail-actions { display: flex; gap: 2px; flex-shrink: 0; }
.msg-retry { color: var(--danger); }
.bubble { position: relative; max-width: 100%; padding: 9px 13px; border-radius: var(--r-bubble); font-size: var(--fs-md); line-height: var(--lh); word-break: break-word; overflow-wrap: anywhere; }
.msg.is-other .bubble { background: var(--bubble-other-bg); color: var(--bubble-other-text); border: 1px solid var(--bubble-other-border); border-bottom-left-radius: var(--r-bubble-tail); }
.msg.is-own .bubble { background: var(--bubble-own-bg); color: var(--bubble-own-text); border-bottom-right-radius: var(--r-bubble-tail); }
.msg.is-pending .bubble { opacity: .75; }
.bubble-text { white-space: pre-wrap; }
.bubble-image, .bubble-video { padding: 4px; }
.bubble-img { display: block; padding: 0; border-radius: 12px; overflow: hidden; cursor: zoom-in; background: var(--bg-sunken); max-width: 280px; }
.bubble-img img { display: block; max-width: 280px; max-height: 320px; width: auto; height: auto; object-fit: cover; min-width: 80px; min-height: 60px; }
.bubble-video { display: block; max-width: 320px; max-height: 320px; border-radius: 12px; background: #000; width: 100%; }
.msg.is-own .bubble-image, .msg.is-own .bubble-video { background: var(--surface); border: 1px solid var(--border); }
.bubble-caption { margin-top: 6px; padding: 0 4px 2px; font-size: var(--fs-sm); white-space: pre-wrap; }
.msg.is-own .bubble-image .bubble-caption, .msg.is-own .bubble-video .bubble-caption { color: var(--text); }
.bubble-file { display: flex; align-items: center; gap: 10px; min-width: 200px; max-width: 320px; color: inherit; text-decoration: none; }
.bubble-file:hover { text-decoration: none; }
.file-icon { width: 36px; height: 36px; border-radius: 10px; background: rgba(0,0,0,0.06); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.msg.is-own .file-icon { background: rgba(255,255,255,0.18); }
.file-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-name { font-weight: 500; }
.file-size { font-size: var(--fs-xs); opacity: .75; }
.file-dl { flex-shrink: 0; opacity: .8; }
.bubble-progress { height: 3px; background: rgba(0,0,0,0.08); border-radius: 2px; overflow: hidden; margin: 6px 4px 2px; }
.msg.is-own .bubble-progress { background: rgba(255,255,255,0.25); }
.bubble-progress-bar { height: 100%; background: var(--brand-600); transition: width var(--dur-fast) linear; }
.msg.is-own .bubble-progress-bar { background: #fff; }
.msg-foot { display: flex; align-items: center; gap: 6px; margin: 3px 4px 0; font-size: 11px; color: var(--text-muted); }
.msg-status.is-failed { color: var(--danger); }
.msg-status.is-read { color: var(--brand-600); }

/* ---- 语音气泡 ---- */
.audio { display: flex; align-items: center; gap: 8px; min-width: 200px; max-width: 280px; height: 32px; }
.audio-btn { width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,0.06); color: inherit; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background-color var(--dur-fast) var(--ease); }
.audio-btn:hover { background: rgba(0,0,0,0.12); }
.audio.is-own .audio-btn { background: rgba(255,255,255,0.2); } .audio.is-own .audio-btn:hover { background: rgba(255,255,255,0.32); }
.audio-bars { flex: 1; height: 24px; display: flex; align-items: center; gap: 2px; cursor: pointer; }
.audio-bar { flex: 1; min-width: 2px; border-radius: 2px; background: currentColor; opacity: .3; transition: opacity var(--dur-fast) var(--ease); }
.audio-bar.is-on { opacity: .95; }
.audio-time { font-size: var(--fs-xs); flex-shrink: 0; min-width: 32px; text-align: right; }
.audio-err { font-size: var(--fs-xs); color: var(--danger); }
.audio.is-own .audio-err { color: #fff; }
/* ---- 正在输入 / 新消息跳转 / 已关闭条 / 拖拽提示 ---- */
.typing-row { animation: none; }
.bubble-typing { display: flex; gap: 4px; align-items: center; height: 36px; padding: 0 14px; }
.bubble-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: kf-typing 1.2s ease-in-out infinite; }
.bubble-typing span:nth-child(2) { animation-delay: .15s; } .bubble-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes kf-typing { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }
.chat-jump { position: absolute; left: 50%; bottom: 132px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 12px; border-radius: var(--r-full); background: var(--brand-600); color: #fff; font-size: var(--fs-sm); font-weight: 500; box-shadow: var(--shadow-md); z-index: 2; animation: kf-fade-up var(--dur-base) var(--ease) both; }
.chat-jump:hover { background: var(--brand-700); }
.chat-closed { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px 16px; background: var(--surface); border-top: 1px solid var(--border); color: var(--text-secondary); font-size: var(--fs-sm); flex-wrap: wrap; }
.drop-hint { position: sticky; inset: 0; margin: -12px -20px -16px; min-height: 100%; background: rgba(240, 253, 250, 0.92); border: 2px dashed var(--brand-500); border-radius: var(--r-card); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--brand-700); font-weight: 500; z-index: 3; pointer-events: none; }

/* ---- 输入区 ---- */
.composer { position: relative; background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0; }
.composer-main { padding: 8px 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.composer-input { width: 100%; border: 0; background: transparent; resize: none; padding: 8px 6px; font-size: var(--fs-md); line-height: var(--lh); max-height: 168px; overflow-y: auto; outline: none; min-height: 38px; }
.composer-input:focus { box-shadow: none; }
.composer-input::placeholder { color: var(--text-muted); }
.composer-tools { display: flex; align-items: center; gap: 2px; }
.composer-count { margin-right: 8px; }
.composer-send { padding: 0 14px; }
.rec-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; min-height: 60px; background: var(--accent-soft); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); animation: kf-pulse-ring 1.4s ease-out infinite; flex-shrink: 0; }
.rec-text { font-weight: 500; }
.rec-time { color: var(--text-secondary); font-size: var(--fs-sm); }

/* ---- 快捷回复弹层 ---- */
.quick-pop { position: absolute; left: 12px; right: 12px; bottom: calc(100% + 6px); max-width: 560px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-md); z-index: 5; display: flex; flex-direction: column; max-height: 320px; animation: kf-fade-up var(--dur-fast) var(--ease) both; }
.quick-pop-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 6px 12px; border-bottom: 1px solid var(--border); }
.quick-pop-search { margin: 8px 10px 4px; width: auto; height: 32px; }
.quick-pop-empty { padding: 20px 14px; text-align: center; color: var(--text-muted); font-size: var(--fs-sm); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.quick-pop-list { overflow-y: auto; padding: 4px; }
.quick-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: var(--r-btn); cursor: pointer; }
.quick-item.is-active { background: var(--brand-50); }
.quick-item-title { font-weight: 500; font-size: var(--fs-sm); }
.quick-item-content { font-size: var(--fs-xs); color: var(--text-muted); }

/* ---- 图片放大 ---- */
.lightbox { position: fixed; inset: 0; z-index: 950; background: rgba(28, 25, 23, 0.86); display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; animation: kf-fade-in var(--dur-fast) var(--ease) both; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--r-sm); cursor: default; box-shadow: var(--shadow-md); }
.lightbox-close { position: absolute; top: 12px; right: 12px; color: #fff; }
.lightbox-close:hover { background: rgba(255,255,255,0.15); color: #fff; }
.lightbox-dl { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); }
@keyframes kf-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- 右侧访客信息 280px ---- */
.vpanel { width: 280px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.vpanel-head { display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 0 10px 0 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.vpanel-head h3 { font-size: var(--fs-md); }
.vpanel-body { flex: 1; overflow-y: auto; padding: 16px; }
.vpanel-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0 16px; text-align: center; }
.vpanel-name { font-weight: 600; font-size: var(--fs-lg); word-break: break-all; }
.vpanel-sub { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin: 16px 0 6px; }
.kv { margin: 0; }
.kv-row { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); align-items: baseline; }
.kv-row:last-child { border-bottom: 0; }
.kv-row dt { width: 76px; flex-shrink: 0; color: var(--text-muted); }
.kv-row dd { margin: 0; flex: 1; min-width: 0; color: var(--text); word-break: break-word; overflow: hidden; text-overflow: ellipsis; }
.kv-link { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vpanel-ua { margin-top: 16px; font-size: var(--fs-xs); }
.vpanel-ua summary { cursor: pointer; color: var(--text-muted); user-select: none; }
.vpanel-ua code { display: block; margin-top: 6px; padding: 8px; background: var(--bg-sunken); border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 11px; word-break: break-all; color: var(--text-secondary); line-height: 1.5; }
.vpanel-skeleton .kv-row { justify-content: space-between; }

/* ---- 子页面零件：快捷回复 / 客服 / 设置 ---- */
.page-search { width: 220px; }
.card-title { font-size: var(--fs-md); font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.qr-form { margin-bottom: 16px; }
.qr-form-title { font-size: var(--fs-md); margin-bottom: 14px; }
.qr-list { overflow: hidden; }
.qr-item { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.qr-item:last-child { border-bottom: 0; }
.qr-item.is-busy { opacity: .6; }
.qr-title { font-weight: 500; margin-bottom: 2px; }
.qr-content { font-size: var(--fs-sm); color: var(--text-secondary); white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.qr-actions { display: flex; gap: 2px; flex-shrink: 0; }
.qr-del:hover { color: var(--danger); background: var(--danger-soft); }
kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .field + .field { margin-top: 0; }
.input-group { display: flex; align-items: center; gap: 4px; }
.input-group .input { flex: 1; }
.table .is-disabled td { color: var(--text-muted); }
.th-actions, .td-actions { text-align: right; white-space: nowrap; }
.td-actions .btn + .btn { margin-left: 4px; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.settings-side { display: flex; flex-direction: column; gap: 16px; }
.pref-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.pref-row:last-of-type { border-bottom: 0; }
.pref-row > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pref-title { font-weight: 500; }
.switch { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: var(--r-full); background: var(--border-strong); position: relative; cursor: pointer; flex-shrink: 0; transition: background-color var(--dur-fast) var(--ease); margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur-fast) var(--ease); }
.switch:checked { background: var(--brand-600); }
.switch:checked::after { transform: translateX(16px); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--bg); border-radius: var(--r-btn); }
.stat-num { font-size: var(--fs-2xl); font-weight: 600; line-height: 1.2; }
.stat-label { font-size: var(--fs-xs); color: var(--text-muted); }
