/* ==========================================================================
   学生排课工作台 - 高颜值 UI 样式 & 移动端/桌面端自适应适配
   ========================================================================== */

/* ==========================================================================
   0. 手机浏览器视口适配（地址栏 / 刘海屏安全区）
   问题：100vh 在手机浏览器里包含被地址栏遮挡的区域，导致底部导航被挡。
   方案：
   1) body 用 100dvh（动态视口高度，地址栏收放时自动适应）；
   2) 老浏览器不支持 dvh 时回退 100vh（先写 vh 再写 dvh，后者覆盖前者）；
   3) 配合 viewport-fit=cover，用 env(safe-area-inset-*) 给底部导航和
      Toast 预留 iPhone 小白条等安全区，避免内容压到屏幕圆角外。
   ========================================================================== */
html, body {
  /* 兜底：不支持 dvh 的老浏览器 */
  height: 100vh;
  /* 现代浏览器：动态视口高度，地址栏收放自动适应 */
  height: 100dvh;
}

body {
  overflow: hidden; /* 页面级不滚动，内部区域各自滚动 */
}

/* 底部导航栏：上内边距保证按钮间距，下内边距预留安全区（小白条） */
.mobile-bottom-nav {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  /* iPhone 底部安全区；非刘海屏 env() 返回 0，无需担心 */
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
}

/* Toast 通知：底部位置同样避开安全区，否则会被小白条压住 */
.toast-safe-bottom {
  bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
}

/* iOS Safari: 键盘弹出时 100dvh 自动收缩，但要防止 body 被橡皮筋拉动 */
@supports (-webkit-touch-callout: none) {
  body {
    position: fixed;
    inset: 0;
    width: 100%;
  }
}

/* 1. 基础布局与极简滚动条 */
.custom-scrollbar::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: rgba(241, 245, 249, 0.4);
  border-radius: 99px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(203, 213, 225, 0.8);
  border-radius: 99px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 1);
}

/* 移动端 (手机屏幕 < 768px) 学员侧边栏 Overlay 抽屉效果 */
@media (max-width: 767px) {
  #sidebarStudent:not(.hidden) {
    position: fixed !important;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40 !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35) !important;
    width: 280px !important;
  }
}

/* 屏幕较小时的日历保底宽与响应式自适应 */
#calendarHeaderDays,
#calendarGridColumns {
  min-width: 560px;
}

/* 2. 时间刻度轴对齐与样式 */
.time-slot-label {
  height: 64px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin-top: -8px;
  color: #94a3b8;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
}

/* 3. 7天日历列格高度与放置线 */
.calendar-day-column {
  position: relative;
  height: 832px; /* 13 个小时 * 64px = 832px */
  background-size: 100% 64px;
  background-image: linear-gradient(to bottom, transparent 63px, rgba(226, 232, 240, 0.5) 64px);
  transition: background-color 0.15s ease;
}

/* 半点虚线辅助线 */
.calendar-day-column::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  background-size: 100% 32px;
  background-image: linear-gradient(to bottom, transparent 31px, rgba(241, 245, 249, 0.7) 32px);
}

/* 4. 拖拽高亮放置目标区 (Drag Over Zone) */
.calendar-day-column.drag-over {
  background-color: rgba(254, 243, 199, 0.3) !important;
}

.drag-preview-slot {
  position: absolute;
  left: 3px;
  right: 3px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.25), rgba(245, 158, 11, 0.35));
  border: 2px dashed #f59e0b;
  border-radius: 12px;
  pointer-events: none;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #92400e;
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px -2px rgba(245, 158, 11, 0.25);
  transition: all 0.05s ease-out;
}

/* 5. 学生可拖拽卡片样式 (Draggable Student Card) */
.student-card {
  cursor: grab;
  user-select: none;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}
.student-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -3px rgba(245, 158, 11, 0.12), 0 2px 6px -2px rgba(0, 0, 0, 0.04);
  border-color: #fcd34d;
}
.student-card:active {
  cursor: grabbing;
  transform: scale(0.98);
}
.student-card.dragging {
  opacity: 0.35;
  border: 2px dashed #f59e0b;
  box-shadow: none;
}

/* 6. 日历卡片 (Schedule Event Cards) */
.schedule-event-card {
  position: absolute;
  border-radius: 12px;
  padding: 0;
  font-size: 11px;
  line-height: 1.25;
  box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s ease, z-index 0.1s ease, min-height 0.15s ease;
  user-select: none;
  z-index: 10;
  overflow: hidden;
  border-left-width: 4px;
}

.schedule-event-card:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.22), 0 4px 10px -2px rgba(0, 0, 0, 0.1);
  z-index: 50 !important;
  min-height: max-content !important;
  overflow: visible !important;
}

/* 颜色主题高级配色 */
.event-amber {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fde68a;
  border-left-color: #f59e0b;
  color: #78350f;
}
.event-emerald {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border-color: #a7f3d0;
  border-left-color: #10b981;
  color: #064e3b;
}
.event-sky {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-color: #bae6fd;
  border-left-color: #0284c7;
  color: #0c4a6e;
}
.event-purple {
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  border-color: #e9d5ff;
  border-left-color: #9333ea;
  color: #581c87;
}
.event-rose {
  background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);
  border-color: #fecdd3;
  border-left-color: #f43f5e;
  color: #881337;
}

/* 时间冲突样式 (Conflict Warning) */
.schedule-event-card.has-conflict {
  border-right: 3px solid #ef4444;
  animation: pulse-conflict 2.5s infinite;
}

@keyframes pulse-conflict {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.08); }
}

/* 7. Modal 弹窗显示动画 (自动覆盖所有弹窗) */
.modal-box {
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
}

div:not(.hidden) > .modal-box,
div:not(.hidden) .modal-box {
  transform: scale(1) translateY(0) !important;
  opacity: 1 !important;
}

/* 8. 今天日期高亮 */
.today-column-header {
  background: linear-gradient(to bottom, #fffbeb, #fef3c7);
  border-bottom: 3px solid #f59e0b;
}
.today-badge {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  border-radius: 9999px;
  padding: 1px 8px;
  box-shadow: 0 2px 6px -1px rgba(245, 158, 11, 0.4);
}
