/* ============ 基础重置 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f3f4f6;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ============ 按钮 ============ */
.btn {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-family: inherit;
  background: #e5e7eb;
  color: #374151;
  transition: all 0.15s;
}
.btn:hover { background: #d1d5db; }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-ghost { background: transparent; color: #6b7280; }
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: #fff; }
.btn-block { width: 100%; margin-top: 12px; }

/* ============ 登录页 ============ */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
}
.login-card {
  width: 360px;
  background: #fff;
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.15);
}
.login-logo {
  font-size: 22px;
  font-weight: 600;
  color: #1f2937;
  text-align: center;
}
.login-sub {
  font-size: 13px;
  color: #6b7280;
  text-align: center;
  margin: 6px 0 28px;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: #4b5563;
  gap: 6px;
}
.login-label input {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.login-label input:focus { border-color: #3b82f6; }
.login-error {
  color: #dc2626;
  font-size: 13px;
  min-height: 18px;
}

/* ============ 顶部状态栏 ============ */
.topbar {
  height: 52px;
  background: #1e293b;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.brand { font-size: 16px; font-weight: 600; }
.status-pill {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  background: rgba(255,255,255,0.1);
}
.status-ok { background: rgba(34,197,94,0.2); color: #4ade80; }
.status-pending { background: rgba(234,179,8,0.2); color: #facc15; }
.status-error { background: rgba(239,68,68,0.2); color: #f87171; }

/* ============ 主布局 ============ */
.main-layout {
  display: flex;
  height: calc(100vh - 52px);
}
.sidebar {
  width: 280px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}
.sidebar-header { padding: 12px; border-bottom: 1px solid #f3f4f6; }
.search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}
.search-input:focus { border-color: #3b82f6; }
.session-list {
  flex: 1;
  overflow-y: auto;
}
.session-item {
  padding: 14px 16px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background 0.1s;
}
.session-item:hover { background: #f9fafb; }
.session-item.active { background: #eff6ff; border-left: 3px solid #3b82f6; }
/* 未读会话：红色高亮 + 红点，打开查看后消失 */
.session-item.unread { background: #fef2f2; border-left: 3px solid #dc2626; }
.session-item.unread .session-name { color: #dc2626; font-weight: 600; }
.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #dc2626;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}
.session-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.session-name { font-weight: 500; color: #1f2937; }
.session-time { font-size: 11px; color: #9ca3af; }
.session-preview {
  font-size: 12px;
  color: #6b7280;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ 聊天区 ============ */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  gap: 12px;
}
.chat-empty-icon { font-size: 48px; }
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-header {
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}
.chat-peer-nickname { font-weight: 600; font-size: 15px; }
.chat-peer-id { font-size: 12px; color: #9ca3af; margin-left: 10px; }
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  background: #f9fafb;
}
.message-row {
  display: flex;
  margin-bottom: 12px;
}
.message-row.inbound { justify-content: flex-start; }
.message-row.outbound { justify-content: flex-end; }
/* 70% 宽度限制放在外层包裹 div 上（相对整行宽度），气泡内文字才能单行铺开 */
.message-row > div {
  max-width: 70%;
  min-width: 0;
}
.message-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.message-row.inbound .message-bubble {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-top-left-radius: 2px;
}
.message-row.outbound .message-bubble {
  background: #3b82f6;
  color: #fff;
  border-top-right-radius: 2px;
}
.message-time {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 2px;
}
.message-input-area {
  padding: 12px 20px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.message-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 120px;
}
.message-input:focus { border-color: #3b82f6; }

/* ============ 客户面板 ============ */
.customer-panel {
  width: 280px;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}
.customer-header {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-weight: 600;
  border-bottom: 1px solid #e5e7eb;
}
.customer-body { padding: 16px 20px; overflow-y: auto; }
.customer-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
.customer-row-label { color: #6b7280; }
.customer-row-value { color: #1f2937; text-align: right; word-break: break-all; }

/* ============ 弹窗 ============ */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 360px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6b7280;
}
.modal-body { padding: 20px; overflow-y: auto; }
.qr-container {
  text-align: center;
  padding: 16px;
  background: #f9fafb;
  border-radius: 6px;
  margin-bottom: 12px;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-placeholder { color: #9ca3af; font-size: 13px; }
.qr-image { max-width: 200px; max-height: 200px; }
.scan-status {
  margin-top: 12px;
  text-align: center;
  font-size: 13px;
  color: #6b7280;
  min-height: 18px;
}
.scan-status.success { color: #16a34a; }
.scan-status.error { color: #dc2626; }
.scan-tip {
  margin-top: 6px;
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
}
.quick-reply-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quick-reply-group-title {
  font-weight: 600;
  color: #6b7280;
  font-size: 12px;
  margin-top: 8px;
  text-transform: uppercase;
}
.quick-reply-item {
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid #e5e7eb;
}
.quick-reply-item:hover { background: #eff6ff; border-color: #3b82f6; }
.quick-reply-title { font-weight: 500; color: #1f2937; }
.quick-reply-content {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

/* ============ 滚动条美化 ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
