/* 千应客服 - 客服端（电脑版）布局 */
.agent-pc {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 登录遮罩 */
.agent-pc .login-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.agent-pc .login-card {
  background: #fff; border-radius: 16px;
  width: 90%; max-width: 360px; padding: 32px 24px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.agent-pc .login-card h2 { font-size: 20px; color: #111827; margin-bottom: 6px; }
.agent-pc .login-card p { font-size: 13px; color: #6b7280; margin-bottom: 18px; }
.agent-pc .login-card input {
  width: 100%; height: 42px; border: 1px solid #d1d5db;
  border-radius: 10px; padding: 0 14px; font-size: 15px;
  margin-bottom: 14px;
}
.agent-pc .login-card .code-btn { width: 100%; height: 42px; font-size: 15px; }
.agent-pc .login-err { color: #dc2626; font-size: 13px; margin-top: 10px; min-height: 18px; }

/* 顶部 */
.agent-pc .topbar {
  height: 52px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 17px;
  font-weight: 600;
  color: #111827;
  flex-shrink: 0;
}
.agent-pc .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.agent-pc .topbar .status {
  font-size: 13px;
  font-weight: 400;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 危险按钮（清除） */
.agent-pc .icon-btn.danger {
  background: #fecaca;
  color: #991b1b;
}
.agent-pc .icon-btn.danger:hover {
  background: #fca5a5;
}
.agent-pc .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* 主体：左右分栏 */
.agent-pc .main {
  display: flex;
  flex: 1;
  min-height: 0; /* 关键：允许子项压缩，防止撑开 */
}

/* ===== 左侧 ===== */
.agent-pc .sidebar {
  width: 330px;
  border-right: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* 访客码折叠入口 */
.agent-pc .code-toggle {
  margin: 12px 12px 0;
  width: calc(100% - 24px);
  height: 40px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.agent-pc .code-toggle:hover { background: #f9fafb; }
.agent-pc .code-toggle-icon { font-size: 14px; color: #9ca3af; transition: transform .2s; }
.agent-pc .code-toggle.open .code-toggle-icon { transform: rotate(90deg); }

/* ===== 访客码卡片（支付宝/微信收款码风格） ===== */
.agent-pc .agent-code-card {
  margin: 12px;
  background: #fff;
  border: 1px solid #e8ecf1;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, .07);
  overflow: hidden;
  flex-shrink: 0;
}

/* 顶部品牌条 */
.agent-pc .code-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #1677ff, #3b82f6);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.agent-pc .code-brand-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  color: #1677ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.agent-pc .code-brand-name { letter-spacing: .5px; }
.agent-pc .code-brand-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .22);
}

/* 二维码区域 */
.agent-pc .qr-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 16px auto 6px;
  padding: 8px;
  background: #fff;
  border: 1px solid #eef1f5;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.agent-pc .qr-wrap::before,
.agent-pc .qr-wrap::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid #1677ff;
  opacity: .45;
}
.agent-pc .qr-wrap::before {
  top: -1px; left: -1px;
  border-right: 0; border-bottom: 0;
  border-top-left-radius: 10px;
}
.agent-pc .qr-wrap::after {
  bottom: -1px; right: -1px;
  border-left: 0; border-top: 0;
  border-bottom-right-radius: 10px;
}
.agent-pc #agentQrImg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.agent-pc .qr-loading {
  position: absolute;
  inset: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #9ca3af;
  font-size: 12px;
}
.agent-pc .qr-loading.hide { display: none; }

/* 说明 + 访客码 */
.agent-pc .code-label {
  text-align: center;
  font-size: 12px;
  color: #6b7280;
  margin-top: 8px;
}
.agent-pc .code-value {
  text-align: center;
  font-family: 'Courier New', monospace;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #111827;
  margin: 4px 0 8px;
  user-select: all;
  word-break: keep-all;
}
.agent-pc .code-link {
  text-align: center;
  font-size: 11px;
  color: #6b7280;
  word-break: break-all;
  padding: 0 14px 10px;
  user-select: all;
}

/* 操作按钮 */
.agent-pc .code-actions {
  display: flex;
  gap: 8px;
  padding: 0 14px;
}
.agent-pc .code-btn {
  flex: 1;
  height: 34px;
  border-radius: 9px;
  border: none;
  background: #f2f4f7;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.agent-pc .code-btn:hover { background: #e7ebf0; }
.agent-pc .code-btn.primary { background: #1677ff; color: #fff; }
.agent-pc .code-btn.primary:hover { background: #0e63e0; }
.agent-pc .code-btn.danger { background: #fee2e2; color: #991b1b; }
.agent-pc .code-btn.danger:hover { background: #fecaca; }

/* 模板切换 */
.agent-pc .tpl-switch {
  display: flex;
  gap: 6px;
  padding: 8px 14px 0;
}
.agent-pc .tpl-btn {
  flex: 1;
  height: 28px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.agent-pc .tpl-btn.active { color: #fff; border-color: transparent; }
.agent-pc .tpl-btn[data-tpl="alipay"].active { background: #1677ff; }
.agent-pc .tpl-btn[data-tpl="wechat"].active { background: #07c160; }
.agent-pc .tpl-btn[data-tpl="taobao"].active { background: #ff5000; }

.agent-pc .code-actions-2 { margin-top: 6px; }

.agent-pc .domain-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 0;
  font-size: 12px;
  color: #374151;
}
.agent-pc .domain-label { color: #6b7280; }
.agent-pc .domain-current {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #111827;
  font-weight: 500;
}

/* ===== 模板配色 ===== */
/* 支付宝（默认蓝） */
.agent-pc .agent-code-card.tpl-alipay .code-brand { background: linear-gradient(135deg, #1677ff, #3b82f6); }
.agent-pc .agent-code-card.tpl-alipay .qr-wrap::before,
.agent-pc .agent-code-card.tpl-alipay .qr-wrap::after { border-color: #1677ff; }
.agent-pc .agent-code-card.tpl-alipay .code-btn.primary { background: #1677ff; }
.agent-pc .agent-code-card.tpl-alipay .code-btn.primary:hover { background: #0e63e0; }

/* 微信（绿） */
.agent-pc .agent-code-card.tpl-wechat .code-brand { background: linear-gradient(135deg, #07c160, #09b85a); }
.agent-pc .agent-code-card.tpl-wechat .qr-wrap::before,
.agent-pc .agent-code-card.tpl-wechat .qr-wrap::after { border-color: #07c160; }
.agent-pc .agent-code-card.tpl-wechat .code-btn.primary { background: #07c160; }
.agent-pc .agent-code-card.tpl-wechat .code-btn.primary:hover { background: #06ad56; }

/* 淘宝（橙） */
.agent-pc .agent-code-card.tpl-taobao .code-brand { background: linear-gradient(135deg, #ff5000, #ff6a00); }
.agent-pc .agent-code-card.tpl-taobao .qr-wrap::before,
.agent-pc .agent-code-card.tpl-taobao .qr-wrap::after { border-color: #ff5000; }
.agent-pc .agent-code-card.tpl-taobao .code-btn.primary { background: #ff5000; }
.agent-pc .agent-code-card.tpl-taobao .code-btn.primary:hover { background: #e64800; }
.agent-pc .code-hint {
  text-align: center;
  font-size: 11px;
  color: #9ca3af;
  padding: 10px 14px 14px;
}

/* 访客列表区域（剩余空间，可滚动） */
.agent-pc .list-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.agent-pc .list-header {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.agent-pc .visitor-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.agent-pc .visitor-item {
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.agent-pc .visitor-item:hover { background: #f3f4f6; }
.agent-pc .visitor-item.active {
  background: #eff6ff;
  border-color: #3b82f6;
}
.agent-pc .visitor-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.agent-pc .visitor-name {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-pc .visitor-note {
  font-size: 11px;
  color: #2563eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.agent-pc .visitor-meta {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}
.agent-pc .visitor-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cbd5e1;
  flex-shrink: 0;
}
.agent-pc .visitor-dot.online { background: #22c55e; }
.agent-pc .visitor-arrow {
  font-size: 20px;
  line-height: 1;
  color: #c7cdd6;
  flex-shrink: 0;
}
.agent-pc .visitor-unread {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  white-space: nowrap;
  animation: blink .8s infinite;
  flex-shrink: 0;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.6} }

/* ===== 右侧聊天 ===== */
.agent-pc .chat-area {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #f5f7fa;
}

/* 聊天顶部标题栏 */
.agent-pc .chat-header {
  height: 46px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

/* 空状态 */
.agent-pc .chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
}
.agent-pc .chat-empty svg {
  width: 64px; height: 64px; margin-bottom: 12px; opacity: .5;
}
.agent-pc .chat-empty p { font-size: 15px; }

/* 消息区：可滚动，占据剩余空间 */
.agent-pc .messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: transparent;
  -webkit-overflow-scrolling: touch;
}

/* 消息气泡 —— 我发的在右侧（蓝），对方的在左侧（白） */
.agent-pc .msg {
  max-width: 72%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  position: relative;
  animation: fadeIn .2s ease;
  clear: both;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-line;
}
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }

/* 自己的消息：右侧，蓝色 —— flex 布局中用 margin-left: auto 推到最右 */
.agent-pc .msg.me {
  align-self: flex-end;
  margin-left: auto;
  background: #3b82f6;
  color: #fff;
  border-bottom-right-radius: 4px;
  border-top-left-radius: 14px;
}
.agent-pc .msg.me::after {
  content: '';
  position: absolute;
  right: -10px;
  top: 10px;
  width: 0; height: 0;
  border: 8px solid transparent;
  border-left-color: #3b82f6;
  border-right: 0;
}

/* 对方的消息：左侧，白色 —— 用 margin-right: auto 推到最左 */
.agent-pc .msg.other {
  align-self: flex-start;
  margin-right: auto;
  background: #fff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
  border-top-right-radius: 14px;
}
.agent-pc .msg.other::after {
  content: '';
  position: absolute;
  left: -10px;
  top: 10px;
  width: 0; height: 0;
  border: 8px solid transparent;
  border-right-color: #fff;
  border-left: 0;
  border-top-color: #e5e7eb;
}

/* 系统消息居中 */
.agent-pc .msg.system {
  align-self: center;
  max-width: 100%;
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  padding: 6px 12px;
  background: transparent;
  margin-left: 0;
  margin-right: 0;
}

/* 清除浮动（兼容旧样式，flex 下不需要但保留无害） */
.agent-pc .messages::after {
  content: '';
  display: block;
  clear: both;
}
.agent-pc .msg.system {
  align-self: center;
  max-width: 100%;
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  padding: 6px 12px;
  background: transparent;
}
.agent-pc .msg.deleted {
  opacity: .5;
  text-decoration: line-through;
  font-style: italic;
  pointer-events: none;
}
.agent-pc .msg img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
  margin-top: 6px;
}
.agent-pc .msg-content {
  display: inline;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-line;
}
.agent-pc .msg-content a {
  word-break: break-all;
}
.agent-pc .msg-time {
  font-size: 10px;
  opacity: .7;
  margin-left: 6px;
  display: inline;
  white-space: nowrap;
  vertical-align: baseline;
}
.agent-pc .msg.other .msg-time { opacity: .5; }

.agent-pc .msg-actions {
  position: absolute;
  top: 4px; right: 6px;
  opacity: 0;
  transition: opacity .2s;
}
.agent-pc .msg.me:hover .msg-actions { opacity: 1; }

/* 每条消息右上角的撤回按钮（常显） */
.agent-pc .msg-btn {
  position: absolute;
  top: 4px; right: 6px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,.12);
  color: inherit;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .55;
  transition: opacity .15s, background .15s;
  border: none;
  cursor: pointer;
  z-index: 2;
}
.agent-pc .msg.me .msg-btn { background: rgba(255,255,255,.25); }
.agent-pc .msg-btn:hover { opacity: 1; background: rgba(0,0,0,.25); }
.agent-pc .msg.me .msg-btn:hover { background: rgba(255,255,255,.4); }

/* 打字提示 */
.agent-pc .typing-indicator {
  font-size: 12px;
  color: #6b7280;
  font-style: italic;
  margin: 0 16px 8px;
  align-self: flex-start;
  flex-shrink: 0;
}

/* 评价提示 */
.agent-pc .eval-tip {
  padding: 8px 16px;
  font-size: 12px;
  color: #b45309;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  flex-shrink: 0;
}

/* 输入区：固定底部 */
.agent-pc .input-wrap {
  border-top: 1px solid #e5e7eb;
  background: #fff;
  padding: 10px 16px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.agent-pc .toolbar {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.agent-pc .icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: #f3f4f6;
  color: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background .15s, color .15s;
  border: none;
  cursor: pointer;
}
.agent-pc .icon-btn:hover { background: #e5e7eb; color: #111827; }
.agent-pc .icon-btn.primary {
  background: #3b82f6;
  color: #fff;
}
.agent-pc .icon-btn.primary:hover { background: #2563eb; }
.agent-pc #fileInput { display: none; }
.agent-pc textarea#messageInput {
  flex: 1;
  min-height: 38px;
  max-height: 120px;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  resize: none;
  font-size: 14px;
  color: #111827;
}
.agent-pc textarea#messageInput::placeholder { color: #9ca3af; }

/* 右键菜单 */
.agent-pc .ctx-menu {
  position: fixed;
  z-index: 100;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  min-width: 120px;
  padding: 6px 0;
  display: none;
}
.agent-pc .ctx-item {
  padding: 8px 16px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
}
.agent-pc .ctx-item:hover { background: #f3f4f6; }
.agent-pc .ctx-item.danger { color: #dc2626; }

/* 快捷回复面板 */
.agent-pc .quick-reply-panel {
  position: absolute;
  bottom: 70px; left: 16px; right: 16px;
  max-height: 260px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.agent-pc .qr-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}
.agent-pc .qr-add-btn {
  font-size: 12px;
  color: #3b82f6;
  background: none;
  border: none;
  cursor: pointer;
}
.agent-pc .qr-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}
.agent-pc .qr-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
}
.agent-pc .qr-item:hover { background: #f3f4f6; }
.agent-pc .qr-item-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-pc .qr-item-del {
  font-size: 12px;
  color: #9ca3af;
  cursor: pointer;
  padding: 2px 6px;
}
.agent-pc .qr-item-del:hover { color: #dc2626; }
.agent-pc .qr-empty {
  text-align: center;
  color: #9ca3af;
  font-size: 12px;
  padding: 16px;
}

/* 快捷回复弹窗 */
.agent-pc .qr-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.agent-pc .qr-modal-card {
  background: #fff; border-radius: 12px;
  width: 90%; max-width: 360px; padding: 20px;
}
.agent-pc .qr-modal-card h3 { font-size: 16px; margin-bottom: 12px; color: #111827; }
.agent-pc .qr-modal-card textarea {
  width: 100%; min-height: 80px; border: 1px solid #d1d5db;
  border-radius: 8px; padding: 10px; font-size: 14px; resize: vertical;
  margin-bottom: 14px;
}
.agent-pc .qr-modal-row { display: flex; gap: 10px; }
.agent-pc .qr-modal-btn { flex: 1; padding: 10px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.agent-pc .qr-modal-btn.cancel { background: #f3f4f6; color: #374151; }
.agent-pc .qr-modal-btn.submit { background: #3b82f6; color: #fff; }

/* 消息音设置面板 */
.agent-pc .sound-panel {
  position: absolute;
  top: 58px; right: 16px;
  width: 220px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  z-index: 70;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.agent-pc .sound-panel-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #374151; }
.agent-pc .sound-panel-row select { flex: 1; height: 30px; border-radius: 6px; border: 1px solid #d1d5db; }

/* tost */
.agent-pc .toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 8px;
  background: rgba(15,23,42,.85);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
  z-index: 50;
}
.agent-pc .toast.show { opacity: 1; }

/* 滚动条 */
.agent-pc ::-webkit-scrollbar { width: 8px; }
.agent-pc ::-webkit-scrollbar-track { background: transparent; }
.agent-pc ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.agent-pc ::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
