/* =========================================
   学生管理系统 - 样式表（浅色主题）
   ========================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #4e6ef2;
  --primary-hover: #3b5be6;
  --primary-light: #eef1fe;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2329;
  --text-2: #8a9099;
  --border: #e9ebf1;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 35, 41, .04), 0 6px 20px rgba(31, 35, 41, .06);
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }
input, select { font-family: inherit; }

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

/* ---------------- 侧边栏 ---------------- */
.sidebar {
  width: 224px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}
.logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4e6ef2, #7c5cf0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.logo-text { font-size: 16px; font-weight: 700; letter-spacing: .5px; }

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  transition: all .18s;
}
.nav-item:hover { background: #f2f4f9; color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-emoji { font-size: 16px; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.8;
}

/* ---------------- 主区域 ---------------- */
.main { flex: 1; min-width: 0; padding: 26px 30px 40px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 22px; font-weight: 700; }
.subtitle { color: var(--text-2); font-size: 13px; margin-top: 2px; }

.topbar-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  width: 280px;
  height: 40px;
  transition: border-color .18s, box-shadow .18s;
}
.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78, 110, 242, .12);
}
.search-box .search-icon { font-size: 13px; opacity: .6; }
.search-box input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 14px;
  background: transparent;
  color: var(--text);
  min-width: 0;
}

.view-section { display: flex; flex-direction: column; gap: 18px; }

/* ---------------- 按钮 ---------------- */
.btn {
  height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  transition: all .18s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-plain { background: #f2f4f9; color: var(--text); }
.btn-plain:hover { background: #e8ebf2; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ---------------- 统计卡片 ---------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.st-blue { background: #eaf1ff; }
.st-indigo { background: #edecfe; }
.st-pink { background: #fdeaf5; }
.st-green { background: #e7f8f1; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-2); font-size: 13px; margin-top: 2px; }

/* ---------------- 表格 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-wrap { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; min-width: 880px; }
.data-table th {
  text-align: left;
  background: #fafbfd;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #f0f2f7;
  vertical-align: middle;
}
.data-table tbody tr { transition: background .15s; }
.data-table tbody tr:hover { background: #f8f9fd; }
.data-table tbody tr:last-child td { border-bottom: none; }

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  color: #3b4a6b;
}
.cell-name { font-weight: 600; }
.muted { color: #b6bac3; }
.td-actions { white-space: nowrap; }
.contact-line { font-size: 13px; color: var(--text-2); line-height: 1.7; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.badge-male { background: #eaf1ff; color: #3b6df0; }
.badge-female { background: #fdeaf5; color: #e0559a; }

.link-btn {
  border: none;
  background: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background .15s;
}
.link-btn:hover { background: var(--primary-light); }
.link-danger { color: var(--danger); }
.link-danger:hover { background: var(--danger-bg); }

.data-table td.td-loading { text-align: center; color: var(--text-2); padding: 36px 16px; }
.data-table td.empty-cell { text-align: center; padding: 48px 16px; }
.empty-box { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text-2); }
.empty-icon { font-size: 42px; }

.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  flex-wrap: wrap;
}
.page-info { color: var(--text-2); font-size: 13px; }

.pagination { display: flex; gap: 6px; align-items: center; }
.page-btn {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: all .15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }
.page-ellipsis { color: var(--text-2); padding: 0 2px; }

/* ---------------- 弹窗 ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.open { display: flex; animation: fadeIn .18s ease; }

.modal {
  background: var(--card);
  border-radius: 16px;
  width: 680px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
  animation: slideUp .22s ease;
}
.modal-sm { width: 420px; text-align: center; padding: 30px 28px 24px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-close {
  border: none;
  background: none;
  font-size: 22px;
  color: var(--text-2);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  line-height: 1;
}
.modal-close:hover { background: #f2f4f9; color: var(--text); }

#studentForm { padding: 22px 24px 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-item label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-item label em { color: var(--danger); font-style: normal; margin-left: 2px; }
.form-item input, .form-item select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.form-item input:focus, .form-item select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78, 110, 242, .12);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.confirm-icon { font-size: 44px; margin-bottom: 6px; }
.modal-sm h2 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.modal-sm p { color: var(--text-2); font-size: 14px; }
.modal-sm .modal-footer { justify-content: center; border-top: none; margin-top: 20px; padding-top: 0; }
.modal-sm .modal-footer .btn { min-width: 96px; }

/* ---------------- Toast 轻提示 ---------------- */
.toast-box {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, .16);
  opacity: 0;
  transform: translateY(-16px);
  transition: all .3s cubic-bezier(.34, 1.56, .64, 1);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.toast.success .toast-icon { background: #10b981; }
.toast.error .toast-icon { background: var(--danger); }

/* ---------------- 数据统计视图 ---------------- */
.chart-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
}
.chart-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.chart-sub { color: var(--text-2); font-size: 12px; font-weight: 400; margin-left: 8px; }

.stats-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.ratio-track {
  display: flex;
  height: 22px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef0f5;
}
.ratio-male { background: linear-gradient(90deg, #4e6ef2, #6d8bff); }
.ratio-female { background: linear-gradient(90deg, #ec5da0, #f78ac0); }
.ratio-legend { display: flex; gap: 24px; margin-top: 12px; color: var(--text-2); font-size: 13px; flex-wrap: wrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot-male { background: #4e6ef2; }
.dot-female { background: #ec5da0; }

.bar-row {
  display: grid;
  grid-template-columns: 170px 1fr 60px;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
}
.bar-label {
  color: var(--text-2);
  font-size: 13px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track { height: 14px; background: #f0f2f7; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width .6s cubic-bezier(.22, 1, .36, 1); }
.bar-blue { background: linear-gradient(90deg, #4e6ef2, #7d9bff); }
.bar-violet { background: linear-gradient(90deg, #8b5cf6, #b28cff); }
.bar-value { font-size: 13px; color: var(--text); font-weight: 600; white-space: nowrap; }
.chart-empty { color: var(--text-2); text-align: center; padding: 24px 0; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1100px) {
  .stats-two-col { grid-template-columns: 1fr; }
}

@media (max-width: 920px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .logo { border-bottom: none; padding: 14px 18px; }
  .nav { flex-direction: row; padding: 10px; }
  .sidebar-footer { display: none; }
  .main { padding: 18px 16px 30px; }
  .search-box { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 54px; }
}
