/* ========== 后台管理样式 ========== */

/* 登录界面 */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-box {
  background: var(--card);
  border-radius: 20px;
  padding: 40px 32px;
  width: 320px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
  text-align: center;
}

.login-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
}

.login-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  text-align: center;
  letter-spacing: 2px;
  margin-bottom: 16px;
  transition: border-color 0.15s;
}
.login-input:focus { border-color: var(--primary); }

.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.login-btn:hover { opacity: 0.85; }
.login-btn:disabled { opacity: 0.5; }

.login-error {
  color: #FF3B30;
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

#admin-app {
  max-width: 100%;
  min-height: 100vh;
  background: var(--bg);
}

/* 顶部导航 */
.admin-header {
  background: var(--card);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 0.5px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.back-link {
  font-size: 14px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.15s;
}
.back-link:hover { opacity: 0.7; }

.admin-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.admin-school {
  font-size: 13px;
  color: var(--text-2);
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-time {
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* Tab 切换 */
.admin-tabs {
  display: flex;
  background: var(--card);
  padding: 0 24px;
  border-bottom: 0.5px solid var(--border);
  gap: 4px;
}

.admin-tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
}

.admin-tab.active {
  color: var(--text);
  font-weight: 600;
}

.admin-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
}

/* 内容区 */
#admin-content {
  padding: 20px 24px;
}

.admin-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-2);
  font-size: 14px;
}

/* ========== 排班总览 ========== */

.overview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.overview-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.overview-nav-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  font-size: 16px;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.overview-nav-btn:hover { background: #F2F2F7; }

.overview-title {
  font-size: 18px;
  font-weight: 600;
  min-width: 140px;
  text-align: center;
}

.overview-stats {
  display: flex;
  gap: 12px;
}

.overview-stat {
  background: var(--card);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-2);
  box-shadow: var(--shadow);
}
.overview-stat strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  margin-right: 4px;
}

/* 全员沿用上周按钮 */
.btn-copy-week {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.btn-copy-week:hover { opacity: 0.85; }

/* 操作列 */
.action-col {
  min-width: 100px;
  position: sticky;
  right: 0;
  background: var(--card);
  z-index: 2;
}
.action-cell {
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
}
.tt-copy {
  background: #E3F2FD;
  color: #1976D2;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.tt-copy:hover { background: #BBDEFB; }
.tt-clear {
  background: #FFEBEE;
  color: #D32F2F;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.tt-clear:hover { background: #FFCDD2; }

/* 清除排班按钮 */
.override-clear-btn {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 8px;
}
.override-clear-btn .os-label { color: var(--text-2); }

/* 排班总览表格 */
.overview-table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}

.overview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 800px;
}

.overview-table th {
  position: sticky;
  top: 0;
  background: #F8F9FA;
  z-index: 10;
  padding: 8px 4px;
  text-align: center;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.overview-table th.teacher-col {
  text-align: left;
  padding-left: 16px;
  min-width: 120px;
  position: sticky;
  left: 0;
  background: #F8F9FA;
  z-index: 11;
}

.overview-table th.day-col {
  min-width: 36px;
  max-width: 42px;
}

.overview-table th.day-col.we {
  color: #FF3B30;
}

.overview-table td {
  padding: 2px;
  text-align: center;
  border-bottom: 1px solid #F0F0F0;
}

.overview-table td.teacher-cell {
  text-align: left;
  padding: 8px 16px;
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 5;
  border-right: 1px solid var(--border);
}

.overview-table tr:hover td.teacher-cell {
  background: #F8F9FA;
}

.teacher-cell-name {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.teacher-cell-class {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 2px;
}

/* 排班格子 */
.ov-cell {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.ov-cell:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  z-index: 5;
}

.ov-cell.early { background: #FF9800; color: #fff; }
.ov-cell.late { background: #2196F3; color: #fff; }
.ov-cell.full { background: #9C27B0; color: #fff; }
.ov-cell.rest { background: #F0F0F0; color: #AEAEAE; }
.ov-cell.holiday { background: #4CAF50; color: #fff; }
.ov-cell.today { outline: 2px solid #FF3B30; outline-offset: -2px; }
.ov-cell.overridden { box-shadow: inset 0 0 0 2px #FF5722; }

/* ========== 教师管理 ========== */

.teacher-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.teacher-count {
  font-size: 14px;
  color: var(--text-2);
}
.teacher-count strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  margin-right: 4px;
}

.btn-add {
  padding: 8px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-add:hover { opacity: 0.85; }
.btn-add:active { transform: scale(0.97); }

.teacher-table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}

.teacher-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 700px;
}

.teacher-table th {
  background: #F8F9FA;
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-2);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.teacher-table td {
  padding: 10px 16px;
  border-bottom: 1px solid #F0F0F0;
}

.teacher-table tr:hover { background: #F8F9FA; }
.teacher-table tr:last-child td { border-bottom: none; }

.tt-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  vertical-align: middle;
  margin-right: 8px;
}

.tt-name { font-weight: 600; vertical-align: middle; }
.tt-code { font-size: 12px; color: var(--text-2); font-family: monospace; }
.tt-class { color: var(--text-2); }
.tt-offset {
  display: inline-block;
  padding: 2px 10px;
  background: #F2F2F7;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}

.tt-actions {
  display: flex;
  gap: 8px;
}

.tt-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.tt-btn:hover { background: #F2F2F7; }
.tt-btn.tt-edit { color: var(--primary); border-color: var(--primary); }
.tt-btn.tt-edit:hover { background: #E3F2FD; }
.tt-btn.tt-del { color: #FF3B30; border-color: #FF3B30; }
.tt-btn.tt-del:hover { background: #FFEBEE; }

/* ========== 调班记录 ========== */

.override-bar {
  margin-bottom: 16px;
}

.override-count {
  font-size: 14px;
  color: var(--text-2);
}
.override-count strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  margin-right: 4px;
}

.override-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-2);
  font-size: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.override-empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.override-table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}

.override-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 600px;
}

.override-table th {
  background: #F8F9FA;
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-2);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.override-table td {
  padding: 10px 16px;
  border-bottom: 1px solid #F0F0F0;
}

.override-table tr:hover { background: #F8F9FA; }
.override-table tr:last-child td { border-bottom: none; }

.ot-shift {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}
.ot-shift.early { background: #FFF0E0; color: #E65100; }
.ot-shift.late { background: #E3F2FD; color: #1565C0; }
.ot-shift.full { background: #F3E5F5; color: #6A1B9A; }
.ot-shift.rest { background: #F5F5F5; color: #9E9E9E; }
.ot-shift.holiday { background: #E8F5E9; color: #2E7D32; }

.ot-restore {
  padding: 4px 12px;
  border: 1px solid #FF3B30;
  background: var(--card);
  color: #FF3B30;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.ot-restore:hover { background: #FFEBEE; }

/* ========== 弹窗 ========== */

.admin-modal {
  max-width: 480px;
  border-radius: 16px !important;
  max-height: 80vh;
}

.admin-confirm {
  max-width: 360px;
}

.confirm-msg {
  font-size: 15px;
  text-align: center;
  padding: 16px 0;
  line-height: 1.6;
}

/* 调班弹窗 */
.override-info {
  padding: 0 20px 12px;
  font-size: 14px;
  color: var(--text-2);
  text-align: center;
}
.override-info strong { color: var(--text); }

.override-shifts {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.override-shift-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}
.override-shift-btn:hover {
  border-color: var(--primary);
  background: #F8FBFF;
}
.override-shift-btn:active { transform: scale(0.98); }

.os-block {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.os-block.early { background: #FF9800; }
.os-block.late { background: #2196F3; }
.os-block.full { background: #9C27B0; }
.os-block.rest { background: #E0E0E0; color: #9E9E9E; }
.os-block.holiday { background: #4CAF50; }

.os-label {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  text-align: left;
}

.os-time {
  font-size: 12px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* 教师编辑弹窗 */
.teacher-form {
  padding: 0 20px;
}

.form-row {
  margin-bottom: 16px;
}

.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-row input,
.form-row select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.form-row input:focus,
.form-row select:focus {
  border-color: var(--primary);
}

.form-row input:disabled {
  background: #F2F2F7;
  color: var(--text-2);
}

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.1s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px #fff inset;
}

.form-actions {
  display: flex;
  gap: 10px;
  padding: 16px 20px 20px;
  justify-content: flex-end;
}

.btn-cancel {
  padding: 8px 20px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.15s;
}
.btn-cancel:hover { background: #F2F2F7; }

.btn-save {
  padding: 8px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-save:hover { opacity: 0.85; }

.btn-danger {
  padding: 8px 20px;
  background: #FF3B30;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-danger:hover { opacity: 0.85; }

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 10px 24px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 999;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ========== 部门管理 ========== */

.dept-section {
  margin-bottom: 24px;
}

.dept-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-left: 4px;
}

.dept-section-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.dept-section-count {
  font-size: 12px;
  color: var(--text-2);
  background: #F2F2F7;
  padding: 2px 8px;
  border-radius: 8px;
}

.dept-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.dept-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.dept-card-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.dept-card-count {
  font-size: 12px;
  color: var(--text-2);
  background: #F2F2F7;
  padding: 2px 10px;
  border-radius: 10px;
  margin-left: 10px;
}

.dept-card-actions {
  display: flex;
  gap: 8px;
}

.dept-card-desc {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 12px;
}

.dept-rotation {
  background: #F8F9FA;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}

.dept-rotation-label {
  color: var(--text-2);
  font-weight: 500;
}

.dept-rotation-value {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* 排班类型列表 */
.shift-type-list {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.shift-type-list-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.shift-type-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-2);
  font-size: 13px;
}

.shift-type-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 12px;
}

.shift-type-table th {
  background: #F8F9FA;
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-2);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.shift-type-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #F0F0F0;
}

.shift-type-table tr:last-child td { border-bottom: none; }

.st-color-block {
  display: inline-flex;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.st-time {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.btn-add-sm {
  padding: 6px 16px;
  background: var(--card);
  color: var(--primary);
  border: 1px dashed var(--primary);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-add-sm:hover { background: #E3F2FD; }

/* 时间段编辑 */
.period-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.period-start, .period-end {
  width: 90px !important;
  padding: 8px 12px !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  font-family: inherit !important;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.period-sep {
  color: var(--text-2);
  font-size: 14px;
}

.period-remove {
  width: 28px;
  height: 28px;
  border: 1px solid #FF3B30;
  background: var(--card);
  color: #FF3B30;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.period-remove:hover { background: #FFEBEE; }

.period-add-btn {
  padding: 6px 14px;
  border: 1px dashed var(--primary);
  background: var(--card);
  color: var(--primary);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 4px;
}
.period-add-btn:hover { background: #E3F2FD; }

.form-hint {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 4px;
  line-height: 1.5;
}

/* 部门标签 */
.tt-dept {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .admin-header {
    padding: 10px 16px;
  }
  .admin-school { display: none; }
  .admin-tabs { padding: 0 12px; }
  .admin-tab { padding: 10px 14px; font-size: 13px; }
  #admin-content { padding: 12px 12px; }
  .overview-bar { flex-direction: column; gap: 10px; align-items: flex-start; }
  .overview-stats { flex-wrap: wrap; }
  .teacher-bar { flex-direction: column; gap: 10px; align-items: flex-start; }
  .dept-card { padding: 14px; }
  .shift-type-table { font-size: 12px; }
  .shift-type-table th, .shift-type-table td { padding: 6px 8px; }
}
