/* ============================================================
   客服工作台样式
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --bg: #f0f2f5;
  --border: #e5e6eb;
  --text: #1d2129;
  --muted: #86909c;
  --danger: #f53f3f;
}
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- 登录页 ---------- */
.login-view {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1677ff 0%, #004aad 100%);
}
.login-card {
  width: 340px;
  background: #fff;
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}
.login-card h1 { font-size: 20px; text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 24px; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  margin-bottom: 12px;
}
.login-card input:focus { border-color: var(--primary); }
.remember-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); margin: -4px 0 12px; cursor: pointer;
}
.remember-row input { width: auto; margin: 0; }
.login-card button {
  width: 100%;
  padding: 11px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
  margin-top: 4px;
}
.login-card button:hover { background: var(--primary-hover); }
.login-card .err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- 工作台布局 ---------- */
.work-view {
  height: 100vh;
  display: flex;
  overflow: hidden;
}
.side { width: 300px; background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.quick { width: 260px; background: #fff; border-left: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }

/* ---------- 侧栏头部 ---------- */
.side-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.me-nick { font-size: 16px; font-weight: 600; }
.me-status { font-size: 12px; color: var(--muted); margin-top: 2px; }
.me-status.online { color: #00b42a; }
.switch { position: relative; display: inline-block; width: 44px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0;
  background: #c9cdd4; border-radius: 22px; cursor: pointer; transition: 0.2s;
}
.switch span::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + span { background: #00b42a; }
.switch input:checked + span::before { transform: translateX(22px); }

.side-meta { padding: 8px 16px; display: flex; gap: 16px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); }
.side-meta b { color: var(--primary); }

.session-tabs { display: flex; border-bottom: 1px solid var(--border); }
.session-tabs .tab {
  flex: 1; padding: 9px; background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent;
}
.session-tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-badge {
  display: inline-block; min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: 11px; text-align: center; padding: 0 4px; margin-left: 4px;
}

.session-list { flex: 1; overflow-y: auto; list-style: none; }
.session-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f2f3f5;
  cursor: pointer;
  position: relative;
}
.session-item:hover { background: #f7f8fa; }
.session-item.active { background: #e8f3ff; }
.session-item .s-name { font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; }
.session-item .s-time { font-size: 11px; color: var(--muted); font-weight: 400; }
.session-item .s-preview {
  font-size: 12px; color: var(--muted); margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-right: 26px;
}
.session-item .s-unread {
  position: absolute; right: 12px; bottom: 12px;
  min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px;
  display: none; align-items: center; justify-content: center; padding: 0 5px;
}
.session-item .s-unread.show { display: flex; }
.session-item .s-status-tag {
  display: inline-block; font-size: 11px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; margin-left: 6px;
}
.empty-tip { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 0; }

.logout { margin: 10px 14px; padding: 8px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 13px; }
.logout:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- 聊天区 ---------- */
.chat-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 15px;
}
.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head {
  padding: 12px 18px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-title { font-size: 16px; font-weight: 600; }
.chat-page { font-size: 12px; color: var(--muted); margin-top: 2px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-actions { display: flex; gap: 8px; }
.btn { padding: 6px 14px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: #ffd6d6; }
.btn.danger:hover { background: #fff1f0; border-color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-body { flex: 1; overflow-y: auto; padding: 18px; background: #f7f8fa; }
.chat-input-wrap { display: flex; gap: 10px; padding: 12px 18px; background: #fff; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-input-wrap textarea {
  flex: 1; height: 64px; padding: 10px 12px; border: 1px solid #d9d9d9; border-radius: 8px;
  font-size: 14px; resize: none; outline: none; font-family: inherit; line-height: 1.5;
}
.chat-input-wrap textarea:focus { border-color: var(--primary); }
.chat-input-wrap .btn { height: 64px; padding: 0 24px; font-size: 14px; }

/* 消息气泡 */
.msg { display: flex; margin-bottom: 12px; }
.msg .av {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px;
}
.msg.agent { justify-content: flex-end; }
.msg.agent .av { background: #4096ff; margin-left: 8px; }
.msg.visitor .av { background: #95de64; margin-right: 8px; }
.msg.system { justify-content: center; }
.msg .bubble {
  max-width: 60%; padding: 9px 13px; border-radius: 10px; font-size: 14px;
  word-break: break-word; white-space: pre-wrap; line-height: 1.5;
}
.msg.agent .bubble { background: var(--primary); color: #fff; border-top-right-radius: 2px; }
.msg.visitor .bubble { background: #fff; border: 1px solid var(--border); border-top-left-radius: 2px; }
.msg.system .bubble { background: #eef0f2; color: #999; font-size: 12px; padding: 4px 12px; border-radius: 12px; }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 3px; text-align: right; }
.msg.visitor .meta { text-align: left; }
.msg .msg-img { max-width: 220px; max-height: 220px; border-radius: 6px; display: block; cursor: zoom-in; }
.msg.agent .msg-img { border: 1px solid rgba(255,255,255,.3); }

/* ---------- 快捷回复 ---------- */
.quick-head {
  padding: 12px 14px; font-weight: 600; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.quick-tabs { display: flex; gap: 10px; }
.quick-tabs .qt {
  background: none; border: none; cursor: pointer; font-size: 13px; color: var(--muted);
  padding: 4px 2px; border-bottom: 2px solid transparent; font-weight: 600;
}
.quick-tabs .qt.active { color: var(--primary); border-bottom-color: var(--primary); }
.qt-tip { padding: 8px 14px; font-size: 12px; color: var(--muted); background: #f7f8fa; border-bottom: 1px solid #f2f3f5; line-height: 1.6; }
.quick-head .count { font-size: 12px; color: var(--muted); font-weight: 400; }
.quick-list { flex: 1; overflow-y: auto; list-style: none; }
.quick-item { padding: 10px 14px; border-bottom: 1px solid #f2f3f5; cursor: pointer; }
.quick-item:hover { background: #f7f8fa; }
.quick-item .q-title { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.quick-item .q-content {
  font-size: 12px; color: var(--muted); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.quick-item .q-del { color: #bbb; font-size: 13px; cursor: pointer; padding: 0 4px; }
.quick-item .q-del:hover { color: var(--danger); }
.quick-form { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.quick-form input, .quick-form textarea {
  padding: 8px 10px; border: 1px solid #d9d9d9; border-radius: 6px; font-size: 13px; outline: none; font-family: inherit;
}
.quick-form textarea { height: 56px; resize: none; }
.quick-form input:focus, .quick-form textarea:focus { border-color: var(--primary); }
.quick-form .q-form-head { display: flex; justify-content: space-between; align-items: center; }
.quick-form .q-cancel { color: var(--muted); font-size: 12px; cursor: pointer; background: none; border: none; }

/* ============================================================
   移动端适配 (≤768px: 左侧会话列表常驻, 右侧为抽屉)
   ============================================================ */
.mobile-nav { display: none; }
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
/* 聊天区快捷回复按钮行(移动端常驻, 桌面隐藏) */
.quick-bar {
  display: none; gap: 6px; overflow-x: auto; padding: 6px 10px;
  background: #fff; border-top: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
.qb-btn {
  flex-shrink: 0; padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 12px; background: #f7f8fa; color: #4e5969;
  font-size: 12px; cursor: pointer; white-space: nowrap;
}
.qb-btn:hover { border-color: var(--primary); color: var(--primary); }
@media (max-width: 768px) {
  .work-view { position: relative; }
  .main { flex: 1; min-width: 0; }
  /* 左侧会话列表: 常驻占位显示(不再抽屉收起) */
  .side {
    position: static; width: 200px; flex-shrink: 0;
    transform: none; box-shadow: none; border-right: 1px solid var(--border);
  }
  .side.open { transform: none; }
  /* 右侧仍为抽屉(⚡ 打开) */
  .quick {
    position: fixed; right: 0; top: 0; bottom: 0; width: 280px;
    z-index: 60; transform: translateX(105%); transition: transform .25s ease;
    box-shadow: -2px 0 16px rgba(0,0,0,.22);
  }
  .quick.open { transform: translateX(0); }
  .mobile-nav { display: inline-flex !important; align-items: center; justify-content: center; min-width: 34px; padding: 6px 8px; }
  .chat-head { gap: 6px; }
  .chat-head-info { flex: 1; min-width: 0; }
  .chat-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat-page { display: none; }
  .chat-actions { gap: 6px; }
  .chat-input-wrap { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .chat-input-wrap textarea { height: 44px; }
  .chat-input-wrap .btn { height: 44px; padding: 0 16px; }
  .msg .bubble { max-width: 78%; }
  .quick-bar { display: flex; } /* 移动端常驻显示快捷回复按钮行 */
  .chat-empty { padding: 0 20px; text-align: center; }
  .login-card { width: 300px; padding: 30px 24px; }
}
