/* 同城便民服务 WEB 管理后台 */
:root {
  --primary: #3B82F6;
  --primary-dark: #2563EB;
  --primary-light: #EFF6FF;
  --bg: #F1F5F9;
  --sidebar-bg: #1E293B;
  --sidebar-hover: #334155;
  --sidebar-active: #3B82F6;
  --surface: #FFFFFF;
  --text: #1E293B;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --border: #E2E8F0;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --orange: #F97316;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  display: flex; min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px; background: var(--sidebar-bg); color: white;
  display: flex; flex-direction: column; flex-shrink: 0;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  font-size: 18px; font-weight: 700; letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px; background: var(--primary);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-section { padding: 12px 20px 4px; font-size: 11px; text-transform: uppercase; color: rgba(255,255,255,0.35); letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; margin: 2px 8px; border-radius: var(--radius);
  color: rgba(255,255,255,0.65); cursor: pointer; font-size: 14px;
  transition: all 0.15s; border: none; background: none; width: calc(100% - 16px);
  text-align: left;
}
.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active { background: var(--sidebar-active); color: white; }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item .nav-badge { margin-left: auto; background: var(--danger); color: white; font-size: 11px; padding: 1px 7px; border-radius: 10px; }

.sidebar-footer {
  padding: 12px 20px; border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px; color: rgba(255,255,255,0.35);
}

/* Main Content */
.main { margin-left: 240px; flex: 1; min-height: 100vh; }
.topbar {
  background: var(--surface); padding: 0 24px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-right .user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light);
  display: flex; align-items: center; justify-content: center; color: var(--primary);
  font-weight: 600; font-size: 14px;
}

.content { padding: 24px; }

/* Page */
.page { display: none; }
.page.active { display: block; }

/* Dashboard Stats */
.stats-grid { display: flex; gap: 16px; }
.stat-card {
  flex: 1; background: var(--surface); border-radius: var(--radius-lg);
  padding: 18px 20px; border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: flex-start;
}
.stat-card .sc-body { flex: 1; }
.stat-card .sc-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.stat-card .sc-value { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.stat-card .sc-change { font-size: 12px; color: var(--success); }
.stat-card .sc-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0; margin-left: 12px;
}
.sc-icon.s-blue { background: #EFF6FF; } .sc-icon.s-green { background: #ECFDF5; }
.sc-icon.s-purple { background: #F5F3FF; } .sc-icon.s-amber { background: #FFFBEB; }

/* Panels */
.panel {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.panel-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-title { font-size: 15px; font-weight: 600; }
.panel-body { padding: 20px; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 14px; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid var(--border); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: #F8FAFC; }

/* Badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-info { background: #DBEAFE; color: #1E40AF; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-gray { background: #F1F5F9; color: #475569; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px; border-radius: 6px; font-size: 13px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer; transition: all 0.15s;
  white-space: nowrap;
}
.btn:active { opacity: 0.85; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: white; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 6px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-label .req { color: var(--danger); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-family: inherit; background: white; outline: none;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.form-textarea { min-height: 80px; resize: vertical; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.4); z-index: 500; display: none;
  align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: white; border-radius: var(--radius-lg); width: 90%; max-width: 580px;
  max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Search/Filter Bar */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .search-input {
  width: 280px; padding: 7px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; outline: none;
}
.toolbar .search-input:focus { border-color: var(--primary); }
.toolbar .filter-select {
  padding: 7px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; outline: none; background: white;
}

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 16px; }
.page-btn {
  width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: white; font-size: 13px;
}
.page-btn:hover { background: var(--bg); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Empty State */
.empty { padding: 48px 20px; text-align: center; color: var(--text-muted); }
.empty-icon { font-size: 40px; margin-bottom: 8px; }

/* Toast */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  background: var(--text); color: white; padding: 10px 20px;
  border-radius: 8px; font-size: 13px; animation: toastIn 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }
.toast-success { background: var(--success); }
.toast-warning { background: var(--warning); color: #000; }
.toast-danger { background: var(--danger); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .main { margin-left: 200px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; }
  .toolbar .search-input { width: 100%; }
}

/* ===== 客服聊天面板 ===== */
.chat-admin-wrap { display: flex; gap: 16px; height: 560px; }
.chat-sessions { width: 280px; flex-shrink: 0; border: 1px solid #E5E7EB; border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; }
.chat-sessions-head { padding: 10px 14px; font-size: 13px; font-weight: 600; border-bottom: 1px solid #E5E7EB; background: #F9FAFB; }
.chat-session-list { flex: 1; overflow-y: auto; }
.chat-session-item { padding: 10px 14px; border-bottom: 1px solid #F3F4F6; cursor: pointer; }
.chat-session-item:hover { background: #F9FAFB; }
.chat-session-item.active { background: #EFF6FF; border-left: 3px solid var(--primary); }
.csi-top { display: flex; justify-content: space-between; align-items: center; }
.csi-phone { font-size: 13px; font-weight: 600; }
.csi-time { font-size: 11px; color: var(--text-muted); }
.csi-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.csi-last { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.chat-unread-dot { background: var(--danger); color: #fff; font-size: 11px; border-radius: 10px; padding: 1px 7px; flex-shrink: 0; }
.chat-main { flex: 1; border: 1px solid #E5E7EB; border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; }
.chat-main-head { padding: 10px 14px; font-size: 13px; font-weight: 600; border-bottom: 1px solid #E5E7EB; background: #F9FAFB; }
.chat-msg-list { flex: 1; overflow-y: auto; padding: 14px; background: #F8FAFC; }
.chat-row { display: flex; margin-bottom: 10px; }
.chat-row.left { justify-content: flex-start; }
.chat-row.right { justify-content: flex-end; }
.chat-bubble { max-width: 70%; border-radius: 10px; padding: 8px 12px; font-size: 13px; line-height: 1.5; }
.chat-bubble.user { background: #fff; border: 1px solid #E5E7EB; }
.chat-bubble.admin { background: var(--primary); color: #fff; }
.cb-who { font-size: 11px; opacity: 0.7; margin-bottom: 2px; }
.cb-text { word-break: break-all; white-space: pre-wrap; }
.cb-time { font-size: 10px; opacity: 0.6; margin-top: 3px; text-align: right; }
.chat-reply-bar { display: flex; padding: 10px 14px; border-top: 1px solid #E5E7EB; background: #fff; }

/* 聊天图片消息 */
.cb-img { max-width: 200px; max-height: 200px; border-radius: 8px; display: block; margin: 4px 0; cursor: pointer; }
.chat-bubble.user .cb-img { border: 1px solid #E5E7EB; }
