/* =========================================================================
   schedule-view.css — единый компонент расписания (Day/Week/Month)
   Использует CSS-переменные темы Kendo (default-ocean-blue) и токены
   из dashboard.css / listview.css. Не дублирует их классы.
   ========================================================================= */

/* ---- Растяжка страницы на всю высоту контентной области ----------------- */
/* main.dashboard-content — flex-колонка (overflow:hidden), страница — её
   прямой потомок. Чтобы расписание заняло всю высоту, тянем flex-цепочку:
   .schedule-page → .cabinet-card → .cabinet-card-body → .schedule-view */
.schedule-page {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.schedule-page > .cabinet-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.schedule-page > .cabinet-card > .cabinet-card-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.schedule-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* ---- Toolbar ----------------------------------------------------------- */
.schedule-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--kendo-color-border, #dee2e6);
  background-color: var(--kendo-color-surface-alt, #f8f9fa);
}

.schedule-view-switcher {
  display: inline-flex;
  border: 1px solid var(--kendo-color-border, #dee2e6);
  border-radius: var(--kendo-border-radius-md, 0.5rem);
  overflow: hidden;
  background-color: var(--kendo-color-surface, #ffffff);
}

.schedule-view-btn {
  border: none;
  background: transparent;
  padding: 0.4rem 0.9rem;
  font-size: 0.875rem;
  color: var(--kendo-color-app-secondary, #6c757d);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.schedule-view-btn:hover {
  background-color: var(--kendo-color-primary-subtle, #e7f1ff);
  color: var(--kendo-color-primary, #0d6efd);
}

.schedule-view-btn.active {
  background-color: var(--kendo-color-primary, #0d6efd);
  color: #fff;
}

.schedule-view-btn.active:hover {
  background-color: var(--kendo-color-primary, #0d6efd);
  color: #fff;
}

.schedule-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.schedule-nav-btn {
  border: 1px solid var(--kendo-color-border, #dee2e6);
  background-color: var(--kendo-color-surface, #ffffff);
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--kendo-color-app-secondary, #6c757d);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.schedule-nav-btn:hover {
  background-color: var(--kendo-color-primary-subtle, #e7f1ff);
  color: var(--kendo-color-primary, #0d6efd);
  border-color: var(--kendo-color-primary, #0d6efd);
}

.schedule-today-btn {
  border: 1px solid var(--kendo-color-border, #dee2e6);
  background-color: var(--kendo-color-surface, #ffffff);
  padding: 0.35rem 0.8rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: var(--kendo-color-app-primary, #212529);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.schedule-today-btn:hover {
  background-color: var(--kendo-color-primary-subtle, #e7f1ff);
  color: var(--kendo-color-primary, #0d6efd);
  border-color: var(--kendo-color-primary, #0d6efd);
}

.schedule-period-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--kendo-color-app-primary, #212529);
  margin-left: 0.5rem;
}

.schedule-loading-spinner {
  margin-left: auto;
  color: var(--kendo-color-primary, #0d6efd);
  font-size: 1.1rem;
}

.spin {
  display: inline-block;
  animation: schedule-spin 1s linear infinite;
}

@keyframes schedule-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---- Легенда (родитель) ----------------------------------------------- */
.schedule-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--kendo-color-border, #dee2e6);
  background-color: var(--kendo-color-surface, #ffffff);
}

.schedule-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--kendo-color-app-primary, #212529);
  cursor: pointer;
  user-select: none;
}

.schedule-legend-item.legend-hidden {
  opacity: 0.5;
}

.schedule-legend-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  border: 1.5px solid var(--kendo-color-border, #adb5bd);
  border-radius: 0.25rem;
  background-color: var(--kendo-color-surface, #ffffff);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.schedule-legend-item input[type="checkbox"]:hover {
  border-color: var(--kendo-color-app-secondary, #6c757d);
}

.schedule-legend-item input[type="checkbox"]:checked {
  background-color: var(--kendo-color-app-secondary, #6c757d);
  border-color: var(--kendo-color-app-secondary, #6c757d);
}

.schedule-legend-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 0.32rem;
  top: 0.12rem;
  width: 0.3rem;
  height: 0.55rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.schedule-legend-marker {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 0.2rem;
  display: inline-block;
  border: 1px solid var(--kendo-color-border, rgba(0,0,0,0.15));
}

.schedule-legend-text {
  font-weight: 500;
}

/* ---- Тело сетки -------------------------------------------------------- */
.schedule-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background-color: var(--kendo-color-surface, #ffffff);
}

/* ---- Month view ------------------------------------------------------- */
.schedule-month {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.schedule-month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--kendo-color-border, #dee2e6);
  background-color: var(--kendo-color-surface-alt, #f8f9fa);
  position: sticky;
  top: 0;
  z-index: 2;
}

.schedule-month-weekdays > div {
  padding: 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--kendo-color-app-secondary, #6c757d);
  border-right: 1px solid var(--kendo-color-border-alt, #e9ecef);
}

.schedule-month-weekdays > div:last-child {
  border-right: none;
}

.schedule-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  flex: 1 1 auto;
  min-height: 0;
}

.schedule-month-day {
  border-right: 1px solid var(--kendo-color-border-alt, #e9ecef);
  border-bottom: 1px solid var(--kendo-color-border-alt, #e9ecef);
  padding: 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-height: 0;
  overflow: hidden;
}

.schedule-month-day.other-month {
  background-color: var(--kendo-color-surface-alt, #f8f9fa);
  color: var(--kendo-color-app-tertiary, #adb5bd);
}

.schedule-month-day.is-today {
  background-color: var(--kendo-color-primary-subtle, #e7f1ff);
}

.schedule-month-dayhead {
  display: flex;
  justify-content: flex-end;
}

.schedule-month-daynum {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--kendo-color-app-secondary, #495057);
  min-width: 1.4rem;
  height: 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.schedule-month-day.is-today .schedule-month-daynum {
  background-color: var(--kendo-color-primary, #0d6efd);
  color: #fff;
}

.schedule-month-events {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 auto;
  min-height: 0;
}

.schedule-event-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  background-color: var(--kendo-color-surface, #ffffff);
  border: 1px solid var(--kendo-color-border, #dee2e6);
  box-shadow: var(--kendo-elevation-1, 0 1px 2px rgba(0,0,0,.05));
  font-size: 0.75rem;
  line-height: 1.2;
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow 0.15s ease;
}

.schedule-event-chip:hover {
  box-shadow: var(--kendo-elevation-1, 0 1px 2px rgba(0,0,0,.1));
}

.schedule-event-chip .schedule-event-time {
  font-weight: 600;
  color: var(--kendo-color-app-primary, #212529);
  flex-shrink: 0;
}

.schedule-event-chip .schedule-event-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--kendo-color-app-secondary, #495057);
}

.schedule-event-chip .schedule-event-tag {
  margin-left: auto;
  flex-shrink: 0;
  padding: 0.05rem 0.3rem;
  border-radius: 0.2rem;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
}

.schedule-event-office {
  font-size: 0.68rem;
  color: var(--kendo-color-app-tertiary, #adb5bd);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.schedule-event-more {
  font-size: 0.7rem;
  color: var(--kendo-color-app-secondary, #6c757d);
  text-align: center;
  padding: 0.1rem;
}

/* Цветовые акценты по статусу (плашки) */
.schedule-event-chip.status-completed { background-color: var(--kendo-color-success-bg, #d4edda); }
.schedule-event-chip.status-postponed { background-color: #dbeafe; }
.schedule-event-chip.status-canceled  { background-color: #fff3e0; }
.schedule-event-chip.status-unclosed  { background-color: #fde8e8; }

/* ---- Week / Day view: временная сетка ---------------------------------- */
.schedule-week-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.schedule-week-heads {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  flex-shrink: 0;
  border-bottom: 1px solid var(--kendo-color-border, #dee2e6);
  background-color: var(--kendo-color-surface-alt, #f8f9fa);
}

.schedule-time-corner {
  border-right: 1px solid var(--kendo-color-border, #dee2e6);
}

.schedule-day-cols-heads {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.schedule-day-cols-heads .schedule-day-head {
  border-bottom: none;
  border-right: 1px solid var(--kendo-color-border-alt, #e9ecef);
}

.schedule-day-cols-heads .schedule-day-head:last-child {
  border-right: none;
}

.schedule-day-cols-heads .schedule-day-head.is-today {
  background-color: var(--kendo-color-primary-subtle, #e7f1ff);
}

/* Скроллируемая область: шкала слева + колонки дней, растянутые на всю высоту */
.schedule-week-scroll {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

/* Шкала времени — flex-column, каждый час равномерно растянут */
.schedule-time-axis {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--kendo-color-border, #dee2e6);
  background-color: var(--kendo-color-surface-alt, #f8f9fa);
  height: 100%;
}

.schedule-day-cols {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-height: 0;
  position: relative;
}

/* Day view — одна колонка */
.schedule-day-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.schedule-day-wrap .schedule-week-heads {
  grid-template-columns: 3.5rem 1fr;
}

.schedule-day-wrap .schedule-day-head {
  border-bottom: none;
}

.schedule-day-wrap .schedule-week-scroll {
  grid-template-columns: 3.5rem 1fr;
}

.schedule-day-corner {
  height: 2.5rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--kendo-color-border, #dee2e6);
}

/* Метка часа — растягивается равномерно (flex:1), выравнивание по верхней границе */
.schedule-hour-label {
  flex: 1 1 0;
  min-height: 2.5rem;
  padding: 0 0.4rem;
  font-size: 0.7rem;
  color: var(--kendo-color-app-secondary, #6c757d);
  text-align: right;
  border-bottom: 1px solid var(--kendo-color-border-alt, #e9ecef);
  position: relative;
}

.schedule-hour-label:last-child {
  border-bottom: none;
}

.schedule-day-col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--kendo-color-border-alt, #e9ecef);
  position: relative;
  min-width: 0;
  height: 100%;
}

.schedule-day-col:last-child {
  border-right: none;
}

.schedule-day-col.is-today .schedule-day-head {
  background-color: var(--kendo-color-primary-subtle, #e7f1ff);
}

.schedule-day-head {
  height: 2.5rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--kendo-color-border, #dee2e6);
  background-color: var(--kendo-color-surface-alt, #f8f9fa);
}

.schedule-day-name {
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--kendo-color-app-secondary, #6c757d);
  letter-spacing: 0.03em;
}

.schedule-day-num {
  font-size: 1rem;
  font-weight: 700;
  color: var(--kendo-color-app-primary, #212529);
}

.schedule-day-col.is-today .schedule-day-num {
  color: var(--kendo-color-primary, #0d6efd);
}

/* Слоты внутри колонки дня — flex-column, каждый слот растянут (flex:1),
   чтобы сетка равномерно заполняла всю высоту */
.schedule-day-slots {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
}

.schedule-hour-slot {
  flex: 1 1 0;
  min-height: 1.5rem;
  border-bottom: 1px solid var(--kendo-color-border-alt, #e9ecef);
}

.schedule-hour-slot:last-child {
  border-bottom: none;
}

.schedule-day-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--kendo-color-app-tertiary, #adb5bd);
  font-size: 0.875rem;
  pointer-events: none;
}

/* ---- Плашка события в Week/Day (absolute) ----------------------------- */
.schedule-event-block {
  position: absolute;
  left: 0.2rem;
  right: 0.2rem;
  border-radius: 0.3rem;
  overflow: hidden;
  cursor: pointer;
  background-color: var(--kendo-color-surface, #ffffff);
  border: 1px solid var(--kendo-color-border, #dee2e6);
  box-shadow: var(--kendo-elevation-1, 0 1px 2px rgba(0,0,0,.05));
  transition: box-shadow 0.15s ease;
  min-height: 1.5rem;
  box-sizing: border-box;
}

.schedule-event-block:hover {
  box-shadow: var(--kendo-elevation-2, 0 2px 6px rgba(0,0,0,.12));
  z-index: 1;
}

.schedule-event-block-inner {
  padding: 0.15rem 0.35rem;
  font-size: 0.72rem;
  line-height: 1.15;
  height: 100%;
  overflow: hidden;
  color: var(--kendo-color-app-primary, #212529);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.schedule-event-block.status-completed { background-color: var(--kendo-color-success-bg, #d4edda); }
.schedule-event-block.status-postponed { background-color: #dbeafe; }
.schedule-event-block.status-canceled  { background-color: #fff3e0; }
.schedule-event-block.status-unclosed  { background-color: #fde8e8; }

/* Строка 1: крупно — название группы */
.schedule-event-block .schedule-event-title {
  font-weight: 700;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* Строка 2: мелко — время + предмет + тег в одну строку */
.schedule-event-line2 {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  overflow: hidden;
  white-space: nowrap;
}

.schedule-event-block .schedule-event-time {
  font-weight: 600;
  font-size: 0.66rem;
  color: var(--kendo-color-app-secondary, #495057);
  flex-shrink: 0;
}

.schedule-event-block .schedule-event-subject {
  font-size: 0.66rem;
  color: var(--kendo-color-app-secondary, #6c757d);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Короткое занятие (< 45 мин) — всё в одну строку */
.schedule-event-block.is-short .schedule-event-block-inner {
  flex-direction: row;
  align-items: baseline;
  gap: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
}

.schedule-event-block.is-short .schedule-event-title {
  flex-shrink: 0;
  max-width: 50%;
}

.schedule-event-block.is-short .schedule-event-line2 {
  flex: 1 1 auto;
  min-width: 0;
}

.schedule-event-block .schedule-event-meta {
  font-size: 0.7rem;
  color: var(--kendo-color-app-secondary, #6c757d);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.schedule-event-block .schedule-event-tag {
  display: inline-block;
  margin-left: auto;
  flex-shrink: 0;
  padding: 0.05rem 0.3rem;
  border-radius: 0.2rem;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 600;
}

/* Day view — расширенная плашка */
.schedule-event-detail {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.schedule-event-detail .schedule-event-title {
  font-size: 0.9rem;
}

.schedule-event-detail .schedule-event-time {
  font-size: 0.78rem;
}

.schedule-event-detail .schedule-event-line2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ---- Week: 7 колонок в одной строке ----------------------------------- */
.schedule-week .schedule-time-grid {
  /* day-col должен занимать оставшееся место, но внутри него 7 колонок */
  grid-template-columns: 3.5rem 1fr;
}

.schedule-week .schedule-day-slots-wrap {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-height: 0;
  overflow: auto;
}

/* Week-специфичная раскладка: 7 колонок дней */
.schedule-week .schedule-day-cols {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-height: 0;
}

/* ---- Адаптивность ----------------------------------------------------- */
@media (max-width: 768px) {
  .schedule-toolbar {
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
  }

  .schedule-period-title {
    width: 100%;
    margin-left: 0;
    order: 5;
  }

  .schedule-month-grid {
    grid-template-rows: repeat(6, minmax(4rem, 1fr));
  }

  .schedule-event-chip {
    font-size: 0.68rem;
  }

  .schedule-event-chip .schedule-event-title {
    display: none;
  }

  .schedule-week .schedule-time-grid {
    grid-template-columns: 2.5rem 1fr;
  }

  .schedule-day-col {
    min-width: 4rem;
  }

  .schedule-day-name {
    font-size: 0.62rem;
  }

  .schedule-day-num {
    font-size: 0.8rem;
  }
}

/* ---- Шапка модалки занятия --------------------------------------------- */
.session-info-header {
  background-color: var(--kendo-color-surface-alt, #f8f9fa);
  border: 1px solid var(--kendo-color-border, #dee2e6);
  border-radius: var(--kendo-border-radius-md, 0.5rem);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.session-info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}

.session-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.session-info-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--kendo-color-app-secondary, #6c757d);
}

.session-info-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--kendo-color-app-primary, #212529);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.session-info-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--kendo-color-border-alt, #e9ecef);
}

.modal-title-text {
  font-weight: 600;
}

/* ---- Карточка ученика в модалке занятия -------------------------------- */
.teacher-students-modal .list-card {
  box-shadow: none;
  border: 1px solid var(--kendo-color-border, #dee2e6);
}

.teacher-students-modal .list-card:hover { box-shadow: none; }

.student-session-card .student-session-status-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  grid-column: 1 / -1;
}

.student-status-label {
  font-weight: 600;
  white-space: nowrap;
  color: var(--kendo-color-app-primary, #212529);
  flex-shrink: 0;
}

.student-session-status-line .student-status-dd {
  flex: 1 1 auto;
  min-width: 0;
}

/* Override Telerik inline width — заставляем dropdown занять всё flex-место */
.student-session-status-line .student-status-dd.k-dropdownlist {
  width: auto !important;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
}

.student-session-status-line .student-status-dd.k-dropdownlist > .k-input-inner,
.student-session-status-line .student-status-dd.k-dropdownlist .k-picker-inner {
  flex: 1 1 auto;
  min-width: 0;
  width: auto !important;
}