/* ============ 客服工作台 ============ */
html, body { height: 100%; overflow: hidden; }
#app { height: 100%; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.boot { height: 100%; display: flex; align-items: center; justify-content: center; }

/* ---------- 布局 ---------- */
.workbench { display: flex; flex-direction: column; height: 100%; min-width: 1080px; }
.topbar {
  flex-shrink: 0; height: 56px; display: flex; align-items: center; gap: 20px; padding: 0 16px;
  background: #fff; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #2f66f5, #5b8dff); color: #fff; }
.topbar-stats { display: flex; gap: 18px; font-size: 13px; color: var(--text-3); }
.topbar-stats b { color: var(--text); font-weight: 600; margin-left: 2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.main { flex: 1; display: flex; min-height: 0; }

/* ---------- 下拉菜单 ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 100; min-width: 168px; padding: 4px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); animation: pop-in .12s ease-out;
}
.dropdown-menu.right { left: auto; right: 0; }
.dropdown-menu button {
  width: 100%; height: 34px; display: flex; align-items: center; gap: 8px; padding: 0 10px;
  border: none; border-radius: 6px; background: none; cursor: pointer; font-size: 14px; text-align: left; white-space: nowrap;
}
.dropdown-menu button:hover { background: var(--bg); }
.dropdown-menu button.danger { color: var(--danger); }
.dropdown-head { padding: 6px 10px 8px; margin-bottom: 4px; font-size: 12px; color: var(--text-3); border-bottom: 1px solid var(--border-2); }
.menu-hint { font-size: 12px; color: var(--text-3); }
.status-btn {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 12px;
  border: 1px solid var(--border); border-radius: 16px; background: #fff; cursor: pointer; font-size: 13px; white-space: nowrap; flex-shrink: 0;
}
.status-btn:hover { border-color: var(--text-4); }
.me-btn { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px; border: none; border-radius: 6px; background: none; cursor: pointer; }
.me-btn:hover { background: var(--bg); }

/* ---------- 标签页 ---------- */
.tabs { flex-shrink: 0; display: flex; padding: 0 8px; border-bottom: 1px solid var(--border); }
.tabs button {
  position: relative; flex: 1; height: 44px; display: flex; align-items: center; justify-content: center; gap: 6px;
  border: none; background: none; cursor: pointer; color: var(--text-2); font-size: 14px;
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--primary); font-weight: 600; }
.tabs button.on::after { content: ''; position: absolute; left: 22%; right: 22%; bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary); }

/* ---------- 会话列表 ---------- */
.sidebar { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; min-height: 0; background: #fff; border-right: 1px solid var(--border); }
.search {
  flex-shrink: 0; display: flex; align-items: center; gap: 6px; height: 32px; margin: 10px 12px; padding: 0 10px;
  border-radius: 6px; background: var(--bg); color: var(--text-3); cursor: text;
}
.search input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 13px; }
.conv-list { flex: 1; overflow-y: auto; }
.conv-item { display: flex; gap: 10px; padding: 11px 14px 11px 11px; border-left: 3px solid transparent; cursor: pointer; transition: background .12s; }
.conv-item:hover { background: var(--bg-2); }
.conv-item.on { background: var(--primary-soft); border-left-color: var(--primary); }
.conv-body { flex: 1; min-width: 0; }
.conv-top, .conv-bottom { display: flex; align-items: center; gap: 8px; }
.conv-bottom { margin-top: 3px; }
.conv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.conv-time { flex-shrink: 0; font-size: 12px; color: var(--text-3); }
.conv-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-3); }
.typing-text { color: var(--primary); }

/* ---------- 聊天区 ---------- */
.chat-panel { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.chat-head { flex-shrink: 0; height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 20px; background: #fff; border-bottom: 1px solid var(--border); }
.chat-head-info { flex: 1; min-width: 0; }
.chat-head-name { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; min-width: 0; }
.chat-head-sub { font-size: 12px; color: var(--text-3); }
.chat-head-actions { display: flex; gap: 8px; }
.online-tag { flex-shrink: 0; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 400; background: var(--bg); color: var(--text-3); }
.online-tag.on { background: var(--success-soft); color: var(--success); }
.note-tag { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 400; background: var(--warning-soft); color: var(--warning); }
.chat-body { position: relative; flex: 1; overflow-y: auto; }
.new-tip {
  position: absolute; right: 24px; bottom: 200px; z-index: 20; display: flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 15px; background: #fff;
  color: var(--primary); font-size: 12px; box-shadow: var(--shadow); cursor: pointer;
}
.typing-preview {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 6px 20px;
  font-size: 12px; color: #8a6100; background: #fffbea; border-top: 1px solid #ffe8a3;
}
.typing-preview .typing-dots i { background: #d4a300; }

.composer-box { position: relative; flex-shrink: 0; height: 190px; display: flex; flex-direction: column; padding: 6px 16px 12px; background: #fff; border-top: 1px solid var(--border); }
.composer-box .toolbar { display: flex; align-items: center; gap: 2px; }
.toolbar-tip { margin-left: auto; font-size: 12px; color: var(--text-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-pending { display: flex; align-items: center; gap: 10px; padding: 6px 4px 2px; }
.composer-pending .qr-thumb { width: 44px; height: 44px; cursor: zoom-in; }
.composer-pending-tip { font-size: 12px; color: var(--text-3); }
.quick-images { margin-top: 6px; gap: 4px; }
.composer-input { flex: 1; padding: 6px 4px; border: none; outline: none; resize: none; font-size: 14px; line-height: 1.6; background: transparent; }
.composer-actions { display: flex; justify-content: flex-end; }
.composer-box .emoji-panel { left: 16px; }
.composer-locked {
  flex-shrink: 0; height: 76px; display: flex; align-items: center; justify-content: center; gap: 12px;
  color: var(--text-3); background: #fff; border-top: 1px solid var(--border);
}
.rating-inline { display: inline-flex; gap: 1px; color: var(--text-4); }
.rating-inline .on { color: #ffb400; }

.slash-panel {
  position: absolute; left: 16px; right: 16px; bottom: calc(100% - 2px); z-index: 40; max-height: 280px; overflow-y: auto;
  padding: 4px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg);
}
.slash-head { padding: 6px 10px; font-size: 12px; color: var(--text-3); }
.slash-item { display: flex; gap: 12px; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.slash-item b { flex-shrink: 0; font-weight: 500; }
.slash-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); }
.slash-item.on { background: var(--primary-soft); }

.welcome-empty { flex: 1; }
.welcome-icon { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 4px; }
.welcome-title { font-size: 16px; font-weight: 600; color: var(--text); }
.welcome-tip { margin-top: 8px; font-size: 12px; color: var(--text-4); }

/* ---------- 右侧信息栏 ---------- */
.info-panel { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; min-height: 0; background: #fff; border-left: 1px solid var(--border); }
.info-body { flex: 1; overflow-y: auto; padding: 16px; }
.visitor-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0 16px; border-bottom: 1px solid var(--border-2); }
.visitor-name-row { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 30px; width: 100%; }
.visitor-name-row .input { max-width: 180px; text-align: center; }
.visitor-name { font-size: 16px; font-weight: 600; }
.visitor-sub { font-size: 12px; color: var(--text-3); }
.info-section { padding: 14px 0; border-bottom: 1px solid var(--border-2); }
.info-section:last-child { border-bottom: none; }
.info-title { margin-bottom: 10px; font-size: 13px; font-weight: 600; }
.kv { display: grid; grid-template-columns: 64px 1fr; gap: 8px 10px; margin: 0; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; word-break: break-all; }
.kv dd a { color: var(--primary); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.history-item { margin: 0 -8px; padding: 8px; border-radius: 6px; cursor: pointer; }
.history-item:hover { background: var(--bg-2); }
.history-item.on { background: var(--primary-soft); }
.history-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-3); }
.history-preview { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

.quick-search { margin-bottom: 12px; }
.quick-item { margin-bottom: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; transition: border-color .12s, background .12s; }
.quick-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.quick-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.quick-title .ellipsis { flex: 1; }
.quick-content { margin-top: 4px; font-size: 12px; color: var(--text-2); white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.quick-add { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px dashed var(--border); border-radius: 8px; }

/* ---------- 转接弹窗 ---------- */
.agent-option { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.agent-option:hover { background: var(--bg-2); }
.agent-option.on { border-color: var(--primary); background: var(--primary-soft); }
.agent-option.disabled { opacity: .45; cursor: not-allowed; }
.agent-option-info { flex: 1; }
.agent-option .sub { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-3); }
.agent-option .check { color: var(--primary); }

@media (max-width: 1280px) {
  .info-panel { width: 260px; }
  .sidebar { width: 270px; }
  .toolbar-tip { display: none; }
}

/* 智能助手消息、拉黑、二次验证 */
.msg.from-bot .bubble { background: #eef3ff; color: var(--text); }
.danger-link { color: var(--danger); margin-top: 2px; }
.danger-link:hover { background: var(--danger-soft); color: var(--danger); }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.security-box { padding-top: 14px; border-top: 1px solid var(--border-2); }
.security-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.qr-box { width: 160px; height: 160px; margin: 4px 0 8px; }
.qr-box svg { width: 100%; height: 100%; }
.form-tip code { padding: 1px 4px; background: var(--bg); border-radius: 4px; word-break: break-all; }

/* 留言 */
.seg-row { flex-shrink: 0; display: flex; gap: 4px; margin: -2px 12px 8px; padding: 2px; border-radius: 8px; background: var(--bg); }
.seg-row button { flex: 1 1 auto; min-width: 0; height: 26px; padding: 0 4px; border: none; border-radius: 6px; background: none; color: var(--text-2); font-size: 12px; white-space: nowrap; cursor: pointer; }
.seg-row button.on { background: #fff; color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.leave-detail { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.leave-card { max-width: 640px; padding: 16px 18px; background: #fff; border: 1px solid var(--border); border-radius: 10px; }
.leave-kv { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border-2); grid-template-columns: 72px 1fr; }
.leave-content { white-space: pre-wrap; word-break: break-word; line-height: 1.7; }
.leave-reply { border-color: var(--primary-ring); background: var(--primary-soft); }
.leave-reply-head { margin-bottom: 6px; font-size: 12px; color: var(--text-3); }
.leave-composer { height: 170px; }
.assign-select { width: 120px; height: 28px; }
.msg-tag { margin-left: 6px; height: 18px; font-size: 11px; }
.rating-tags-inline { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }

/* 内部备注、撤回、插话、分类小结、质检 */
.note-card { align-self: center; width: min(92%, 560px); padding: 8px 12px; border: 1px dashed #e6c200; border-radius: 10px; background: #fffbe6; }
.note-head { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #8a6d00; }
.note-head .link-btn { margin-left: auto; padding: 0 4px; }
.note-body { margin-top: 4px; white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.6; }
.note-body b { color: var(--primary); font-weight: 600; }
.recall-btn { padding: 0 0 0 8px; font-size: 11px; }
.compose-tabs { display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.compose-tabs > button:not(.icon-btn) { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; border: none; border-radius: 6px; background: none; color: var(--text-2); font-size: 12px; cursor: pointer; }
.compose-tabs > button.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.compose-tabs .muted { font-weight: 400; }
.composer-box.note-mode { background: #fffdf2; }
.composer-box.note-mode .compose-tabs > button.on { background: #fff3bf; color: #8a6d00; }
.composer-locked { flex-wrap: wrap; padding: 0 16px; }
.summary-text { margin-top: 6px; font-size: 13px; color: var(--text-2); white-space: pre-wrap; }
.info-title .link-btn { float: right; padding: 0; }
.qa-row { display: flex; align-items: center; gap: 6px; }
.cat-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.day-pick { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 15px; background: #fff; cursor: pointer; font-size: 13px; }
.day-pick.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.req { margin-left: 2px; color: var(--danger); font-style: normal; }
.visitor-card .row-end { justify-content: center; }
/* 会话列表标签较多时不换行 */
.sidebar .tabs { padding: 0 4px; }
.sidebar .tabs button { gap: 3px; padding: 0 2px; font-size: 13px; white-space: nowrap; min-width: 0; }
.sidebar .tabs .badge { min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; }

/* ---------- 工单 ---------- */
.ticket-props { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-width: 640px; }
.ticket-props label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-3); }
.ticket-timeline { max-width: 640px; }
.tl-item { position: relative; padding: 0 0 12px 16px; border-left: 2px solid var(--border); margin-left: 4px; }
.tl-item::before { content: ''; position: absolute; left: -5px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--text-4); }
.tl-note::before { background: #e6c200; }
.tl-reply::before { background: var(--primary); }
.tl-overdue::before { background: var(--danger); }
.tl-head { display: flex; gap: 8px; align-items: baseline; font-size: 12px; }
.tl-body { margin-top: 2px; white-space: pre-wrap; word-break: break-word; font-size: 13px; color: var(--text-2); }
.tl-note .tl-body { padding: 6px 10px; border-radius: 6px; background: #fffbe6; color: var(--text); }
.tk-processing { background: var(--primary-soft); color: var(--primary); }
.tk-done, .tk-closed { background: var(--success-soft); color: var(--success); }
.tk-pending { background: var(--warning-soft); color: var(--warning); }
.tk-overdue { background: var(--danger-soft); color: var(--danger); }

/* ---------- 在线访客 ---------- */
.online-btn b { margin-left: 2px; color: var(--primary); }
.drawer-mask { justify-content: flex-end; padding: 0; }
.drawer { width: 440px; max-width: 100%; height: 100%; display: flex; flex-direction: column; background: #fff; box-shadow: var(--shadow-lg); animation: drawer-in .18s ease-out; }
.drawer .modal-header { border-bottom: 1px solid var(--border-2); padding-bottom: 14px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 4px 16px 16px; }
.ov-item { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border-2); }
.ov-info { flex: 1; min-width: 0; }
.ov-name { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.ov-page { margin-top: 2px; font-size: 13px; color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-sub { margin-top: 2px; font-size: 12px; color: var(--text-3); }
.ov-action { display: flex; align-items: center; }
@keyframes drawer-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 手机布局：一次显示一栏 ---------- */
.m-info-head { display: none; }
.workbench.is-mobile { min-width: 0; }
.is-mobile .topbar { gap: 8px; padding: 0 8px; }
.is-mobile .topbar-stats, .is-mobile .brand span, .is-mobile .m-hide, .is-mobile .toolbar-tip, .is-mobile .me-btn > span:not(.avatar) { display: none; }
.is-mobile .topbar-right { gap: 4px; }
.is-mobile .sidebar { width: 100%; border-right: none; }
.is-mobile .chat-panel, .is-mobile .info-panel { display: none; }
.is-mobile.mv-chat .sidebar, .is-mobile.mv-info .sidebar { display: none; }
.is-mobile.mv-chat .chat-panel { display: flex; width: 100%; }
.is-mobile.mv-info .info-panel { display: flex; width: 100%; }
.is-mobile .m-info-head { display: flex; align-items: center; gap: 6px; height: 48px; padding: 0 8px; border-bottom: 1px solid var(--border); }
.is-mobile .chat-head { gap: 6px; padding: 0 8px; }
.is-mobile .chat-head-actions { gap: 4px; flex-wrap: nowrap; overflow-x: auto; }
.is-mobile .chat-head-actions .btn { padding: 0 8px; }
.is-mobile .composer-box { height: auto; min-height: 150px; padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); }
.is-mobile .composer-input { min-height: 60px; font-size: 16px; }
.is-mobile .msg-main { max-width: 82%; }
.is-mobile .bubble-img img { max-width: 180px; }
.is-mobile .note-card { width: 96%; }
.is-mobile .new-tip { bottom: 170px; }
.is-mobile .leave-detail { padding: 12px; }

/* ---------- 自动翻译 / 微信 / 卡片 ---------- */
.translate-menu { left: auto; right: 0; max-height: 360px; overflow-y: auto; }
.translate-menu button.on { color: var(--primary); font-weight: 500; }
.online-tag.wechat { background: var(--success-soft); color: var(--success); }
.msg.mine .translated, .msg .translated { border-top-color: rgba(127, 127, 127, .35); }
.card-image-row { display: flex; align-items: center; gap: 8px; }
.card-image-row img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.card-image-row .input { flex: 1; min-width: 0; }
.is-mobile .translate-menu { position: fixed; top: 108px; right: 12px; left: auto; }

/* ---------- 快捷回复分类 ---------- */
.quick-search { margin-bottom: 8px; }
.quick-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.quick-chips button { height: 24px; padding: 0 9px; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: var(--text-2); font-size: 12px; cursor: pointer; }
.quick-chips button:hover { border-color: var(--primary); color: var(--primary); }
.quick-chips button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.quick-group { display: flex; align-items: center; gap: 6px; margin: 12px 0 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.quick-group:first-of-type { margin-top: 2px; }
.quick-group span { font-weight: 400; color: var(--text-3); }
.slash-item .slash-cat { flex-shrink: 0; padding: 0 6px; border-radius: 4px; background: var(--bg); color: var(--text-3); font-size: 11px; font-style: normal; line-height: 20px; }
