/* 小屏/笔记本自适应：盖在 p0-schedule-dense 之上
 * - 宽屏仍用密铺桌面课表
 * - 中等宽度：侧栏变窄 + 课表保底列宽、可横向滚动（不再硬挤扁）
 * - ≤1100：侧栏改抽屉
 * - ≤720：恢复手机课表（覆盖 dense 的 display:none）
 */

/* —— 1366 及以下：别把 7 列硬挤进窄主区 —— */
@media (max-width: 1366px) {
  :root {
    --sidebar-width: 212px;
  }

  #teacher-app #panel-schedule .timetable-wrap,
  #panel-schedule #timetableContainer.timetable-wrap {
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  #teacher-app #panel-schedule .timetable {
    width: max(100%, 980px) !important;
    min-width: 980px !important;
    table-layout: fixed !important;
  }

  #teacher-app #panel-schedule .timetable th:not(.period),
  #teacher-app #panel-schedule .timetable td.lesson-cell {
    min-width: 112px !important;
  }

  #teacher-app #panel-schedule .timetable .period,
  #teacher-app #panel-schedule .timetable td.period,
  #teacher-app #panel-schedule .timetable th.period,
  #teacher-app #panel-schedule .timetable thead th:first-child {
    width: 92px !important;
    min-width: 92px !important;
    max-width: 100px !important;
  }

  #panel-schedule .schedule-toolbar {
    row-gap: 8px !important;
  }

  #panel-schedule .schedule-legend {
    flex-wrap: wrap !important;
  }
}

/* —— 1200：再收一点侧栏与工具条 —— */
@media (max-width: 1200px) {
  :root {
    --sidebar-width: 196px;
  }

  #teacher-app .sidebar .nav-btn {
    padding-left: 10px !important;
    padding-right: 8px !important;
    gap: 8px !important;
  }

  #teacher-app .sidebar .tp-nav-label {
    font-size: 0.86rem !important;
  }

  #panel-schedule .page-title {
    font-size: 1.05rem !important;
  }

  #panel-schedule .schedule-toolbar .btn,
  #panel-schedule .schedule-toolbar .tt-mode-tabs__btn {
    font-size: 0.74rem !important;
    padding: 3px 8px !important;
  }
}

/* —— 1100：侧栏改抽屉，把宽度让给课表（原断点 900 偏晚） —— */
@media (max-width: 1100px) {
  #teacher-app .app-body {
    flex-direction: column !important;
  }

  #teacher-app .sidebar {
    display: none !important;
    flex: none !important;
    width: auto !important;
  }

  #teacher-app .sidebar.is-open {
    display: block !important;
    position: fixed !important;
    left: 0 !important;
    top: var(--topbar-offset, 56px) !important;
    bottom: 0 !important;
    width: min(280px, 88vw) !important;
    z-index: 150 !important;
    background: var(--glass-strong, rgba(255, 255, 255, 0.96)) !important;
    padding: 16px !important;
    overflow-y: auto !important;
    box-shadow: 8px 0 24px rgba(15, 23, 42, 0.12);
  }

  #teacher-app .main {
    flex: 1 !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  #teacher-app .menu-mobile,
  .menu-mobile {
    display: inline-flex !important;
  }

  #teacher-app #panel-schedule .timetable {
    width: max(100%, 860px) !important;
    min-width: 860px !important;
  }
}

/* —— 手机宽：必须用移动课表，不能被 dense 的 display:none 盖掉 —— */
@media (max-width: 720px) {
  #teacher-app:has(#panel-schedule.active) .main {
    overflow: auto !important;
    padding: 8px 10px 16px !important;
  }

  #panel-schedule .tp-mobile-schedule {
    display: block !important;
  }

  #teacher-app #panel-schedule .timetable-wrap,
  #panel-schedule #timetableContainer.timetable-wrap,
  #panel-schedule .schedule-evening-footer {
    display: none !important;
  }

  #panel-schedule .schedule-board-card {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
  }

  #panel-schedule .schedule-legend {
    display: none !important;
  }
}
