/* ===== 全局重置 & 变量 ===== */
:root {
  --primary: #667eea;
  --primary-dark: #5a6fd6;
  --primary-light: #eef0ff;
  --success: #27ae60;
  --success-light: #e8f8ef;
  --danger: #e74c3c;
  --danger-light: #fdecea;
  --warning: #f39c12;
  --warning-light: #fef7e6;
  --text: #333;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #e8e8e8;
  --bg: #f5f7fa;
  --white: #fff;
  --sidebar-width: 240px;
  --header-height: 60px;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 布局 ===== */
.layout { display: flex; height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
  color: #ecf0f1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}
.sidebar-brand {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand h2 { font-size: 18px; color: #fff; }
.sidebar-brand p { font-size: 12px; color: rgba(255,255,255,0.5); margin-top: 4px; }

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-left-color: var(--primary);
}
.nav-item .icon { margin-right: 12px; font-size: 18px; }
.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}
.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-footer .logout-btn {
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  border: none;
  background: none;
  font-size: 12px;
}
.sidebar-footer .logout-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* 主内容区 */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 顶部栏 */
.header {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-title { font-size: 18px; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 12px; }

/* 内容区 */
.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ===== 卡片 ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ===== 统计卡片 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.stat-icon.pending { background: var(--warning-light); }
.stat-icon.approved { background: var(--success-light); }
.stat-icon.rejected { background: var(--danger-light); }
.stat-icon.total { background: var(--primary-light); }
.stat-info .stat-number { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-info .stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ===== 表格 ===== */
.table-container { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
th {
  background: #fafbfc;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
tr:hover { background: #f8f9fb; }

/* 状态标签 */
.status-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.status-pending { background: var(--warning-light); color: #e67e22; }
.status-approved { background: var(--success-light); color: var(--success); }
.status-rejected { background: var(--danger-light); color: var(--danger); }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #219a52; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c0392b; }
.btn-outline {
  background: var(--white);
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; }

/* ===== 表单 ===== */
.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.form-input, .form-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}
.form-input:focus, .form-select:focus { border-color: var(--primary); }
.form-input::placeholder { color: #ccc; }
textarea.form-input { resize: vertical; min-height: 80px; }

/* 搜索栏 */
.search-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.search-bar .form-input { width: 240px; }
.search-bar .form-select { width: 140px; }

/* ===== 分页 ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  font-size: 13px;
  color: var(--text-muted);
}
.pagination-btns {
  display: flex;
  gap: 4px;
}
.pagination-btns button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pagination-btns button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-btns button:hover:not(.active):not(:disabled) { border-color: var(--primary); color: var(--primary); }

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 500px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.9);
  transition: transform 0.3s;
}
.modal-overlay.active .modal { transform: scale(1); }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; }
.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text-muted);
}
.modal-close:hover { background: #f5f5f5; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ===== 商户详情弹窗 ===== */
.detail-grid {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 12px 16px;
  font-size: 13px;
}
.detail-label { color: var(--text-muted); text-align: right; }
.detail-value { color: var(--text); word-break: break-all; }
.detail-images {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.detail-images img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
}

/* ===== 分类树 ===== */
.category-tree { list-style: none; }
.category-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: #fff;
}
.category-main {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}
.category-main .cat-name { font-weight: 600; font-size: 14px; }
.category-main .cat-key { color: var(--text-muted); font-size: 12px; font-family: monospace; }
.category-main .cat-sort { color: var(--text-muted); font-size: 12px; }
.category-main .cat-actions { margin-left: auto; display: flex; gap: 6px; }
.category-children {
  padding: 0 16px 12px 40px;
  list-style: none;
}
.sub-category-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 10px;
  border: 1px solid #f0f0f0;
  border-radius: 6px;
  margin-bottom: 4px;
  background: #fafbfc;
}
.sub-category-item .cat-name { font-size: 13px; }
.sub-category-item .cat-key { color: var(--text-muted); font-size: 11px; font-family: monospace; }
.sub-category-item .cat-actions { margin-left: auto; display: flex; gap: 4px; }

/* 禁用状态 */
.category-item.disabled { opacity: 0.5; }
.sub-category-item.disabled { opacity: 0.5; }

/* ===== 图片查看器 ===== */
.image-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}
.image-viewer.active { opacity: 1; visibility: visible; }
.image-viewer img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
}

/* ===== Toast 通知 ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--primary); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 14px; }

/* ===== 加载状态 ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .search-bar { flex-direction: column; }
  .search-bar .form-input, .search-bar .form-select { width: 100%; }
  .modal { width: 95vw; }
  .detail-grid { grid-template-columns: 80px 1fr; }
}
