/* ============================================
   客服工作台 - 时尚大气UI样式
   ============================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f5f7fb;
}
:root {
  --primary: #667eea;
  --primary-dark: #764ba2;
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --text-1: #1f2937;
  --text-2: #4b5563;
  --text-3: #6b7280;
  --text-4: #9ca3af;
  --border: #e5e7eb;
  --bg-1: #ffffff;
  --bg-2: #f9fafb;
  --bg-3: #f3f4f6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

/* ============ 全局按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1;
}
.btn svg { width: 14px; height: 14px; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-primary { background: var(--primary-gradient); color: #fff; box-shadow: 0 4px 14px rgba(102,126,234,0.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(102,126,234,0.4); }
.btn-success { background: linear-gradient(135deg,#10b981,#059669); color: #fff; box-shadow: 0 4px 14px rgba(16,185,129,0.3); }
.btn-success:hover { transform: translateY(-1px); }
.btn-danger { background: linear-gradient(135deg,#ef4444,#dc2626); color: #fff; box-shadow: 0 4px 14px rgba(239,68,68,0.3); }
.btn-danger:hover { transform: translateY(-1px); }
.btn-default { background: #fff; color: var(--text-2); border: 1px solid var(--border); }
.btn-default:hover { background: var(--bg-2); }
.btn-outline { background: transparent; color: var(--text-2); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(102,126,234,0.04); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 14px;
  color: #fff;
  z-index: 99999;
  transition: all 0.35s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
  max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { background: linear-gradient(135deg,#10b981,#059669); }
.toast.error { background: linear-gradient(135deg,#ef4444,#dc2626); }
.toast.warning { background: linear-gradient(135deg,#f59e0b,#d97706); }
.toast.info { background: var(--primary-gradient); }

/* ============ 确认弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: maskFade 0.2s ease;
}
@keyframes maskFade { from{opacity:0;} to{opacity:1;} }
.modal {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.2);
  min-width: 360px;
  max-width: 640px;
  animation: modalIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
  overflow: hidden;
}
@keyframes modalIn {
  from{opacity:0; transform: scale(0.9) translateY(20px);}
  to{opacity:1; transform: scale(1) translateY(0);}
}
.confirm-modal { padding: 32px; text-align: center; }
.modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-icon svg { width: 32px; height: 32px; }
.modal-icon.warning { background: rgba(245,158,11,0.12); color: #d97706; }
.modal-content h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; color: var(--text-1); }
.modal-content p { font-size: 14px; color: var(--text-3); line-height: 1.5; }
.modal-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 20px;
}

.qr-modal { width: 560px; max-height: 75vh; display: flex; flex-direction: column; }
.tag-modal { width: 400px; }
.force-modal { width: 460px; }
.force-qr { max-height: 120px; overflow-y: auto; margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.force-qr:empty { display: none; }
.force-qr .force-chip { font-size: 12px; padding: 5px 10px; border: 1px solid var(--border, #e5e7eb); border-radius: 14px; background: #f9fafb; color: var(--text-2, #4b5563); cursor: pointer; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.force-qr .force-chip:hover { background: #eef2ff; border-color: #667eea; color: #667eea; }
.modal-header {
  padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none; background: transparent;
  cursor: pointer; font-size: 16px; color: var(--text-3);
  transition: all 0.15s;
}
.modal-close:hover { background: var(--bg-3); color: var(--text-1); }
.modal-body { padding: 25px; overflow-y: auto; }
.qr-header-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.form-input {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  background: #fff;
  color: var(--text-1);
  transition: all 0.2s;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(102,126,234,0.1); }
.form-input.small { padding: 6px 10px; font-size: 12px; }
.qr-list { display: flex; flex-direction: column; gap: 8px; }
.qr-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: all 0.2s;
}
.qr-item:hover { border-color: rgba(102,126,234,0.4); background: rgba(102,126,234,0.02); }
.qr-item .qr-text { flex: 1; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.qr-item .qr-actions { display: flex; gap: 4px; }
.qr-item .icon-btn-xs {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: none; background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  transition: all 0.15s;
}
.qr-item .icon-btn-xs:hover { background: var(--bg-3); color: var(--text-1); }
.qr-item .icon-btn-xs:hover.danger { background: rgba(239,68,68,0.1); color: var(--danger); }
.qr-item .icon-btn-xs svg { width: 13px; height: 13px; }

/* 话术多语言编辑表单 */
.qr-edit-form {
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}
.qr-edit-title { font-size: 13px; font-weight: 600; color: var(--text-1); margin-bottom: 10px; }
.qr-lang-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.qr-lang-tab {
  padding: 4px 12px; border-radius: 999px; font-size: 12px; cursor: pointer;
  background: var(--bg-3); color: var(--text-3); border: 1px solid var(--border);
  transition: all .2s;
}
.qr-lang-tab.active { background: var(--primary-gradient); color: #fff; border-color: transparent; }
.qr-edit-form textarea { width: 100%; box-sizing: border-box; }
.qr-edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ============ 主布局 ============ */
.app-container {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  gap: 0;
  background: #eef1f8;
}

/* ============ 左侧栏 ============ */
.left-panel {
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* 客服信息区 */
.admin-profile {
  padding: 20px 18px 16px;
  background: linear-gradient(135deg, rgba(102,126,234,0.08) 0%, rgba(118,75,162,0.08) 100%);
  border-bottom: 1px solid var(--border);
}
.profile-main {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  border-radius: 50%;
  background: var(--primary-gradient);
  user-select: none;
}
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-md { width: 40px; height: 40px; font-size: 15px; border-radius: 12px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; border-radius: 14px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.online-dot {
  position: absolute;
  bottom: 0; right: 0;
  width: 14px; height: 14px;
  background: var(--success);
  border: 3px solid #fff;
  border-radius: 50%;
}
.online-dot.busy { background: var(--warning); }
.online-dot.offline { background: var(--text-4); }
.profile-info { flex: 1; min-width: 0; }
.admin-name { font-size: 15px; font-weight: 600; color: var(--text-1); margin-bottom: 2px; }
.admin-role { font-size: 12px; color: var(--text-3); }
.profile-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-select-wrap { flex: 1; }
.status-select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  background: #fff;
  outline: none;
  font-family: inherit;
  cursor: pointer;
}
.status-select:focus { border-color: var(--primary); }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: none;
  background: rgba(255,255,255,0.7);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: all 0.2s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: #fff; color: var(--danger); box-shadow: var(--shadow-sm); }
.icon-btn.settings-btn:hover { background: #fff; color: var(--primary); }

/* 筛选区 */
.filters-wrap {
  padding: 14px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.site-filter {
  position: relative;
  display: flex;
  align-items: center;
}
.filter-icon {
  position: absolute;
  left: 12px;
  width: 14px; height: 14px;
  color: var(--text-4);
  pointer-events: none;
}
.site-select {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-2);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  color: var(--text-1);
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%239ca3af'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.site-select:focus { border-color: var(--primary); background-color: #fff; }
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 12px;
  width: 15px; height: 15px;
  color: var(--text-4);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-2);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  color: var(--text-1);
  transition: all 0.2s;
}
.search-box input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(102,126,234,0.08); }
.search-box input::placeholder { color: var(--text-4); }

/* 分类标签 */
.tabs-nav {
  padding: 12px 10px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}
.tab-item {
  flex: 1 1 calc(50% - 4px);
  min-width: calc(50% - 4px);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}
.tab-item:hover { background: var(--bg-2); }
.tab-item.active { background: var(--primary-gradient); color: #fff; box-shadow: 0 4px 12px rgba(102,126,234,0.3); }
.tab-icon { display: flex; }
.tab-icon svg { width: 15px; height: 15px; fill: currentColor; }
.tab-item .tab-text { font-size: 12px; font-weight: 500; flex: 1; }
.tab-count {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(0,0,0,0.06);
  color: var(--text-3);
  font-weight: 600;
}
.tab-item.active .tab-count { background: rgba(255,255,255,0.25); color: #fff; }
.tab-count.highlight { background: rgba(239,68,68,0.12); color: var(--danger); }
.tab-item.active .tab-count.highlight { background: rgba(255,255,255,0.25); color: #fff; }

/* 会话列表 */
.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.session-list::-webkit-scrollbar,
.message-list::-webkit-scrollbar,
.qr-content::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.right-content::-webkit-scrollbar,
.history-list::-webkit-scrollbar { width: 5px; }
.session-list::-webkit-scrollbar-track,
.message-list::-webkit-scrollbar-track,
.qr-content::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.right-content::-webkit-scrollbar-track,
.history-list::-webkit-scrollbar-track { background: transparent; }
.session-list::-webkit-scrollbar-thumb,
.message-list::-webkit-scrollbar-thumb,
.qr-content::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.right-content::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb { background: rgba(102,126,234,0.2); border-radius: 3px; }
.session-list::-webkit-scrollbar-thumb:hover,
.message-list::-webkit-scrollbar-thumb:hover,
.right-content::-webkit-scrollbar-thumb:hover { background: rgba(102,126,234,0.4); }

.session-card {
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
  margin-bottom: 4px;
  border: 1.5px solid transparent;
}
.session-card:hover { background: var(--bg-2); }
.session-card.active {
  background: linear-gradient(135deg, rgba(102,126,234,0.08) 0%, rgba(118,75,162,0.08) 100%);
  border-color: rgba(102,126,234,0.2);
}
/* 访客上线提醒：列表卡片闪烁 3 次（绿色高亮脉冲） */
.session-card.flash {
  animation: cardFlash 0.9s ease-in-out 3;
  border-color: rgba(16,185,129,0.5);
}
@keyframes cardFlash {
  0%, 100% { box-shadow: none; background: var(--bg-1); }
  50% { box-shadow: 0 0 0 3px rgba(16,185,129,0.35), 0 4px 14px rgba(16,185,129,0.18); background: rgba(16,185,129,0.08); }
}
.session-card.waiting::before {
  content: '';
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 3px;
  background: linear-gradient(180deg, #f59e0b, #ef4444);
  border-radius: 3px;
  animation: pulseBar 1.5s ease-in-out infinite;
}
@keyframes pulseBar {
  0%,100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.sc-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.sc-top .avatar { flex-shrink: 0; }
.sc-top .avatar.visitor { background: linear-gradient(135deg,#f093fb,#f5576c); }
.sc-top .avatar.leave { background: linear-gradient(135deg,#f093fb,#f5576c); }
.sc-info { flex: 1; min-width: 0; }
.sc-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.sc-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.sc-time {
  font-size: 11px;
  color: var(--text-4);
  flex-shrink: 0;
}
.sc-site {
  font-size: 11px;
  color: var(--primary);
  background: rgba(102,126,234,0.08);
  padding: 1px 7px;
  border-radius: 8px;
  display: inline-block;
  max-width: 110px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sc-preview {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.4;
  padding-left: 42px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sc-preview .leave-preview { color: var(--warning); }
.sc-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 6px;
  padding-left: 42px;
}
.sc-page {
  font-size: 10px;
  color: var(--text-4);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sc-badge-group { display: flex; gap: 4px; flex-shrink: 0; }
.sc-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 500;
}
.sc-badge.waiting { background: rgba(245,158,11,0.15); color: #d97706; }
.sc-badge.active { background: rgba(16,185,129,0.15); color: #059669; }
.sc-badge.closed { background: rgba(156,163,175,0.15); color: #6b7280; }
.unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: linear-gradient(135deg,#ef4444,#dc2626);
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(239,68,68,0.4);
}

/* 访客在线/离线状态点（会话列表） */
.sc-name-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.visitor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.visitor-dot.online { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,0.18); }
.visitor-dot.offline { background: #9ca3af; box-shadow: 0 0 0 3px rgba(156,163,175,0.15); }
.visitor-dot.online::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid rgba(16,185,129,0.35);
  animation: dotPulse 2s ease-in-out infinite;
}
@keyframes dotPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* 正在接待分组标题 */
.group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.3px;
}
.group-label .gl-count {
  background: var(--bg-2);
  color: var(--text-4);
  padding: 0 7px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 500;
}

/* 会话操作按钮 */
.sc-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.sc-action-btn {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.sc-action-btn:hover {
  background: var(--bg-3);
  border-color: var(--text-4);
}
.sc-action-btn.invite-btn:hover {
  background: rgba(102,126,234,0.1);
  border-color: #667eea;
  color: #667eea;
}
.sc-action-btn.force-btn:hover {
  background: rgba(245,158,11,0.1);
  border-color: #f59e0b;
  color: #d97706;
}

.empty-session {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-4);
}
.empty-session svg { width: 64px; height: 64px; opacity: 0.4; margin-bottom: 10px; }
.empty-session p { font-size: 13px; }

/* ============ 中间聊天区 ============ */
.chat-panel {
  background: #fff;
  position: relative;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
}
.empty-illustration {
  margin-bottom: 24px;
  opacity: 0.9;
}
.empty-svg { width: 200px; height: 200px; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text-1); margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--text-3); }

/* 聊天内容 */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 聊天顶部栏 */
.chat-header-bar {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #fafbff 0%, #fff 100%);
}
.visitor-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.visitor-info .avatar { flex-shrink: 0; background: linear-gradient(135deg,#f093fb,#f5576c); }
.visitor-meta { flex: 1; min-width: 0; }
.visitor-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.visitor-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
}
.site-badge {
  padding: 2px 9px;
  background: rgba(102,126,234,0.1);
  color: var(--primary);
  font-size: 11px;
  border-radius: 8px;
  font-weight: 500;
  flex-shrink: 0;
}
.visitor-status {
  padding: 2px 9px;
  font-size: 11px;
  border-radius: 8px;
  font-weight: 500;
  flex-shrink: 0;
}
.visitor-status.online {
  background: rgba(16,185,129,0.12);
  color: #059669;
}
.visitor-status.offline {
  background: rgba(156,163,175,0.14);
  color: #6b7280;
}
.leave-badge {
  padding: 2px 9px;
  background: rgba(245,158,11,0.12);
  color: #d97706;
  font-size: 11px;
  border-radius: 8px;
  font-weight: 500;
}
.visitor-sub {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-3);
}
.sub-item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.chat-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* 消息列表 */
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: linear-gradient(180deg, #f9fafb 0%, #f3f5fb 100%);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* 访客离线提示条 */
.offline-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  font-size: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(146,64,14,0.12);
}
.offline-tip svg { width: 15px; height: 15px; fill: #b45309; flex-shrink: 0; }
.msg-row {
  display: flex;
  gap: 10px;
  max-width: 75%;
  animation: msgIn 0.3s ease;
}
@keyframes msgIn { from{opacity:0; transform:translateY(8px);} to{opacity:1; transform:translateY(0);} }
.msg-row.agent { align-self: flex-start; }
.msg-row.visitor { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { flex-shrink: 0; }
.msg-avatar svg { width: 36px; height: 36px; fill: currentColor; }
.msg-wrap { min-width: 0; }
.msg-row.visitor .msg-wrap { display: flex; flex-direction: column; align-items: flex-end; }
.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 11px;
  color: var(--text-4);
}
.msg-row.visitor .msg-meta { flex-direction: row-reverse; }
.msg-name { color: var(--text-2); font-weight: 500; }
.bubble {
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  word-break: break-word;
  position: relative;
}
.msg-row.agent .bubble {
  background: #fff;
  color: var(--text-1);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.03);
}
.msg-row.visitor .bubble {
  background: var(--primary-gradient);
  color: #fff!important;
  border-top-right-radius: 4px;
  box-shadow: 0 6px 20px rgba(102,126,234,0.25);
}
.bubble a { color: inherit; text-decoration: underline; opacity: 0.9; }
/* 访客非中文消息：翻译结果（主行）+ 原始信息（副行，次级色小字） */
.bubble .msg-translated { line-height: 1.5; }
.bubble .msg-original {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(127,127,127,0.35);
  font-size: 12px;
  line-height: 1.45;
  /*color: var(--text-3);*/
  word-break: break-word;
  color: rgba(255,255,255,0.5);
}
.bubble .msg-original::before {
  content: '原文';
  display: inline-block;
  font-size: 10px;
  color: var(--text-4);
  background: var(--bg-3);
  border-radius: 4px;
  padding: 0 5px;
  margin-right: 6px;
  vertical-align: 1px;
}
.typing-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing-dots span { width: 7px; height: 7px; background: var(--text-3); border-radius: 50%; animation: typingBounce 1.4s infinite ease-in-out both; }
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce { 0%, 80%, 100% { transform: scale(0); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }
.bubble img {
  max-width: 260px;
  max-height: 260px;
  border-radius: 8px;
  cursor: zoom-in;
  display: block;
}
.msg-system {
  align-self: center;
  max-width: 80%;
  display: flex;
  justify-content: center;
}
.msg-system .text {
  display: inline-block;
  padding: 6px 16px;
  background: rgba(156,163,175,0.15);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-3);
  backdrop-filter: blur(10px);
}

/* 快捷话术栏 */
.quick-replies-bar {
  border-top: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
.qr-header {
  padding: 10px 20px 6px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.qr-title {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 600;
  padding-right: 10px;
  border-right: 1px solid var(--border);
}
.qr-tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.qr-tab {
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}
.qr-tab:hover { background: var(--bg-2); color: var(--text-2); }
.qr-tab.active { background: rgba(102,126,234,0.1); color: var(--primary); }
.qr-manage-btn {
  padding: 4px 10px;
  font-size: 12px;
  color: var(--primary);
  background: transparent;
  border: 1px solid rgba(102,126,234,0.3);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
}
.qr-manage-btn:hover { background: rgba(102,126,234,0.08); }
.qr-lang-select {
  flex: none;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  background: var(--bg-1);
  color: var(--text-2);
  cursor: pointer;
  outline: none;
}
.qr-lang-select:hover { border-color: rgba(102,126,234,0.4); }
.qr-content {
  padding: 4px 16px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 120px;
  overflow-y: auto;
}
.qr-chip {
  padding: 6px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.qr-chip:hover {
  background: rgba(102,126,234,0.08);
  border-color: rgba(102,126,234,0.3);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(102,126,234,0.1);
}

/* 输入区 */
.input-area {
  border-top: 1px solid var(--border);
  padding: 12px 18px 16px;
  background: #fff;
  flex-shrink: 0;
}
.input-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
  position: relative;
}
.tool-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.tool-btn svg { width: 18px; height: 18px; fill: currentColor; }
.tool-btn:hover { background: var(--bg-3); color: var(--primary); }
.tool-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 8px;
}
.tip-text {
  font-size: 11px;
  color: var(--text-4);
  margin-left: auto;
}
.emoji-panel {
  position: absolute;
  bottom: 40px;
  left: 0;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  width: 320px;
  z-index: 100;
  display: none;
  border: 1px solid var(--border);
}
.emoji-panel.show { display: grid; animation: panelIn 0.2s ease; }
@keyframes panelIn { from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:translateY(0);} }
.emoji-panel .emoji-item {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.emoji-panel .emoji-item:hover {
  background: var(--bg-3);
  transform: scale(1.25);
}

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--bg-2);
  border-radius: 14px;
  padding: 10px 10px 10px 16px;
  border: 1.5px solid transparent;
  transition: all 0.2s;
  position: relative;
}
.input-box:focus-within {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(102,126,234,0.08);
}
.input-box textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  resize: none;
  max-height: 180px;
  min-height: 24px;
  line-height: 1.5;
  color: var(--text-1);
  font-family: inherit;
  padding: 3px 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.input-box textarea::-webkit-scrollbar { width: 0; height: 0; display: none; }
.input-box textarea::placeholder { color: var(--text-4); }
.input-box textarea:disabled { opacity: 0.5; cursor: not-allowed; }
.session-closed-tip {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--text-4);
  background: var(--bg-3);
  padding: 2px 12px;
  border-radius: 10px;
  white-space: nowrap;
}
.send-btn {
  height: 40px;
  padding: 0 22px;
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  flex-shrink: 0;
  font-family: inherit;
}
.send-btn svg { width: 15px; height: 15px; }
.send-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(102,126,234,0.4); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* 留言详情 */
.leave-msg-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: linear-gradient(180deg, #f9fafb 0%, #f3f5fb 100%);
}
.leave-detail-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.leave-detail-card h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.leave-detail-card h4 svg { width: 18px; height: 18px; color: var(--primary); }
.leave-text {
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(102,126,234,0.04) 0%, rgba(118,75,162,0.04) 100%);
  border-radius: 12px;
  border-left: 3px solid var(--primary);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-2);
  margin-bottom: 20px;
}
.leave-site-info {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 13px;
  color: var(--text-3);
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.leave-site-info strong { color: var(--text-1); font-weight: 500; margin-left: 4px; }

/* ============ 右侧栏 ============ */
.right-panel {
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.right-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.re-svg svg { width: 140px; height: 140px; opacity: 0.6; }
.right-empty p { color: var(--text-4); font-size: 13px; margin-top: 16px; }

.right-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
}
.info-section { margin-bottom: 22px; }
.section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.section-header svg { width: 15px; height: 15px; color: var(--primary); }
.section-count {
  margin-left: auto;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--bg-3);
  color: var(--text-3);
  font-weight: 500;
}
.section-add-btn {
  margin-left: auto;
  font-size: 11px;
  padding: 3px 10px;
  border: 1px dashed var(--primary);
  background: transparent;
  color: var(--primary);
  border-radius: 7px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}
.section-add-btn:hover { background: rgba(102,126,234,0.08); }

.visitor-card {
  background: linear-gradient(135deg, rgba(102,126,234,0.08) 0%, rgba(240,147,251,0.08) 100%);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}
.vc-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.vc-top .avatar { background: linear-gradient(135deg,#f093fb,#f5576c); }
.vc-info { flex: 1; min-width: 0; }
.vc-name { font-size: 15px; font-weight: 600; color: var(--text-1); margin-bottom: 2px; }
.vc-id { font-size: 11px; color: var(--text-3); margin-bottom: 4px; }
.vc-type {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(245,158,11,0.12);
  color: #d97706;
  font-size: 11px;
  border-radius: 8px;
  font-weight: 500;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.info-cell {
  background: #fff;
  padding: 10px 12px;
}
.info-cell.full { grid-column: 1 / -1; }
.info-cell label {
  display: block;
  font-size: 10px;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.info-cell div {
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
  line-height: 1.4;
}
.info-link {
  color: var(--primary) !important;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(102,126,234,0.3);
  word-break: break-all;
}
.info-link:hover { text-decoration-color: var(--primary); }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.tag-chip.default { background: rgba(102,126,234,0.1); color: var(--primary); border-color: rgba(102,126,234,0.2); }
.tag-chip.potential { background: rgba(245,158,11,0.12); color: #d97706; border-color: rgba(245,158,11,0.2); }
.tag-chip.service { background: rgba(16,185,129,0.12); color: #059669; border-color: rgba(16,185,129,0.2); }
.tag-chip.consult { background: rgba(59,130,246,0.12); color: #2563eb; border-color: rgba(59,130,246,0.2); }
.tag-chip .tag-close {
  cursor: pointer;
  opacity: 0.5;
  font-size: 14px;
  line-height: 1;
  transition: opacity 0.15s;
}
.tag-chip .tag-close:hover { opacity: 1; }

.history-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.history-item {
  padding: 10px 12px;
  background: var(--bg-2);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.history-item:hover {
  background: rgba(102,126,234,0.05);
  border-color: rgba(102,126,234,0.2);
}
.hi-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.hi-title { font-size: 12.5px; font-weight: 600; color: var(--text-1); }
.hi-status {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 8px;
}
.hi-status.closed { background: rgba(156,163,175,0.15); color: #6b7280; }
.hi-status.active { background: rgba(16,185,129,0.15); color: #059669; }
.hi-row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-4);
}
.hi-site { color: var(--primary); }
.hi-summary {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--text-3);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============ 响应式 ============ */
@media (max-width: 1400px) {
  .app-container { grid-template-columns: 280px 1fr 300px; }
  .visitor-sub .sub-item { max-width: 160px; }
}
@media (max-width: 1200px) {
  .app-container { grid-template-columns: 260px 1fr; }
  .right-panel { display: none; }
}
@media (max-width: 900px) {
  .app-container { grid-template-columns: 1fr; }
  .left-panel { display: none; }
}

/* ============ 历史会话消息弹窗 ============ */
.history-msg-modal { width: 620px; max-width: calc(100vw - 40px); }
.history-msg-modal .modal-body { padding: 0; }
.history-msg-list {
  max-height: 62vh;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-msg-list .msg-row { max-width: 88%; }
.history-msg-list .history-loading {
  text-align: center;
  color: var(--text-4);
  font-size: 13px;
  padding: 30px 0;
}
.history-item.clickable .hi-title { color: var(--primary); }
.history-item.clickable:hover .hi-title { text-decoration: underline; }
