/* ===== 通用重置 & 变量 ===== */
:root {
  --black: #1a1a1a;
  --black-light: #333;
  --red: #7a2432;
  --red-light: #9b3a4a;
  --gray: #666;
  --gray-light: #999;
  --gray-lighter: #f5f5f5;
  --border: #eee;
  --white: #fff;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
  --sidebar-w: 220px;
  --topbar-h: 60px;
  --transition: all 0.2s;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-lighter);
  color: var(--black);
  font-size: 14px;
  line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; }
input, select, textarea { outline: none; font-family: inherit; }
img { max-width: 100%; }
table { border-collapse: collapse; width: 100%; }

/* ===== 布局框架 ===== */
.layout { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-w);
  background: var(--black);
  color: #fff;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: var(--transition);
}
.sidebar-logo {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  gap: 8px;
}
.sidebar-logo .wine { font-size: 22px; }
.sidebar-nav { padding: 16px 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.05); }
.nav-item.active { color: #fff; background: rgba(255,255,255,0.1); border-left-color: var(--red); }
.nav-item .icon { font-size: 18px; width: 22px; text-align: center; }

/* 主内容区 */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}
.topbar {
  height: var(--topbar-h);
  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;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user { display: flex; align-items: center; gap: 8px; color: var(--gray); font-size: 13px; }

.page-content { padding: 24px; }

/* ===== 卡片 ===== */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ===== 统计卡片 ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon { font-size: 32px; }
.stat-info { flex: 1; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--black); }
.stat-label { font-size: 13px; color: var(--gray); margin-top: 2px; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.up { color: #e74c3c; }
.stat-change.down { color: #2ecc71; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: var(--gray-lighter);
  padding: 12px 16px;
  text-align: left;
  font-weight: 500;
  font-size: 13px;
  color: var(--gray);
  white-space: nowrap;
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.data-table tr:hover td { background: #fafafa; }
.data-table .thumb { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--gray-lighter); display: block; }
.data-table .tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  margin-right: 4px;
  margin-bottom: 2px;
}
.tag-red { background: #fdf0f2; color: var(--red); }
.tag-gray { background: #f5f5f5; color: var(--gray); }
.tag-black { background: var(--black); color: #fff; }
.tag-green { background: #e8f8f0; color: #27ae60; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.btn-primary { background: var(--black); color: #fff; }
.btn-primary:hover { background: var(--black-light); }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-outline { background: transparent; color: var(--gray); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--gray-light); color: var(--black); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 4px; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; color: var(--gray); margin-bottom: 6px; font-weight: 500; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: var(--transition);
  background: var(--white);
}
.form-control:focus { border-color: var(--black); }
.form-control-sm { padding: 6px 10px; font-size: 13px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-row-3 { grid-template-columns: repeat(3, 1fr); }
.form-hint { font-size: 12px; color: var(--gray-light); margin-top: 4px; }

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; }
.modal-lg { max-width: 800px; }
.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 { font-size: 20px; color: var(--gray-light); cursor: pointer; background: none; border: none; padding: 0; line-height: 1; }
.modal-close:hover { color: var(--black); }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== 筛选 & 搜索 ===== */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-search { display: flex; align-items: center; gap: 8px; background: var(--gray-lighter); border-radius: var(--radius); padding: 6px 12px; flex: 1; max-width: 320px; }
.toolbar-search input { border: none; background: transparent; font-size: 13px; width: 100%; }
.toolbar-search .icon { color: var(--gray-light); }
select.form-control-sm { padding: 6px 10px; font-size: 13px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--white); cursor: pointer; }

/* ===== 状态徽章 ===== */
.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500;
}
.status-pending { background: #fff8e1; color: #f39c12; }
.status-paid { background: #e8f5e9; color: #4caf50; }
.status-processing { background: #e3f2fd; color: #2196f3; }
.status-shipped { background: #f3e5f5; color: #9c27b0; }
.status-completed { background: #e8f8f0; color: #27ae60; }
.status-cancelled { background: #fdf0f0; color: #e74c3c; }

/* ===== 分页 ===== */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 16px; }
.page-btn { padding: 6px 12px; border: 1px solid var(--border); border-radius: 4px; background: var(--white); font-size: 13px; cursor: pointer; transition: var(--transition); }
.page-btn:hover { border-color: var(--black); }
.page-btn.active { background: var(--black); color: #fff; border-color: var(--black); }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-light); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== 图片上传占位 ===== */
.img-upload-box {
  width: 100%; height: 160px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; cursor: pointer; transition: var(--transition);
  color: var(--gray-light); font-size: 13px; position: relative; overflow: hidden;
}
.img-upload-box:hover { border-color: var(--black); color: var(--black); }
.img-upload-box .preview-img { position: absolute; inset: 0; object-fit: cover; width: 100%; height: 100%; z-index: 1; }
.img-upload-box input { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 2; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: var(--black); color: #fff; padding: 10px 24px; border-radius: 24px;
  font-size: 13px; z-index: 9999; box-shadow: var(--shadow-lg);
  transition: opacity 0.3s;
}

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}

/* ===== 工具 ===== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.text-red { color: var(--red); }
.text-gray { color: var(--gray); }
.text-sm { font-size: 13px; }
.text-bold { font-weight: 600; }
.text-center { text-align: center; }
