/* ===== 后台管理样式 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #8B4513;
  --primary-light: #A0522D;
  --accent: #D4A017;
  --bg: #F5F5F5;
  --sidebar-bg: #2C1A0E;
  --sidebar-w: 220px;
  --text: #1A1A1A;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --card: #FFFFFF;
  --radius: 10px;
  --shadow: 0 1px 8px rgba(0,0,0,0.08);
  --font: 'Noto Sans SC', -apple-system, sans-serif;
}
body { font-family: var(--font); background: var(--bg); color: var(--text); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* 登录 */
.admin-login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #3B1F0A, #7A3B10);
  display: flex; align-items: center; justify-content: center;
}
.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 360px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo { font-size: 32px; margin-bottom: 8px; }
.login-box h2 { font-size: 18px; font-weight: 700; margin-bottom: 28px; color: var(--text); }
.login-box .form-row { margin-bottom: 16px; }
.login-box input {
  width: 100%; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; outline: none;
  transition: border-color 0.2s;
}
.login-box input:focus { border-color: var(--primary); }
.login-btn {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; font-size: 16px; font-weight: 700;
  border-radius: 8px; transition: all 0.2s;
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(139,69,19,0.35); }
.login-hint { font-size: 12px; color: var(--text-muted); margin-top: 12px; }

/* 后台布局 */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 24px 20px;
  font-size: 18px; font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: #D4A017;
}
.sidebar-logo span:first-child { font-size: 24px; }
.sidebar-nav { flex: 1; padding: 16px 0; }
.sn-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.sn-item:hover { color: #fff; background: rgba(255,255,255,0.08); }
.sn-item.active { color: #D4A017; background: rgba(212,160,23,0.12); border-left-color: #D4A017; }
.sn-item i { width: 18px; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar-footer a, .sidebar-footer button {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  transition: color 0.2s;
}
.sidebar-footer a:hover, .sidebar-footer button:hover { color: #fff; }

/* 主内容 */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 28px;
}
.admin-page { display: none; }
.admin-page.active { display: block; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 20px; font-weight: 700; color: var(--text); }

/* 数据卡片 */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.dash-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.dash-card-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.dash-card-icon.blue { background: #EFF6FF; color: #2563EB; }
.dash-card-icon.green { background: #F0FDF4; color: #16A34A; }
.dash-card-icon.orange { background: #FFF7ED; color: #EA580C; }
.dash-card-icon.purple { background: #FAF5FF; color: #9333EA; }
.dash-card-val { font-size: 28px; font-weight: 800; color: var(--text); font-family: monospace; }
.dash-card-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* 最新订单 */
.dash-recent { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.dash-recent h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--text); }

/* 筛选栏 */
.filter-bar {
  display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
  padding: 9px 14px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; outline: none;
  background: var(--card);
  transition: border-color 0.2s;
}
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--primary); }
.filter-bar input { width: 220px; }

/* 表格 */
.admin-table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  background: #F9FAFB; padding: 12px 16px;
  text-align: left; font-weight: 600; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.admin-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-light, #F3F4F6); vertical-align: middle; }
.admin-table tr:hover td { background: #FAFAFA; }
.prod-thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; }
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600;
}
.status-badge.on_sale { background: #F0FDF4; color: #16A34A; }
.status-badge.off_sale { background: #FEF2F2; color: #DC2626; }
.status-badge.pending { background: #FFF7ED; color: #EA580C; }
.status-badge.paid { background: #EFF6FF; color: #2563EB; }
.status-badge.shipped { background: #F5F3FF; color: #7C3AED; }
.status-badge.completed { background: #F0FDF4; color: #16A34A; }
.status-badge.cancelled { background: #F9FAFB; color: #6B7280; }
.tbl-actions { display: flex; gap: 8px; }
.btn-tbl {
  padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; border: 1px solid;
  transition: all 0.2s;
}
.btn-tbl.edit { color: #2563EB; border-color: #93C5FD; }
.btn-tbl.edit:hover { background: #2563EB; color: #fff; border-color: #2563EB; }
.btn-tbl.del { color: #DC2626; border-color: #FCA5A5; }
.btn-tbl.del:hover { background: #DC2626; color: #fff; border-color: #DC2626; }
.btn-tbl.toggle { color: var(--primary); border-color: #D4A017; }
.btn-tbl.toggle:hover { background: var(--primary); color: #fff; }

/* 新增按钮 */
.btn-add {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; font-size: 14px; font-weight: 600;
  border-radius: 8px; transition: all 0.2s;
}
.btn-add:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(139,69,19,0.3); }

/* 弹窗 */
.admin-modal {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2000;
  width: min(760px, 96vw);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  overflow: hidden;
  max-height: 90vh;
  display: flex; flex-direction: column;
}
.admin-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1999;
  backdrop-filter: blur(2px);
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: #F9FAFB; flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-header button { font-size: 18px; color: var(--text-muted); padding: 4px; border-radius: 4px; transition: all 0.2s; }
.modal-header button:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group label em { color: #E53935; font-style: normal; }
.form-group input, .form-group select, .form-group textarea {
  padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 80px; }

/* SKU管理 */
.sku-section { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 20px; }
.sku-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #F9FAFB;
  border-bottom: 1px solid var(--border);
}
.sku-header h4 { font-size: 14px; font-weight: 700; }
.btn-sm {
  padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 600;
  background: var(--primary); color: #fff; display: flex; align-items: center; gap: 5px; transition: all 0.2s;
}
.btn-sm:hover { background: var(--primary-light); }
.sku-table-wrap { overflow-x: auto; }
.sku-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sku-table th { background: #F9FAFB; padding: 10px 12px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.sku-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-light, #F3F4F6); }
.sku-table input, .sku-table select {
  width: 100%; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; font-family: inherit; outline: none;
}
.sku-table input:focus, .sku-table select:focus { border-color: var(--primary); }
.sku-del-btn { color: #DC2626; padding: 4px; border-radius: 4px; font-size: 14px; transition: all 0.2s; }
.sku-del-btn:hover { background: #FEE2E2; }

/* 表单操作 */
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 4px; }
.btn-cancel { padding: 10px 24px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; color: var(--text-muted); transition: all 0.2s; }
.btn-cancel:hover { border-color: var(--text-muted); color: var(--text); }
.btn-submit {
  padding: 10px 28px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; font-size: 14px; font-weight: 700; border-radius: 8px; transition: all 0.2s;
}
.btn-submit:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(139,69,19,0.3); }

/* 设置页 */
.settings-form { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); max-width: 600px; }
.settings-form .form-group { margin-bottom: 16px; }
.settings-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.settings-form input, .settings-form textarea {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; outline: none;
}
.settings-form textarea { min-height: 80px; resize: vertical; }
.btn-save {
  padding: 11px 28px; background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; font-size: 14px; font-weight: 700; border-radius: 8px; transition: all 0.2s;
  display: flex; align-items: center; gap: 8px;
}
.btn-save:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(139,69,19,0.3); }

/* Toast */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  background: #333; color: #fff;
  padding: 12px 20px; border-radius: 8px; font-size: 14px;
  transition: all 0.3s; pointer-events: none;
  transform: translateY(-80px); opacity: 0;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: #16A34A; }
.toast.error { background: #DC2626; }

/* 加载 */
.loading-spinner {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 60px; color: var(--text-muted); font-size: 14px;
}
.loading-spinner i { font-size: 22px; color: var(--primary); }

@media (max-width: 768px) {
  .admin-sidebar { width: 60px; }
  .sidebar-logo span:last-child, .sn-item span, .sidebar-footer a span, .sidebar-footer button span { display: none; }
  .admin-main { margin-left: 60px; padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
