/* ==========================================
   成员管理系统 - 全局样式
   ========================================== */

/* ── CSS 变量 ──────────────────────────── */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #e0e7ff;
  --secondary: #0f172a;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0284c7;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --sidebar-width: 240px;
  --header-height: 64px;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 16px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 32px rgba(0,0,0,.14);
  --transition: all .2s ease;
}

/* ── 基础重置 ──────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--gray-700);
  background: var(--gray-100);
}

a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ── 认证页（登录/注册等）──────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.auth-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo .brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px; height: 60px;
  background: var(--primary-light);
  border-radius: 16px;
  margin-bottom: 12px;
}
.auth-logo .brand-icon i { font-size: 28px; color: var(--primary); }
.auth-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--secondary); margin: 0 0 4px; }
.auth-logo p { color: var(--gray-500); margin: 0; font-size: 13px; }

/* ── 侧边栏 ──────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--secondary);
  overflow-y: auto;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.sidebar-logo {
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header-height);
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo .logo-icon i { color: #fff; font-size: 18px; }
.sidebar-logo .logo-text { overflow: hidden; }
.sidebar-logo .logo-text span { display: block; font-weight: 700; color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logo .logo-text small { color: rgba(255,255,255,.45); font-size: 11px; }

.sidebar-nav { padding: 12px 8px; flex: 1; }

.nav-section-title {
  color: rgba(255,255,255,.3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 12px 12px 6px;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.65);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-nav .nav-link i { font-size: 16px; flex-shrink: 0; width: 18px; text-align: center; }
.sidebar-nav .nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-nav .nav-link.active { color: #fff; background: var(--primary); }

/* ── 顶栏 ────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

.topbar-title { font-size: 16px; font-weight: 600; color: var(--gray-900); }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--gray-100);
  cursor: pointer;
  transition: var(--transition);
}
.user-chip:hover { background: var(--gray-200); }
.user-chip .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.user-chip .user-name { font-size: 13px; font-weight: 500; color: var(--gray-700); }
.user-chip .user-rank { font-size: 11px; color: var(--gray-500); }

/* ── 主内容区 ─────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  padding-top: var(--header-height);
  min-height: 100vh;
}

.page-container { padding: 24px; max-width: 1400px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 1.375rem; font-weight: 700; color: var(--gray-900); margin: 0; }
.page-header p { color: var(--gray-500); margin: 4px 0 0; font-size: 13px; }

/* ── 卡片 ────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header-title { font-size: 14px; font-weight: 600; color: var(--gray-900); display: flex; align-items: center; gap: 8px; }
.card-header-title i { color: var(--primary); }
.card-body { padding: 20px; }

/* ── 统计卡片 ─────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 22px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-icon-wrap {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon-wrap.blue { background: #eff6ff; }
.stat-icon-wrap.green { background: #f0fdf4; }
.stat-icon-wrap.purple { background: #faf5ff; }
.stat-icon-wrap.orange { background: #fff7ed; }
.stat-icon-wrap.red { background: #fef2f2; }
.stat-icon-wrap i { font-size: 22px; }
.stat-icon-wrap.blue i { color: #2563eb; }
.stat-icon-wrap.green i { color: #16a34a; }
.stat-icon-wrap.purple i { color: #7c3aed; }
.stat-icon-wrap.orange i { color: #d97706; }
.stat-icon-wrap.red i { color: #dc2626; }
.stat-value { font-size: 1.875rem; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ── 表格 ────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  background: var(--gray-50);
  padding: 11px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  letter-spacing: .4px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  font-size: 13.5px;
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr:last-child td { border-bottom: none; }

/* ── 徽章 ────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef9c3; color: #a16207; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-info    { background: #e0f2fe; color: #0284c7; }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-gray    { background: var(--gray-100); color: var(--gray-500); }
.badge-secondary { background: var(--gray-200); color: var(--gray-700); }

/* ── 按钮 ────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 7px; border-radius: 7px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-200); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-200); color: var(--gray-700); }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { background: #b45309; color: #fff; }
.btn-outline-primary { border-color: var(--primary); color: var(--primary); background: transparent; }
.btn-outline-primary:hover:not(:disabled) { background: var(--primary); color: #fff; }
.btn-outline-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-outline-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

/* ── 表单 ────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--gray-900);
  background: #fff;
  transition: var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.form-control:disabled { background: var(--gray-100); cursor: not-allowed; }
.form-control.is-invalid { border-color: var(--danger); }
.form-hint { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; cursor: pointer; }
.form-check input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }
.form-check label { font-size: 13px; color: var(--gray-700); cursor: pointer; }

/* ── 提示框 ──────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.alert i { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── 模态框 ──────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-box {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: var(--transition);
}
.modal-overlay.show .modal-box { transform: translateY(0); }
.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.modal-close { background: none; border: none; cursor: pointer; padding: 4px; color: var(--gray-500); border-radius: 6px; }
.modal-close:hover { background: var(--gray-100); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Toast 通知 ──────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  max-width: 360px;
  animation: slideInRight .25s ease;
  color: #fff;
}
.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-info    { background: #2563eb; }
.toast i { font-size: 16px; }
@keyframes slideInRight { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── 搜索框 ──────────────────────────── */
.search-bar { position: relative; }
.search-bar i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-500); font-size: 15px; }
.search-bar input { padding-left: 34px; }

/* ── 空状态 ──────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-500); }
.empty-state i { font-size: 48px; color: var(--gray-300); display: block; margin-bottom: 16px; }
.empty-state p { font-size: 14px; margin: 0; }

/* ── 分隔线 ──────────────────────────── */
hr.divider { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

/* ── 工具类 ──────────────────────────── */
.text-muted { color: var(--gray-500) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-primary { color: var(--primary) !important; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-4 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.w-100 { width: 100%; }

/* ── 分页 ────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; }
.page-btn {
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 13px;
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-700);
  cursor: pointer;
  transition: var(--transition);
}
.page-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── 暗色模式 ──────────────────────────── */
html[data-theme="dark"] {
  --card-bg: #1a2636;
  --gray-50: #1e293b;
  --gray-100: #1a2332;
  --gray-200: #2a3a4e;
  --gray-300: #3b4d63;
  --gray-500: #8b9db5;
  --gray-700: #c8d3e0;
  --gray-900: #eaf0f7;
  --secondary: #0d1320;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.25);
  --shadow: 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 10px 32px rgba(0,0,0,.45);
}

html[data-theme="dark"] body {
  color: var(--gray-700);
  background: var(--gray-100);
}

html[data-theme="dark"] .auth-card { background: #1e293b; }
html[data-theme="dark"] .auth-logo h1 { color: #eaf0f7; }
html[data-theme="dark"] .auth-logo .brand-icon { background: rgba(79,70,229,.25); }

html[data-theme="dark"] .sidebar { background: var(--secondary); }

html[data-theme="dark"] .topbar {
  background: #131c2a;
  border-bottom-color: var(--gray-200);
}

html[data-theme="dark"] .user-chip { background: var(--gray-200); }
html[data-theme="dark"] .user-chip:hover { background: var(--gray-300); }

/* 卡片 */
html[data-theme="dark"] .card {
  background: #1a2636;
  border-color: var(--gray-200);
}
html[data-theme="dark"] .card-header {
  background: #1a2636;
  border-bottom-color: var(--gray-200);
}

/* 统计卡片 */
html[data-theme="dark"] .stat-card {
  background: #1a2636;
  border-color: var(--gray-200);
}
html[data-theme="dark"] .stat-icon-wrap.blue { background: rgba(37,99,235,.15); }
html[data-theme="dark"] .stat-icon-wrap.green { background: rgba(22,163,74,.15); }
html[data-theme="dark"] .stat-icon-wrap.purple { background: rgba(124,58,237,.15); }
html[data-theme="dark"] .stat-icon-wrap.orange { background: rgba(217,119,6,.15); }
html[data-theme="dark"] .stat-icon-wrap.red { background: rgba(220,38,38,.15); }

/* 表格 */
html[data-theme="dark"] .table th { background: var(--gray-50); border-bottom-color: var(--gray-200); }
html[data-theme="dark"] .table td { border-bottom-color: var(--gray-200); color: var(--gray-700); }
html[data-theme="dark"] .table tbody tr:hover { background: rgba(255,255,255,.04); }

/* 徽章 */
html[data-theme="dark"] .badge-success { background: rgba(22,163,74,.2); color: #4ade80; }
html[data-theme="dark"] .badge-warning { background: rgba(217,119,6,.2); color: #fbbf24; }
html[data-theme="dark"] .badge-danger  { background: rgba(220,38,38,.2); color: #f87171; }
html[data-theme="dark"] .badge-info    { background: rgba(2,132,199,.2); color: #38bdf8; }
html[data-theme="dark"] .badge-gray    { background: var(--gray-200); color: var(--gray-500); }
html[data-theme="dark"] .badge-secondary { background: var(--gray-200); color: var(--gray-700); }

/* 表单 */
html[data-theme="dark"] .form-control {
  background: #0f1a28;
  border-color: var(--gray-300);
  color: var(--gray-900);
}
html[data-theme="dark"] .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.25);
}
html[data-theme="dark"] .form-control:disabled { background: var(--gray-200); }

/* 提示框 */
html[data-theme="dark"] .alert-success { background: rgba(22,163,74,.15); color: #86efac; border-color: rgba(22,163,74,.3); }
html[data-theme="dark"] .alert-danger  { background: rgba(220,38,38,.15); color: #fca5a5; border-color: rgba(220,38,38,.3); }
html[data-theme="dark"] .alert-warning { background: rgba(217,119,6,.15); color: #fde68a; border-color: rgba(217,119,6,.3); }
html[data-theme="dark"] .alert-info    { background: rgba(37,99,235,.15); color: #93c5fd; border-color: rgba(37,99,235,.3); }

/* 模态框 */
html[data-theme="dark"] .modal-box { background: #1a2636; }
html[data-theme="dark"] .modal-header { border-bottom-color: var(--gray-200); }
html[data-theme="dark"] .modal-footer { border-top-color: var(--gray-200); }
html[data-theme="dark"] .modal-close:hover { background: var(--gray-200); }

/* 分页 */
html[data-theme="dark"] .page-btn {
  background: #1a2636;
  border-color: var(--gray-200);
  color: var(--gray-700);
}

/* 按钮 */
html[data-theme="dark"] .btn-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
  border-color: var(--gray-300);
}
html[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
  background: var(--gray-300);
}

/* 分隔线 */
html[data-theme="dark"] hr.divider { border-top-color: var(--gray-200); }

/* 空状态 */
html[data-theme="dark"] .empty-state i { color: var(--gray-300); }

/* 暗色模式切换按钮 */
.theme-toggle {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gray-500);
  transition: var(--transition);
  font-size: 16px;
}
html[data-theme="dark"] .theme-toggle {
  border-color: var(--gray-300);
  color: #fbbf24;
}
.theme-toggle:hover { background: var(--gray-100); }
html[data-theme="dark"] .theme-toggle:hover { background: var(--gray-200); }

/* ── 响应式 ──────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(-240px); }
  .sidebar.open { transform: translateX(0); width: 240px; }
  .topbar { left: 0; }
  .main-content { margin-left: 0; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; }
  .page-container { padding: 16px; }
}

@media (max-width: 576px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .auth-card { padding: 1.5rem; }
}
