/* ========== 基础重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --text: #1C1C1E;
  --text-2: #8E8E93;
  --text-3: #C7C7CC;
  --border: #E5E5EA;
  --primary: #2196F3;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Microsoft YaHei', 'PingFang SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: 56px;
}

/* ========== 顶部头部 ========== */
.app-header {
  background: var(--card);
  padding: 44px 20px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 0.5px solid var(--border);
}

.school-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.admin-link {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  margin-left: 10px;
  padding: 2px 8px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.15s;
}
.admin-link:active { background: #E3F2FD; }

.header-right { display: flex; align-items: center; }

.header-user {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 4px 10px 4px 4px;
  border-radius: 20px;
  background: #F2F2F7;
  transition: background 0.15s;
}

.header-user:active { background: #E5E5EA; }

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron { color: var(--text-2); }

/* ========== 控制栏 ========== */
.controls-bar {
  background: var(--card);
  padding: 8px 20px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 0.5px solid var(--border);
}

/* 分段控件 */
.segmented-control {
  display: flex;
  background: #F2F2F7;
  border-radius: 9px;
  padding: 2px;
}

.seg-btn {
  padding: 5px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: none;
  color: var(--text-2);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s;
}

.seg-btn.active {
  background: #fff;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* 范围切换 */
.scope-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
}

.scope-btn {
  padding: 4px 4px;
  font-size: 13px;
  border: none;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.15s;
}

.scope-btn.active {
  color: var(--text);
  font-weight: 600;
}

.scope-sep { color: var(--text-3); font-size: 13px; }

/* ========== 内容区 ========== */
.content { padding: 16px 16px 8px; }

/* ========== 今日卡片 ========== */
.today-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.today-label {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.today-shift-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.today-shift-name {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.today-pill {
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
}

.today-times {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.today-time {
  background: #F2F2F7;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.today-note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-2);
}

/* ========== 月份/周导航 ========== */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 14px;
  position: relative;
}

.nav-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 20px;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.nav-btn:active { background: #E5E5EA; }

.nav-title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}

.nav-today-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 12px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 14px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
}

.nav-today-btn:active { background: #F2F2F7; }

/* ========== 日历 ========== */
.calendar {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  padding: 8px;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding-bottom: 6px;
}

.cal-weekday {
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}

.cal-weekday.we { color: #FF3B30; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 1px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.1s;
}

.cal-cell:active { background: #F2F2F7; }

.cal-cell.empty { cursor: default; }
.cal-cell.empty:active { background: transparent; }

.cal-day-wrap {
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}

.cal-day {
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  color: var(--text);
}

.cal-day.we { color: #FF3B30; }
.cal-day.dim { color: var(--text-3); }

.cal-day.today-circle {
  background: #FF3B30;
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.cal-block {
  flex: 1;
  width: 100%;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  min-height: 18px;
}

/* 班次色块 */
.cal-block.early { background: #FF9800; color: #fff; }
.cal-block.late { background: #2196F3; color: #fff; }
.cal-block.full { background: #9C27B0; color: #fff; }
.cal-block.rest { background: #F0F0F0; color: #AEAEAE; }
.cal-block.holiday { background: #4CAF50; color: #fff; }

/* ========== 周视图卡片 ========== */
.week-cards { display: flex; flex-direction: column; gap: 6px; }

.week-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.1s;
}

.week-card:active { transform: scale(0.98); }

.week-card.today {
  border-left: 3px solid #FF3B30;
  padding-left: 13px;
}

.week-card.rest-day { opacity: 0.6; }

.wc-left {
  text-align: center;
  min-width: 48px;
}

.wc-day {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}

.wc-day.we { color: #FF3B30; }

.wc-wd {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 1px;
}

.wc-wd.today-tag {
  color: #FF3B30;
  font-weight: 600;
}

.wc-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
  flex-shrink: 0;
}

.wc-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.wc-shift-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wc-badge {
  padding: 3px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.wc-badge.early { background: #FFF0E0; color: #E65100; }
.wc-badge.late { background: #E3F2FD; color: #1565C0; }
.wc-badge.full { background: #F3E5F5; color: #6A1B9A; }
.wc-badge.rest { background: #F5F5F5; color: #9E9E9E; }
.wc-badge.holiday { background: #E8F5E9; color: #2E7D32; }

.wc-times {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.wc-time {
  background: #F2F2F7;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.wc-note {
  font-size: 12px;
  color: var(--text-2);
}

/* ========== 人员网格 ========== */
.person-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.person-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s;
  border: 2px solid transparent;
}

.person-card:active { transform: scale(0.97); }
.person-card.current { border-color: var(--primary); }

.person-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.person-info { flex: 1; min-width: 0; }

.person-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-class {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 1px;
}

.person-today {
  font-size: 11px;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 8px;
  display: inline-block;
  font-weight: 500;
}

/* ========== 底部图例 ========== */
.legend {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--card);
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 10px 16px;
  border-top: 0.5px solid var(--border);
  z-index: 50;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-2);
}

.legend-chip {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-block {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

/* 部门分组标签 */
.dept-group-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding: 8px 4px 6px;
  grid-column: 1 / -1;
}

.modal-dept-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding: 10px 20px 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

/* ========== 弹窗 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.show {
  display: flex;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  background: var(--card);
  width: 100%;
  max-width: 480px;
  border-radius: 16px 16px 0 0;
  max-height: 70vh;
  overflow-y: auto;
  animation: slideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-grip {
  width: 36px;
  height: 5px;
  background: #E0E0E0;
  border-radius: 3px;
  margin: 8px auto 0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px 8px;
}

.modal-header h3 { font-size: 17px; font-weight: 600; }

.modal-close {
  border: none;
  background: none;
  font-size: 26px;
  color: var(--text-2);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
}

.modal-body { padding: 4px 0 20px; }

.modal-user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.1s;
}

.modal-user-item:active { background: #F2F2F7; }
.modal-user-item.current { background: #F0F7FF; }
