/* Страница «Расписание» ученика (static/schedule-ui.js). Цвета берём из переменных темы, тёмная тема работает сама. */
/* Колонка minmax(0, 1fr): без неё широкое содержимое (сетка календаря, строки) раздувает страницу шире экрана. */
.sched { display: grid; grid-template-columns: minmax(0, 1fr); gap: 30px; min-width: 0; }
.sched > * { min-width: 0; }
.sched *, .sched *::before, .sched *::after { box-sizing: border-box; }
.sched-block-title { margin: 0 0 14px; font-size: 18px; font-weight: 800; line-height: 1.3; }

/* Плашки: срок, статус */
.sched-pill {
  display: inline-flex; align-items: center; gap: 6px; width: max-content; max-width: 100%;
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 800; line-height: 1.3; white-space: nowrap;
}
.sched-pill.tone-red { background: var(--coral-soft); color: color-mix(in srgb, var(--coral) 80%, var(--text)); }
.sched-pill.tone-amber { background: var(--amber-soft); color: color-mix(in srgb, var(--amber) 80%, var(--text)); }
.sched-pill.tone-grey { background: var(--surface-2); color: var(--text-soft); }
.sched-pill.tone-green { background: var(--success-soft); color: color-mix(in srgb, var(--success) 70%, var(--text)); }

/* Сейчас в работе */
.sched-now-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 18px; }
.sched-now-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 14px; min-width: 0; padding: 20px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-soft);
}
.sched-now-card.is-overdue { border-color: color-mix(in srgb, var(--coral) 42%, var(--line)); }
.sched-now-head { display: grid; gap: 5px; width: 100%; min-width: 0; }
.sched-eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-soft); overflow-wrap: anywhere; }
.sched-now-title { margin: 0; font-size: 19px; line-height: 1.3; font-weight: 800; overflow-wrap: anywhere; }
.sched-progress { width: 100%; }
.sched-progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.sched-progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .4s ease; }
.sched-now-card.is-done .sched-progress-track span { background: var(--success); }
.sched-progress-label { margin-top: 7px; font-size: 12px; font-weight: 700; color: var(--text-soft); }
.sched-now-foot { display: grid; gap: 12px; width: 100%; margin-top: auto; }
.sched-continue { width: 100%; min-width: 0; height: auto; padding-top: 9px; padding-bottom: 9px; }
.sched-continue svg { flex: 0 0 18px; }
/* название урока переносится максимум на две строки, длиннее обрезается многоточием */
.sched-btn-text {
  display: -webkit-box; min-width: 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  line-height: 1.35; text-align: center; overflow-wrap: anywhere;
}
.sched-now-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 12px; }
.sched-note { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; line-height: 1.4; color: var(--text-soft); }
.sched-note svg { flex: 0 0 17px; width: 17px; height: 17px; }
.sched-note.is-ok { color: color-mix(in srgb, var(--success) 75%, var(--text)); }

/* Календарь месяца: карточка с сеткой слева, лента справа (на узком экране друг под другом) */
.sched { --sched-slate: color-mix(in srgb, var(--cyan) 62%, var(--text-soft)); }
.sched-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 30px; align-items: start; }
.sched-cal {
  width: 100%; max-width: 580px; min-width: 0; padding: 18px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-soft);
}
/* Заголовок: название слева, «Текущий месяц» и стрелки справа, подпись строкой ниже на всю ширину */
.sched-cal-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; margin-bottom: 14px;
  grid-template-areas: "title slot prev next" "caption caption caption caption";
}
.sched-cal-title { grid-area: title; margin: 0; font-size: 21px; font-weight: 800; line-height: 1.25; }
.sched-cal-caption { grid-area: caption; margin: 3px 0 0; font-size: 12px; line-height: 1.45; color: var(--text-soft); }
.sched-cal-slot { grid-area: slot; align-self: start; justify-self: end; }
.sched-cal-current {
  height: 36px; margin: 0 4px 0 0; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--primary);
  font: inherit; font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer; transition: background-color .18s ease;
}
.sched-cal-current:hover { background: var(--primary-soft); }
.sched-cal-arrow {
  align-self: start; display: grid; place-items: center; width: 36px; height: 36px; margin: 0 0 0 6px; padding: 0;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.sched-cal-arrow.is-prev { grid-area: prev; }
.sched-cal-arrow.is-next { grid-area: next; }
.sched-cal-arrow:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.sched-cal-arrow svg { width: 18px; height: 18px; }
/* Сетка: заголовок дней недели и 6 недель по 7 клеток, неделя начинается с понедельника */
.sched-cal-weekdays, .sched-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.sched-cal-weekdays { margin-bottom: 4px; }
.sched-cal-weekdays span { padding: 4px 0; text-align: center; font-size: 11px; font-weight: 800; letter-spacing: .05em; color: var(--text-soft); }
.sched-cal-weekdays .is-weekend { color: color-mix(in srgb, var(--coral) 85%, var(--text)); }
.sched-cal-day {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; aspect-ratio: 1 / 1; margin: 0; padding: 2px;
  border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--text); font: inherit; text-align: center; cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.sched-cal-day:hover { background: var(--surface-2); }
.sched-cal-day.is-selected { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.sched-cal-num {
  display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 3px; border-radius: 999px;
  font-size: 15px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
/* Место под подпись месяца занято в каждой клетке, чтобы числа стояли ровно; текст есть только у 1-го числа */
.sched-cal-mon { height: 10px; margin-top: 1px; font-size: 9px; font-weight: 800; line-height: 10px; white-space: nowrap; color: var(--text-soft); }
.sched-cal-day.is-out .sched-cal-num { color: var(--text-soft); opacity: .65; }
.sched-cal-day.is-out .sched-cal-mon { opacity: .75; }
.sched-cal-day.is-today .sched-cal-num { background: var(--primary); color: #fff; opacity: 1; }
[data-theme="dark"] .sched-cal-day.is-today .sched-cal-num { background: color-mix(in srgb, var(--primary) 70%, var(--bg)); }
/* Место под точки тоже занято в каждой клетке: содержимое клеток одинаковое, числа стоят ровно */
.sched-cal-dots { display: flex; justify-content: center; align-items: center; gap: 3px; height: 5px; margin-top: 3px; }
.sched-cal-dots i { display: block; flex: 0 0 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); }
.sched-cal-dots.tone-red i { background: var(--coral); }
.sched-cal-dots.tone-slate i { background: var(--sched-slate); }
.sched-cal-day.is-out .sched-cal-dots { opacity: .65; }
/* Под календарём: короткая подсказка (место под неё занято, чтобы страница не прыгала) и легенда цветов */
.sched-cal-foot { display: grid; gap: 6px; margin-top: 10px; padding: 0 2px; }
.sched-cal-hint { min-height: 20px; margin: 0; font-size: 13px; font-weight: 700; line-height: 20px; color: var(--text-soft); }
.sched-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--text-soft); }
.sched-legend li { display: inline-flex; align-items: center; gap: 6px; }
.sched-dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; }
.sched-dot.tone-red { background: var(--coral); }
.sched-dot.tone-purple { background: var(--primary); }
.sched-dot.tone-slate { background: var(--sched-slate); }

/* Лента по дням */
.sched-agenda { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.sched-group { min-width: 0; scroll-margin-top: 96px; }
.sched-group-title { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 15px; font-weight: 800; line-height: 1.4; }
.sched-group.is-overdue .sched-group-title { color: color-mix(in srgb, var(--coral) 80%, var(--text)); }
.sched-count {
  min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--coral-soft);
  color: color-mix(in srgb, var(--coral) 80%, var(--text)); font-size: 12px; font-weight: 800; text-align: center;
}
.sched-rows { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-soft); }
.sched-group.is-overdue .sched-rows { border-color: color-mix(in srgb, var(--coral) 38%, var(--line)); }
.sched-row {
  display: flex; align-items: center; gap: 14px; width: 100%; min-width: 0; margin: 0; padding: 14px 16px;
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: inherit; font: inherit; text-align: left;
}
.sched-row:last-child { border-bottom: 0; }
button.sched-row { cursor: pointer; transition: background-color .18s ease; }
button.sched-row:hover { background: var(--surface-2); }
.sched-row > svg { flex: 0 0 18px; width: 18px; height: 18px; color: var(--text-soft); }
.sched-row-icon {
  display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary);
}
.sched-row-icon svg { width: 20px; height: 20px; }
.sched-row.t-overdue .sched-row-icon, .sched-row.t-deadline .sched-row-icon { background: var(--coral-soft); color: color-mix(in srgb, var(--coral) 85%, var(--text)); }
.sched-row.t-task .sched-row-icon { background: var(--amber-soft); color: color-mix(in srgb, var(--amber) 85%, var(--text)); }
.sched-row.t-event .sched-row-icon { background: var(--cyan-soft); color: var(--cyan); }
.sched-row.t-module_open .sched-row-icon, .sched-row.t-course_start .sched-row-icon, .sched-row.t-course_end .sched-row-icon { background: var(--surface-2); color: var(--text-soft); }
.sched-row.is-done .sched-row-icon { background: var(--success-soft); color: color-mix(in srgb, var(--success) 75%, var(--text)); }
.sched-row.is-done .sched-row-main strong { color: var(--text-soft); }
.sched-row-main { display: grid; gap: 3px; flex: 1 1 auto; min-width: 0; }
.sched-row-main strong { font-size: 14px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.sched-row-main small { font-size: 12px; line-height: 1.4; color: var(--text-soft); overflow-wrap: anywhere; }
.sched-row-side { display: flex; align-items: center; justify-content: flex-end; flex: 0 0 auto; gap: 10px; }
.sched-time { font-size: 15px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sched-time small { margin-left: 4px; font-size: 10px; font-weight: 800; color: var(--text-soft); }
.sched-side-note { font-size: 12px; font-weight: 700; white-space: nowrap; color: var(--text-soft); }
@keyframes sched-flash {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 38%, transparent); }
  100% { box-shadow: 0 0 0 14px transparent; }
}
.sched-group.is-flash .sched-rows { animation: sched-flash 1.2s ease-out; }

/* Пустое состояние */
.sched-empty {
  padding: 48px 20px; border: 1px dashed var(--line); border-radius: 18px; background: var(--surface);
  color: var(--text-soft); text-align: center;
}
.sched-empty-icon { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.sched-empty-icon svg { width: 26px; height: 26px; }
.sched-empty h3 { margin: 0 0 6px; color: var(--text); }
.sched-empty p { max-width: 440px; margin: 0 auto; line-height: 1.55; }
.sched-empty.compact { padding: 16px 18px; text-align: left; }
.sched-empty.compact p { max-width: none; margin: 0; }
.sched-empty.compact strong { color: var(--text); }

/* Широкий экран: календарь слева, лента справа. На достаточно высоком экране календарь остаётся на виду, пока листается лента */
@media (min-width: 1000px) {
  .sched-split { grid-template-columns: minmax(440px, min(500px, 44%)) minmax(0, 1fr); gap: 28px; }
  .sched-cal { max-width: none; }
}
@media (min-width: 1000px) and (min-height: 760px) {
  .sched-cal { position: sticky; top: 96px; }
}

/* Телефон: одна колонка, клетка календаря не ниже 44px, строки лентой */
@media (max-width: 720px) {
  .sched { gap: 24px; }
  .sched-split { gap: 24px; }
  .sched-now-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .sched-now-card { padding: 18px; }
  .sched-cal { padding: 14px 10px; }
  .sched-cal-title { font-size: 18px; }
  .sched-cal-weekdays, .sched-cal-grid { gap: 2px; }
  .sched-cal-day { aspect-ratio: auto; min-height: 44px; padding: 2px 0; border-radius: 10px; }
  .sched-cal-num { min-width: 24px; height: 24px; font-size: 14px; }
}
@media (max-width: 480px) {
  .sched-cal-title { font-size: 17px; white-space: nowrap; }
  .sched-cal-current { padding: 0 6px; font-size: 12px; }
}
/* Узкий телефон: название и «Текущий месяц» в одну строку со стрелками уже не помещаются, ссылка уходит отдельной строкой ниже подписи, стрелки стоят на месте */
@media (max-width: 400px) {
  .sched-cal-head { grid-template-areas: "title prev next" "caption caption caption" "slot slot slot"; }
  .sched-cal-current { margin: 2px -6px 0 0; }
}
@media (max-width: 600px) {
  .sched-row {
    display: grid; grid-template-columns: 38px minmax(0, 1fr) 18px; grid-template-areas: "icon main chev" "icon side chev";
    align-items: start; column-gap: 12px; row-gap: 6px; padding: 13px 14px;
  }
  .sched-row-icon { grid-area: icon; width: 38px; height: 38px; flex-basis: auto; }
  .sched-row-main { grid-area: main; }
  .sched-row-side { grid-area: side; justify-content: flex-start; flex-wrap: wrap; }
  .sched-row-side:empty { display: none; }
  .sched-row > svg { grid-area: chev; align-self: center; }
  .sched-legend { gap: 4px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .sched-group.is-flash .sched-rows { animation: none; }
  .sched-progress-track span, .sched-cal-day, .sched-cal-arrow, .sched-cal-current, button.sched-row { transition: none; }
}
