/* 渭师院课程表 · 管理后台样式：无任何外部依赖 */
:root {
  --primary: #5B8FF9;
  --primary-dark: #2455B8;
  --bg: #F5F6FA;
  --card: #FFFFFF;
  --text: #1F2329;
  --text-2: #4E5969;
  --text-3: #86909C;
  --line: #E5E6EB;
  --danger: #E8684A;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* 重要：下面若干元素写了 display，会覆盖 HTML hidden 属性的默认 display:none，
   必须显式声明，否则弹窗/整页会一直显示且关不掉。 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ---------------- 登录 ---------------- */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #EAF1FE, #F5F6FA 60%);
}

.login__card {
  width: 360px;
  padding: 32px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(31, 35, 41, .1);
}

.login__title { margin: 0; font-size: 20px; }
.login__sub { margin: 6px 0 22px; color: var(--text-3); font-size: 13px; }
.login__label { display: block; margin: 12px 0 6px; color: var(--text-2); font-size: 13px; }
.login__btn { width: 100%; margin-top: 20px; }
.login__error { min-height: 20px; margin-top: 10px; color: var(--danger); font-size: 13px; }
.login__tip { margin: 14px 0 0; color: var(--text-3); font-size: 12px; }

/* ---------------- 通用控件 ---------------- */
.input, .select, .textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.input--tiny { width: 64px; text-align: center; }
.textarea { min-height: 180px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; line-height: 1.5; }

.btn {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #F2F3F5;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { opacity: .88; }
.btn--sm { padding: 5px 12px; font-size: 13px; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--ghost { background: #fff; border-color: var(--line); color: var(--text-2); }
.btn--danger { background: #fff; border-color: #F5C2B6; color: var(--danger); }

.row { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.row--end { justify-content: flex-end; }
.gap { color: var(--text-3); }
.radio { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }

/* ---------------- 主框架 ---------------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__title { font-weight: 600; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar__user { color: var(--text-3); font-size: 13px; }

.tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
}
.tab.is-active { background: #EAF1FE; color: var(--primary-dark); font-weight: 600; }

.content { flex: 1; padding: 16px 20px 40px; }
.panel { display: none; }
.panel.is-active { display: block; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card__head { display: flex; align-items: center; justify-content: space-between; }
.card__title { margin: 0 0 12px; font-size: 15px; }
.card__head .card__title { margin-bottom: 12px; }
.card__subtitle { margin: 18px 0 8px; font-size: 14px; color: var(--text-2); }

.hint {
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #FFF9EC;
  color: #B26217;
  font-size: 13px;
}

/* ---------------- 工具栏 ---------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--card);
  border-radius: var(--radius);
}
.toolbar__spacer { flex: 1; }
.field { display: flex; align-items: center; gap: 6px; }
.field > span { color: var(--text-3); font-size: 13px; white-space: nowrap; }
.select { min-width: 160px; }
.select--sm { min-width: 96px; }
.select--strong { color: var(--primary-dark); font-weight: 600; }

/* ---------------- 课表 ---------------- */
.timetable { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.tt__head { display: flex; border-bottom: 1px solid var(--line); }
.tt__corner { width: 64px; flex: none; }
.tt__dayhead {
  flex: 1;
  padding: 8px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}
.tt__dayhead small { display: block; color: var(--text-3); font-weight: 400; }
.tt__dayhead.is-today { color: var(--primary); font-weight: 600; }
.tt__body { display: flex; position: relative; }
.tt__time { width: 64px; flex: none; }
.tt__cell {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #F2F3F5;
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
}
.tt__col { flex: 1; position: relative; border-left: 1px solid #F2F3F5; }
.tt__col.is-today { background: #FAFBFF; }
.tt__grid-cell { height: 64px; border-bottom: 1px solid #F2F3F5; }
.tt__course {
  position: absolute;
  padding: 4px 4px 4px 8px;
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.25;
  overflow: hidden;
  cursor: pointer;
}
.tt__course b { display: block; font-weight: 600; }
.tt__course small { color: inherit; opacity: .8; }
.tt__empty { padding: 40px; text-align: center; color: var(--text-3); }

/* ---------------- 导入 ---------------- */
.import-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.drop {
  padding: 24px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-2);
}
.drop.is-over { border-color: var(--primary); background: #F5F9FF; }
.drop__tip { color: var(--text-3); font-size: 12px; }
.preview__summary { margin-bottom: 8px; font-weight: 600; }
.preview__errors { margin-bottom: 12px; color: #B26217; font-size: 13px; }
.preview__errors div { padding: 2px 0; }

/* ---------------- 表格 ---------------- */
.table-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid #F2F3F5; text-align: left; white-space: nowrap; }
.table th { background: #FAFAFB; color: var(--text-2); position: sticky; top: 0; }
.table tr:last-child td { border-bottom: none; }

/* ---------------- 组织管理 ---------------- */
.org { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.list { list-style: none; margin: 0; padding: 0; max-height: 460px; overflow: auto; }
.list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.list li:hover { background: #F7F8FA; }
.list li.is-active { background: #EAF1FE; color: var(--primary-dark); font-weight: 600; }
.list__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__actions { display: flex; gap: 6px; opacity: 0; }
.list li:hover .list__actions { opacity: 1; }
.link-btn { border: none; background: none; color: var(--primary); font-size: 12px; cursor: pointer; padding: 0; }
.link-btn--danger { color: var(--danger); }

/* ---------------- 学期 ---------------- */
.term-grid { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.form-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.form-row > label { width: 96px; flex: none; color: var(--text-3); font-size: 13px; }
.section-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.section-row span { width: 64px; color: var(--text-3); font-size: 13px; }

/* ---------------- 弹窗 / Toast ---------------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal__mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); }
.modal__card {
  position: relative;
  width: 460px;
  max-height: 88vh;
  overflow: auto;
  padding: 24px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
}
.modal__title { margin: 0 0 16px; font-size: 16px; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.is-active { border-color: #1F2329; }

.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  padding: 8px 18px;
  border-radius: 8px;
  background: rgba(31, 35, 41, .88);
  color: #fff;
  font-size: 13px;
}
.toast.is-error { background: rgba(178, 60, 34, .92); }

@media (max-width: 1100px) {
  .import-grid, .term-grid, .org { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; }
}
/* ---------------- 导入面板：目标班级 ---------------- */
.toolbar--flat { padding: 0 0 12px; margin-bottom: 0; background: transparent; }

.tag-count {
  padding: 4px 12px;
  border-radius: 12px;
  background: #F2F3F5;
  color: var(--text-3);
  font-size: 13px;
}
.tag-count--on { background: #EAF1FE; color: var(--primary-dark); font-weight: 600; }

.check-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 200px;
  overflow: auto;
  padding: 12px;
  background: #FAFAFB;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.check-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.check-item:hover { border-color: var(--primary); }
.check-item input { margin: 0; }

/* ---------------- 导入面板：编辑工具条 ---------------- */
.edit-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: #FAFAFB;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.edit-toolbar__sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.edit-toolbar__label { color: var(--text-2); font-size: 13px; }

.input--xs { width: 64px; padding: 5px 8px; }
.input--sm { width: 150px; padding: 5px 8px; }
.select--xs { min-width: 104px; padding: 5px 8px; }

/* ---------------- 可编辑课程表 ---------------- */
.table-wrap--tall { max-height: 620px; }
.table--edit { min-width: 1620px; }
.table--edit .col-teaching { width: 180px; }
.table--edit .col-group { width: 180px; }
.table--edit .col-count { width: 70px; }
.table--edit th { font-size: 12px; font-weight: 600; }
.table--edit td { padding: 5px 6px; }
.table--edit .col-check { width: 36px; text-align: center; }
.table--edit .col-day { width: 92px; }
.table--edit .col-section { width: 130px; }
.table--edit .col-weeks { width: 130px; }
.table--edit .col-actions { width: 96px; white-space: nowrap; text-align: right; }

.cell-input {
  width: 100%;
  min-width: 60px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #F7F8FA;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.cell-input:focus { border-color: var(--primary); background: #fff; }
.cell-input.is-invalid { border-color: var(--danger); background: #FCEBE6; }
.cell-input--num { width: 52px; min-width: 52px; text-align: center; }
.cell-section { white-space: nowrap; }
.cell-section .gap { margin: 0 4px; }

.muted { color: var(--text-3); text-align: center; padding: 18px 0; }
.tip { margin: 12px 0 0; color: var(--text-3); font-size: 12px; line-height: 1.7; }
.tip code {
  padding: 2px 6px;
  background: #F2F3F5;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-2);
}
.format-tip {
  padding: 8px 12px;
  margin-bottom: 10px;
  background: #EAF1FE;
  border-radius: 8px;
  color: var(--primary-dark);
  font-size: 13px;
  line-height: 1.7;
}
.format-tip--warn {
  background: #FFF4E3;
  color: #B26217;
}
/* 上一周 / 下一周 并排放在一起 */
.week-nav { display: inline-flex; align-items: center; }
.week-nav .btn { border-radius: 8px; }
.week-nav #prevWeek { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.week-nav #nextWeek { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: none; }
/* 节假日列 */
.tt__dayhead.is-holiday { color: #C9CDD4; }
.tt__dayhead.is-holiday small { color: #C9CDD4; }
.tt__col.is-holiday { background: #FAFAFB; }
.tt__holiday {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  margin-top: -16px;
  text-align: center;
  font-size: 28px;
  color: #E5E6EB;
  font-weight: 600;
  pointer-events: none;
}
/* 临时调整行 */
.change-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid #F2F3F5;
}
.change-row:last-child { border-bottom: none; }
.change-label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; }
.tt__tag {
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.75);
  font-size: 10px;
  font-style: normal;
  font-weight: 400;
}

/* 切周过渡动画 */
.timetable.tt--slide-next {
  animation: tt-slide-in-right .26s ease-out both;
}

.timetable.tt--slide-prev {
  animation: tt-slide-in-left .26s ease-out both;
}

@keyframes tt-slide-in-right {
  from { transform: translateX(36px); opacity: .3; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes tt-slide-in-left {
  from { transform: translateX(-36px); opacity: .3; }
  to { transform: translateX(0); opacity: 1; }
}

/* 节假日：当天的课灰着显示 */
.tt__course.is-holiday {
  filter: grayscale(1);
  opacity: .55;
}

/* ---------------- 消息推送（课前提醒） ---------------- */
.stat-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 14px 0 4px; }
.stat { min-width: 118px; padding: 10px 14px; background: #FAFAFB; border: 1px solid var(--line); border-radius: 8px; }
.stat b { display: block; font-size: 20px; line-height: 1.4; }
.stat span { color: var(--text-3); font-size: 12px; }
.stat.is-warn b { color: var(--danger); }
.kv { margin: 6px 0; font-size: 13px; color: var(--text-2); line-height: 1.9; word-break: break-all; }
.kv b { color: var(--text); font-weight: 600; }
.kv--code { margin: 8px 0; padding: 10px 12px; background: #FAFAFB; border: 1px solid var(--line);
  border-radius: 8px; font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  line-height: 1.7; color: var(--text-2); white-space: pre-wrap; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; }
.badge--on { background: #E6F9F0; color: #1F8A62; }
.badge--off { background: #FCEBE6; color: var(--danger); }
.badge--idle { background: #EEF1F4; color: var(--text-3); }
.tip--danger { color: var(--danger); }
