@import url('./shift-constructor.css');

/*
 * MY WORK — ГРАФИК СМЕН
 * Локальные стили модуля. Кнопки, поля и общая
 * закреплённая шапка берутся из дизайн-системы.
 */

/* Расположение заголовка и управляющих кнопок */
.shift-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

/* Описание под заголовком */
.shift-header-info p {
  margin: 8px 0 0;
  color: var(--text-muted);
}

/* Кнопки создания и очистки графика */
.shift-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Панель навигации по неделям */
.shift-navigation {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

/* Текущий отображаемый период */
.shift-period {
  font-weight: var(--weight-heading);
}

/* Стрелки переключения недель */
/* Переключатель недель — единый блок со скруглением по краям */
.shift-navigation-buttons {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 28px;
  overflow: hidden;
  flex-shrink: 0;
}

/* Кнопки внутри переключателя */
.shift-navigation-buttons .comp-btn {
  min-width: 72px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* Разделитель между кнопками */
.shift-navigation-buttons .comp-btn + .comp-btn {
  border-left: 1px solid var(--border);
}

/* Скругление крайних кнопок */
.shift-navigation-buttons .comp-btn:first-child {
  border-top-left-radius: 28px;
  border-bottom-left-radius: 28px;
}

.shift-navigation-buttons .comp-btn:last-child {
  border-top-right-radius: 28px;
  border-bottom-right-radius: 28px;
}
/* Фильтр сотрудников справа от навигации */
/* MY WORK — Сохранённые отпуска и больничные сотрудников. */
.shift-absence {
  padding: 10px 8px;
  border: 1px solid #f4b266;
  border-radius: 9px;
  background: #f4b266;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.shift-absence[data-type='sick'] {
  border-color: #ee7c7c;
  background: #ee7c7c;
  color: #ffffff;
}

/* Поиск сотрудников в панели фильтров. */
.shift-search {
  width: 220px;
  max-width: 100%;
  margin-left: auto;
  flex: 0 1 220px;
}

.shift-filter {
  position: relative;
}

/* Выпадающее меню фильтра */
/* Текст и стандартная стрелка внутри кнопки фильтра */
#shift-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/*
 * Стандартная Arrow.svg направлена вниз при закрытом меню.
 * При раскрытии поворачиваем ту же иконку вверх.
 */
#shift-filter-toggle .mywork-arrow {
  transition: transform var(--motion-fast) ease;
}

#shift-filter-toggle[aria-expanded='true'] .mywork-arrow {
  transform: rotate(270deg);
}

.shift-filter-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  width: 210px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--select-radius);
  background: var(--background);
  box-shadow: var(--select-shadow);
}

.shift-filter-menu[hidden] {
  display: none;
}

/* Варианты фильтрации */
.shift-filter-menu button {
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.shift-filter-menu button:hover,
.shift-filter-menu button[aria-pressed='true'] {
  background: var(--hover);
}

.shift-filter-menu button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ==========================================================
   MY WORK — ПЕРЕКЛЮЧАТЕЛЬ НЕДЕЛЬ
   Единая группа кнопок с разделителем
   ========================================================== */

/* Общий контейнер двух стрелок */
.shift-week-switch {
  display: inline-flex;
  align-items: stretch;
  flex-shrink: 0;
  overflow: hidden;

  border: 1px solid var(--border);

  background: var(--background);

  border-radius: 14px;
  overflow: hidden;
}

/* Кнопки предыдущей и следующей недели */
.shift-week-switch__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 44px;
  height: 42px;
  padding: 0;

  border: 0;
  background: transparent;
  color: var(--text);

  font: inherit;
  font-size: 27px;
  line-height: 1;

  cursor: pointer;
  transition: background-color 0.2s ease;
}

/* Разделитель между кнопками */
.shift-week-switch__button + .shift-week-switch__button {
  border-left: 1px solid var(--border);
}

/* Подсветка при наведении */
.shift-week-switch__button:hover {
  background: var(--hover);
}

/* Видимый фокус при управлении клавиатурой */
.shift-week-switch__button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Компактный переключатель для мобильных устройств */
@media (max-width: 768px) {
  .shift-week-switch__button {
    width: 40px;
    height: 40px;
    font-size: 25px;
  }
}

/* Внешняя область графика с горизонтальной прокруткой */
.shift-table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: transparent;
}

/* Сетка таблицы */
.shift-table {
  width: 100%;
  min-width: 960px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

/* Ячейки графика */
.shift-table th,
.shift-table td {
  height: 64px;
  padding: 12px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.shift-table tr > :last-child {
  border-right: none;
}

.shift-table tbody tr:last-child td {
  border-bottom: none;
}

/* Компактная шапка графика. */
.shift-table thead th {
  height: 48px;
  padding: 4px;
}

/* Колонка поиска и сотрудников */
/* Заголовок колонки сотрудников. */
.shift-table thead .shift-employee-heading {
  width: 220px;
  padding-left: 12px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

/* Дни недели */
.shift-day-heading {
  text-align: center;
  font-weight: 400;
}

/* Число даты над названием дня недели */
.shift-day-date {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
  font-size: 14px;
  color: var(--text);
  font-weight: 400;
}

/* Число даты в заголовке графика. */
.shift-day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
}

/* Название дня недели под числом даты. */
.shift-day-weekday {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1;
}

/* Сегодняшний день выделяем только вокруг числа даты. */
.shift-day-heading.is-today .shift-day-number {
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

/* Содержимое первой колонки сотрудника */
.shift-employee {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* Аватар с инициалами */
.shift-employee-avatar {
  display: inline-flex;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--hover);
  color: var(--text);
  font-weight: var(--weight-heading);
}

/* Фотография сотрудника внутри круглого аватара */
.shift-employee-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

/* Имя и должность сотрудника */
.shift-employee-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.shift-employee-info strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shift-employee-info span {
  color: var(--text-muted);
  font-size: var(--font-small);
}

/* Ячейки с назначенными сменами */
.shift-day-cell {
  position: relative;
  vertical-align: top !important;
}

/* Карточка смены одинакова в светлой и тёмной темах. */
.shift-assignment {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  height: 34px;
  min-height: 34px;
  margin: 0 0 5px;
  padding: 0 8px;
  border: 0;
  border-radius: 10px;
  background: #4a97e8;
  color: #ffffff;
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: box-shadow 160ms ease;
}

/* Одиночная карточка остаётся по центру ячейки и не растягивается. */
.shift-day-cell > .shift-assignment:only-child {
  position: absolute;
  top: 50%;
  right: 12px;
  left: 12px;
  width: auto;
  margin: 0;
  transform: translateY(-50%);
}

/* Время смены — единственное содержимое карточки. */
.shift-assignment-time {
  color: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .shift-assignment {
    transition: none;
  }
}

/* Стажировка использует сиреневый оттенок в обеих темах. */
.shift-assignment[data-shift-type='internship'] {
  background: #a98bff;
}

/* Скрытие сотрудников при поиске */
.shift-table tbody tr[hidden] {
  display: none;
}

/* Пустая ячейка не интерактивна в режиме просмотра. */
.shift-day-cell--editable {
  position: relative;
}

/* Кнопка добавления доступна только при редактировании графика. */
.shift-day-add {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 25px;
  font-weight: 400;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--motion-fast) ease;
}

.shift-constructor-active .shift-day-add {
  display: flex;
}

.shift-constructor-active .shift-day-add:hover,
.shift-constructor-active .shift-day-add:focus-visible {
  opacity: 1;
}

.shift-day-add:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

@media (hover: none) {
  .shift-constructor-active .shift-day-add {
    opacity: 1;
  }
}

/* Контур фокуса карточки смены */
.shift-assignment:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Содержимое окна просмотра смены */
.shift-details-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 24px;
}

/* Действия под информацией о смене */
.shift-details-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Скрытые поля не занимают место в форме редактирования. */
.shift-form-field[hidden],
.shift-form-notice[hidden] {
  display: none;
}

/* Строка информации о смене */
.shift-detail-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shift-detail-row > span {
  color: var(--text-muted);
  font-size: var(--font-small);
}

.shift-detail-row > strong {
  font-weight: var(--weight-medium);
}

/* Пустое состояние графика */
.shift-empty {
  height: 180px !important;
  text-align: center;
  color: var(--text-muted);
}

/* Адаптация элементов управления на телефонах */
@media (max-width: 768px) {
  .shift-header {
    align-items: flex-start;
  }

  .shift-header-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}

/* ==========================================================
   ФОРМА СОЗДАНИЯ СМЕНЫ
   ========================================================== */

/* Модальное окно поверх рабочего пространства */
.shift-dialog {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--modal-radius);
  background: var(--background);
  color: var(--text);
  box-shadow: var(--select-shadow);
  overflow-y: auto;
}

/* Затемнение страницы под формой */
.shift-dialog::backdrop {
  background: rgb(0 0 0 / 55%);
}

/* Вертикальное расположение элементов формы */
.shift-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Заголовок и кнопка закрытия */
.shift-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.shift-form-header h2 {
  margin: 0;
}

/* Поле с подписью */
.shift-form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Время начала и окончания в две колонки */
.shift-form-times {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* Подсказка о ночных сменах */
.shift-form-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--font-small);
}

/* Предупреждение о публикации */
.shift-form-notice {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--font-small);
}

/* Ошибки проверки и сохранения */
.shift-form-error {
  margin: 0;
  color: var(--input-error-color);
  font-size: var(--font-small);
}

.shift-form-error[hidden] {
  display: none;
}

/* Кнопки в нижней части формы */
.shift-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* MY WORK — Модальное окно массовой очистки календаря. */
.shift-clear-dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.shift-clear-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.shift-clear-description {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.shift-clear-period {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
}

.shift-clear-period .comp-picker {
  width: 100%;
}

.shift-clear-period .comp-picker-trigger {
  width: 100%;
}

.shift-clear-employees-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.shift-clear-select-all,
.shift-clear-employee {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.shift-clear-select-all {
  font-size: 12px;
  font-weight: 400;
}

.shift-clear-employees {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 190px;
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13px;
}

.shift-clear-preview {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.shift-clear-preview-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 13px;
}

.shift-clear-preview-total {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-weight: 600;
  font-size: 13px;
}

.shift-clear-error {
  margin: 0;
  color: #d64545;
  font-size: 12px;
}

.shift-clear-error:empty {
  display: none;
}

.shift-clear-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
