/* ===========================
   营销平台 - 全局管理后台样式
   =========================== */

:root {
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --sidebar-bg: #1e1e2e;
  --sidebar-text: rgba(255,255,255,0.75);
  --sidebar-active: #4f46e5;
  --bg-main: #f4f6fa;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text-main: #1f2937;
  --text-muted: #6b7280;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Microsoft YaHei', 'PingFang SC', -apple-system, sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  overflow-x: hidden;
}

/* ============ Sidebar ============ */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 200;
  overflow-y: auto;
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.brand-logo {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin-right: 12px;
  flex-shrink: 0;
}
.brand-name { color: #fff; font-size: 15px; font-weight: 700; }
.brand-role { color: rgba(255,255,255,0.4); font-size: 11px; margin-top: 2px; }

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}
.nav-section-title {
  color: rgba(255,255,255,0.3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 16px 20px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 8px;
  margin: 1px 10px;
  transition: all 0.2s;
  font-size: 14px;
}
.nav-item i {
  width: 20px;
  font-size: 14px;
  margin-right: 12px;
  text-align: center;
  opacity: 0.7;
}
.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.nav-item:hover i { opacity: 1; }
.nav-item.active {
  background: var(--primary);
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(79,70,229,0.4);
}
.nav-item.active i { opacity: 1; }
.nav-item.text-danger { color: #ef4444 !important; }
.nav-item.text-danger:hover { background: rgba(239,68,68,0.15); }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
}

/* ============ Main Layout ============ */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
  overflow-x: hidden;
  position: relative;
  z-index: 1;
  width: calc(100% - var(--sidebar-width));
}

/* ============ Topbar ============ */
.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.sidebar-toggle {
  background: none; border: none;
  font-size: 18px; cursor: pointer;
  color: var(--text-muted);
  display: none;
  padding: 6px;
  border-radius: 8px;
}
.sidebar-toggle:hover { background: var(--bg-main); }
.topbar-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-main) !important;
  text-decoration: none;
  font-size: 14px;
}
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
}

/* ============ Content Area ============ */
.content-area {
  padding: 24px;
  flex: 1;
  overflow-x: hidden;
  max-width: 100%;
}
.page-header {
  margin-bottom: 24px;
}
.page-header h2 {
  font-size: 22px; font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

/* ============ Stat Cards ============ */
.stat-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.1); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff;
  margin-right: 16px;
  flex-shrink: 0;
}
.stat-blue .stat-icon { background: linear-gradient(135deg, #3b82f6, #60a5fa); box-shadow: 0 4px 12px rgba(59,130,246,0.35); }
.stat-green .stat-icon { background: linear-gradient(135deg, #10b981, #34d399); box-shadow: 0 4px 12px rgba(16,185,129,0.35); }
.stat-orange .stat-icon { background: linear-gradient(135deg, #f59e0b, #fbbf24); box-shadow: 0 4px 12px rgba(245,158,11,0.35); }
.stat-red .stat-icon { background: linear-gradient(135deg, #ef4444, #f87171); box-shadow: 0 4px 12px rgba(239,68,68,0.35); }
.stat-info { flex: 1; }
.stat-num {
  font-size: 28px; font-weight: 800;
  color: var(--text-main); line-height: 1.2;
}
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.stat-footer {
  width: 100%;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.stat-footer strong { color: var(--primary); }

/* ============ Card Box ============ */
.card-box {
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  overflow: hidden;
}
.card-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

/* ============ Table ============ */
.table th {
  background: #f9fafb;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  font-weight: 600;
  border-bottom: 1px solid var(--border) !important;
}
.table td { vertical-align: middle; font-size: 14px; }
.table-hover tbody tr:hover { background: #f8f9ff; }

/* ============ Buttons ============ */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ============ Forms ============ */
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
.form-label { font-weight: 600; font-size: 13px; color: var(--text-main); }

/* ============ Badges ============ */
.badge { font-weight: 500; padding: 5px 10px; border-radius: 6px; }

/* ============ Alert ============ */
.alert { border-radius: 10px; border: none; }

/* ============ Modal ============ */
.modal-content { border-radius: 16px; border: none; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { border-bottom: 1px solid var(--border); padding: 18px 24px; }
.modal-footer { border-top: 1px solid var(--border); padding: 16px 24px; }

/* ============ Filter Bar ============ */
.filter-bar {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

/* ============ Responsive ============ */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.show { display: block; }
  .main-wrapper { margin-left: 0; width: 100%; }
  .sidebar-toggle { display: flex; }
  .content-area { padding: 16px; }
}

/* ============ Merchant Admin (merchant/) specific ============ */
.merchant-topbar-logo {
  color: var(--primary); font-weight: 800; font-size: 18px;
}

/* Login Page Overrides (for merchant) */
.login-page-merchant {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

/* QR Code Box */
.qr-box {
  width: 200px; height: 200px;
  border: 3px dashed var(--primary);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  background: #f8f9ff;
}
.qr-hint { text-align: center; color: var(--text-muted); font-size: 13px; margin-top: 12px; }

/* Tag styles */
.type-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.type-coupon { background: #fef3c7; color: #92400e; }
.type-lottery { background: #fce7f3; color: #9d174d; }
.type-points { background: #dcfce7; color: #14532d; }
.type-checkin { background: #dbeafe; color: #1e3a8a; }
.type-seckill { background: #fee2e2; color: #7f1d1d; }
.type-group { background: #ede9fe; color: #4c1d95; }
.type-scratch { background: #e0f2fe; color: #0c4a6e; }
.type-vote { background: #f3e8ff; color: #581c87; }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 48px; margin-bottom: 16px;
  opacity: 0.4;
}
.empty-state h5 { font-size: 16px; color: var(--text-muted); }
