/* ============================================================
 * 智序教务 · 移动端 H5 样式
 * 移动优先;≥640px 转为更宽的卡片布局;≥960px 模拟手机画框
 * ============================================================ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; padding: 0; }

:root {
  --color-primary: #1677ff;
  --color-primary-2: #4096ff;
  --color-primary-bg: #e6f4ff;
  --color-text: #1f1f1f;
  --color-text-2: #595959;
  --color-text-3: #8c8c8c;
  --color-border: #e8e8e8;
  --color-bg: #f5f7fa;
  --color-card: #ffffff;
  --color-danger: #ff4d4f;
  --color-success: #52c41a;
  --color-warn: #faad14;
  --color-odd: #fff7e6;
  --color-even: #f0f5ff;
  --color-after: #f9f0ff;
  --color-dual: #e6fffb;
  --radius: 10px;
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-header: 0 1px 6px rgba(0, 0, 0, 0.04);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }

/* ============================================================
 * 启动遮罩
 * ============================================================ */
.boot {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #1677ff 0%, #4096ff 50%, #69b1ff 100%);
  transition: opacity .4s ease;
}
.boot.hide { opacity: 0; pointer-events: none; }
.boot-logo { text-align: center; color: #fff; }
.boot-icon {
  width: 84px; height: 84px; line-height: 84px;
  margin: 0 auto 18px;
  background: rgba(255,255,255,.18);
  border: 2px solid rgba(255,255,255,.35);
  border-radius: 22px;
  font-size: 42px; font-weight: 700;
  backdrop-filter: blur(8px);
}
.boot-name { font-size: 24px; font-weight: 600; letter-spacing: 2px; }
.boot-tip { margin-top: 8px; font-size: 13px; opacity: .85; }

/* ============================================================
 * 通用页面
 * ============================================================ */
.page {
  min-height: 100vh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ============================================================
 * 登录页
 * ============================================================ */
#page-login {
  background: linear-gradient(180deg, #1677ff 0%, #4096ff 35%, #f5f7fa 70%);
}
.login-hero {
  padding: 56px 24px 24px;
  text-align: center;
  color: #fff;
}
.login-logo {
  display: inline-flex;
  width: 72px; height: 72px;
  background: rgba(255,255,255,.2);
  border: 2px solid rgba(255,255,255,.4);
  border-radius: 18px;
  align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.login-icon { font-size: 36px; font-weight: 700; color: #fff; }
.login-title { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: 1px; }
.login-subtitle { margin: 6px 0 0; font-size: 14px; opacity: .9; }

.card {
  background: var(--color-card);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  margin: 0 16px;
}
.login-form {
  margin: 0 20px;
  padding: 20px 18px 22px;
}
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block; font-size: 13px; color: var(--color-text-2);
  margin-bottom: 6px;
}
.field-hint {
  display: block; font-size: 12px; color: var(--color-text-3);
  margin-top: 6px; line-height: 1.4;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--color-text);
  background: #f5f7fa;
  border: 1px solid transparent;
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s, background .15s;
}
.field input:focus {
  background: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, .12);
}

.btn-primary {
  display: block; width: 100%;
  margin-top: 6px;
  padding: 13px 16px;
  font-size: 16px; font-weight: 600; color: #fff;
  background: linear-gradient(180deg, var(--color-primary-2), var(--color-primary));
  border: none; border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(22, 119, 255, .25);
  cursor: pointer;
  transition: transform .08s, box-shadow .15s, opacity .15s;
}
.btn-primary:active { transform: translateY(1px); box-shadow: 0 2px 6px rgba(22, 119, 255, .25); }
.btn-primary[disabled] { opacity: .6; cursor: not-allowed; }

.tip {
  margin-top: 12px;
  font-size: 13px; line-height: 1.5;
  min-height: 18px;
  color: var(--color-danger);
  word-break: break-all;
}

.login-footer {
  margin: 28px 0 24px;
  text-align: center;
  font-size: 12px;
  color: var(--color-text-3);
}

/* ============================================================
 * 主页头部
 * ============================================================ */
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-header);
}
.app-header-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-header-r {
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
.user-tag-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-primary-bg);
  padding: 4px 10px;
  border-radius: 999px;
  max-width: 160px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-logo-mini {
  width: 40px; height: 40px; line-height: 40px;
  background: var(--color-primary);
  color: #fff; font-weight: 700; text-align: center;
  border-radius: 10px; font-size: 20px;
}
.app-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 1.5px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-subtitle { font-size: 12px; color: var(--color-text-3); margin-top: 2px; }
.btn-ghost-sm {
  padding: 7px 12px; font-size: 13px;
  color: var(--color-text-2);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
}
.btn-ghost-sm:active { background: #f0f0f0; }

/* ============================================================
 * Tab 栏
 * ============================================================ */
.tabbar {
  display: flex;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: calc(60px + var(--safe-top)); z-index: 9;
}
.tab {
  flex: 1; padding: 11px 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; color: var(--color-text-2);
  background: transparent; border: none; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}
.tab-icon { font-size: 16px; }

.tab-pane { display: none; padding: 12px 12px 24px; }
.tab-pane.active { display: block; }

/* ============================================================
 * 选择器 (班级 / 教师)
 * ============================================================ */
.picker-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-card);
}
.picker-label { font-size: 13px; color: var(--color-text-2); white-space: nowrap; }
.picker-control {
  flex: 1;
  display: flex; align-items: center; gap: 4px;
  min-width: 0;
}
.btn-arrow {
  width: 32px; height: 32px;
  font-size: 22px; line-height: 1;
  color: var(--color-primary);
  background: var(--color-primary-bg);
  border: none; border-radius: 8px;
  cursor: pointer; flex-shrink: 0;
}
.btn-arrow:active { background: #bae0ff; }
.btn-arrow[disabled] { color: #bfbfbf; background: #f5f5f5; cursor: not-allowed; }
.picker-name {
  flex: 1; min-width: 0;
  font-size: 15px; font-weight: 600;
  text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 0 4px;
}
.picker-select {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}
/* 把原生 select 放在箭头按钮附近,被点箭头时主动拉起 */
.picker-control { position: relative; }

/* 搜索式 picker (输入框 + 下拉) */
.picker-control.searchable { padding: 0; }
.picker-nav-wrap {
  display: flex !important;
  align-items: center;
  gap: 4px;
}
.picker-input-wrap {
  position: relative;
  flex: 1; min-width: 0;
}
.picker-nav {
  width: 32px; height: 32px;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--color-primary);
  background: var(--color-primary-bg);
  border: none; border-radius: 8px;
  cursor: pointer;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  transition: background .15s, color .15s;
}
.picker-nav:hover:not([disabled]) { background: #bae0ff; }
.picker-nav:active:not([disabled]) { background: #91caff; }
.picker-nav[disabled] {
  color: #bfbfbf; background: #f5f5f5; cursor: not-allowed;
}
.picker-input {
  flex: 1; min-width: 0;
  width: 100%;
  padding: 7px 32px 7px 12px;
  font-size: 15px; font-weight: 500;
  color: var(--color-text);
  background: #f5f7fa;
  border: 1px solid transparent;
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.picker-input::placeholder { color: #bfbfbf; font-weight: 400; }
.picker-input:focus {
  background: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, .12);
}
.picker-clear {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 24px; height: 24px;
  font-size: 18px; line-height: 1;
  color: #999;
  background: transparent;
  border: 0; border-radius: 50%;
  cursor: pointer;
  display: none;          /* 有内容时才显示 */
  padding: 0;
}
.picker-clear:hover { background: #f0f0f0; color: #555; }
.picker-input:not(:placeholder-shown) + .picker-clear { display: inline-flex; align-items: center; justify-content: center; }

.picker-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
  margin: 0; padding: 4px 0;
  list-style: none;
  display: none;          /* 默认收起 */
}
.picker-dropdown.open { display: block; }
.picker-dropdown li {
  padding: 9px 12px;
  font-size: 14px;
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid #f5f5f5;
}
.picker-dropdown li:last-child { border-bottom: 0; }
.picker-dropdown li:hover,
.picker-dropdown li.active {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}
.picker-dropdown li.empty {
  color: #999; cursor: default; text-align: center; padding: 14px 12px;
  background: transparent !important; color: #999 !important;
}
.picker-dropdown li .sub {
  color: var(--color-text-3); font-size: 12px; margin-left: 6px;
}
.picker-dropdown mark {
  background: #fff3a3; color: inherit; padding: 0 1px; border-radius: 2px;
}

/* ============================================================
 * 元信息行
 * ============================================================ */
.meta-line {
  font-size: 12px; color: var(--color-text-3);
  padding: 4px 4px 10px;
}

/* ============================================================
 * 课表网格
 * ============================================================ */
.schedule-wrap {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 8px 6px 10px;
  overflow-x: auto;
}
.schedule-table {
  display: grid;
  /* 列定义必须与 app.js 中的 MAX_DAYS 同步: 1 列节次 + 5 列(周一~周五) */
  grid-template-columns: 36px repeat(5, minmax(54px, 1fr));
  gap: 3px;
  min-width: 100%;
}
.sc-cell {
  background: #fafafa;
  border-radius: 6px;
  padding: 6px 4px;
  font-size: 12px;
  min-height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  word-break: break-all;
  line-height: 1.3;
  position: relative;
}
.sc-cell.head {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  font-weight: 600;
  font-size: 12px;
  min-height: 30px;
  padding: 4px 2px;
}
.sc-cell.row-head {
  background: #f5f5f5;
  color: var(--color-text-2);
  font-weight: 500;
  font-size: 12px;
}
.sc-cell.empty { background: transparent; }

.sc-subject { font-weight: 600; color: var(--color-text); margin-bottom: 2px; }
.sc-class { color: var(--color-text-2); font-size: 11px; }
.sc-room { color: var(--color-text-3); font-size: 10px; margin-top: 2px; }
.sc-tag {
  position: absolute; top: 2px; right: 3px;
  font-size: 9px;
  padding: 0 4px;
  border-radius: 6px;
  color: #fff;
  line-height: 14px;
  height: 14px;
}
.sc-tag.odd { background: var(--color-warn); }
.sc-tag.even { background: var(--color-primary); }
.sc-tag.after { background: #b37feb; }
.sc-tag.dual { background: #13c2c2; }

.sc-cell.t-odd { background: var(--color-odd); }
.sc-cell.t-even { background: var(--color-even); }
.sc-cell.t-after { background: var(--color-after); }
.sc-cell.t-dual { background: var(--color-dual); }

/* ============================================================
 * 课表点击高亮
 *  - 选中格 (data-active):      鲜明,黄底橙边
 *  - 同行其他 (data-active-row): 浅蓝
 *  - 同列标签 (data-active-col): 浅蓝 + 加粗 (表头 + 节次标签)
 *  - 其余: 半透明 (opacity .25)
 * ============================================================ */
.schedule-table .sc-cell { transition: opacity .18s ease, background-color .18s ease, transform .18s ease; }
.schedule-table.hl-active .sc-cell:not([data-active]):not([data-active-row]):not([data-active-col]) {
  opacity: .22;
}
.sc-cell[data-active] {
  background: #fff3a3 !important;
  border: 2px solid #ff9800;
  box-shadow: 0 4px 12px rgba(255, 152, 0, .25);
  transform: scale(1.03);
  z-index: 3;
  opacity: 1 !important;
}
.sc-cell[data-active-row] {
  background: #e6f4ff !important;
  opacity: 1 !important;
}
.sc-cell[data-active-col] {
  background: #d6e8ff !important;
  opacity: 1 !important;
}
.sc-cell.row-head[data-active-col] {
  background: #2b6cff !important;
  color: #fff !important;
  font-weight: 700;
}
.sc-cell.head[data-active-col] {
  background: #1677ff !important;
  color: #fff !important;
  font-weight: 700;
}
/* 子块(.sc-sub) 在父格高亮时维持清晰 */
.sc-cell[data-active] .sc-sub,
.sc-cell[data-active-row] .sc-sub { opacity: 1; }

/* ============================================================
 * 教师简表 浮窗 (hover 单元格时弹出)
 * ============================================================ */
.tch-preview {
  position: fixed; z-index: 200;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  padding: 10px 10px 8px;
  width: 360px;
  max-width: calc(100vw - 24px);
  border: 1px solid #e8e8e8;
  animation: tp-fadein .14s ease;
  pointer-events: auto;       /* 浮窗上 hover 不会消失 */
}
@keyframes tp-fadein { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.tch-preview.hidden { display: none; }
.tch-preview .tp-title {
  font-size: 13px; font-weight: 600;
  color: var(--color-text);
  padding: 0 2px 6px;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 6px;
}
.tch-preview .tp-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 2px;
  table-layout: fixed;
  font-size: 11px;
}
.tch-preview .tp-th,
.tch-preview .tp-rh {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  font-weight: 600;
  text-align: center;
  padding: 3px 2px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.2;
  width: 50px;
}
.tch-preview .tp-td {
  background: #fafafa;
  border-radius: 4px;
  text-align: center;
  vertical-align: middle;
  padding: 4px 2px;
  min-height: 28px;
  font-weight: 600;
  color: var(--color-text);
}
.tch-preview .tp-td.empty { background: transparent; }
/* 班级课表点击高亮时:浮窗里对应 (d,p) 单元格加粗绿框 */
.tch-preview .tp-td.match {
  border: 2.5px solid #16a34a;
  background: #dcfce7 !important;
  box-shadow: 0 0 0 1px rgba(22, 163, 74, .15);
  position: relative;
}
.tch-preview .tp-td.empty.match {
  background: #f0fdf4 !important;
}
.tch-preview .tp-sub {
  display: inline-block;
  line-height: 1.2;
  padding: 1px 2px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tch-preview .tp-loading {
  padding: 18px;
  text-align: center;
  color: var(--color-text-3);
  font-size: 12px;
}
/* 移动端:贴底展示,网格更紧凑 */
@media (max-width: 639px) {
  .tch-preview {
    width: auto;
    left: 8px !important; right: 8px !important; top: auto !important;
    bottom: 8px;
  }
  .tch-preview .tp-th,
  .tch-preview .tp-rh { width: 28px; font-size: 10px; }
  .tch-preview .tp-td { font-size: 11px; padding: 3px 1px; }
}

/* ============================================================
 * 加载/空/错
 * ============================================================ */
.state {
  padding: 36px 16px;
  text-align: center;
  color: var(--color-text-3);
  font-size: 13px;
}
.state .state-icon { font-size: 32px; margin-bottom: 6px; opacity: .5; }

/* ============================================================
 * Toast
 * ============================================================ */
.toast {
  position: fixed; left: 50%; bottom: 60px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.78); color: #fff;
  padding: 9px 16px; border-radius: 20px;
  font-size: 13px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 1000;
  max-width: 80%;
  text-align: center;
}
.toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* ============================================================
 * 响应式
 * ============================================================ */

/* 平板 / 较小桌面 */
@media (min-width: 640px) {
  .login-form { margin: 0 40px; padding: 24px 24px 28px; }
  .tab { font-size: 15px; padding: 12px 0; }
  .sc-cell { font-size: 13px; min-height: 64px; }
  .sc-cell.head { font-size: 13px; }
}

/* 桌面:模拟手机画框 */
@media (min-width: 960px) {
  body { background: #ebedf0; }
  .page {
    max-width: 440px;
    margin: 24px auto;
    min-height: calc(100vh - 48px);
    border-radius: 24px;
    box-shadow: 0 12px 40px rgba(0,0,0,.12);
    overflow: hidden;
    background: var(--color-bg);
  }
  #page-login {
    background: linear-gradient(180deg, #1677ff 0%, #4096ff 35%, #f5f7fa 70%);
  }
  .boot { border-radius: 0; }
}
