@import url('base.css');

/* Общие стили */

body {
  position: relative;
  font-family: Arial, sans-serif;
  background-color: #5655558d;
  overflow-x: auto;
  /* Предотвращаем автоматический зум на мобильных */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Предотвращаем pull-to-refresh */
  overscroll-behavior-y: none;
}

body::before {
  content: "";
  position: fixed;
  /* фиксируем, чтобы покрыть весь экран */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('../images/avicenaImage2.png');
  background-size: cover;
  background-position: center;
  /* прозрачность фонового изображения */
  z-index: -1;
  /* помещаем позади основного контента */
}

header {
  background-color: #0c4601;
  color: #fff;
  padding: 12px 0;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
  box-shadow: 10px 12px 14px rgba(0.30, 0.30, 0.30, 0.30);
  opacity: 0.98;
  margin-top: 60px;
}

.page-header {
  margin: 8px 70px 8px 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  flex-wrap: wrap;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(22px, 2.6vw, 34px);
  text-shadow: #000000 0.1em 0.1em 0.2em;
}

.legend-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 12px;
}

@media (max-width: 768px) {
  .page-header {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    gap: 16px;
  }

  .legend-control {
    width: auto;
    justify-content: center;
    margin-left: 8px;
  }
}


/* Контейнер календаря */
.calendar {
  width: 90%;
  max-width: 1700px;
  min-width: 800px;
  min-height: 800px;
  /* Увеличиваем высоту для квадратных ячеек */
  height: auto;
  /* Автоматическая высота для заполнения содержимым */
  background: rgb(242, 242, 242);
  border-radius: 10px;
  box-shadow: 10px 14px 18px rgba(0.20, 0.20, 0.20, 0.20);
  margin: 180px auto 0 auto;
  padding: 20px;
  transition: transform 0.3s ease, opacity 0.3s ease;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.calendar.slide-out-left {
  transform: translateX(-100%);
  opacity: 1;
}

.calendar.slide-in-right {
  transform: translateX(100%);
  opacity: 1;
}

.calendar.slide-out-right {
  transform: translateX(100%);
  opacity: 1;
}

.calendar.slide-in-left {
  transform: translateX(-100%);
  opacity: 1;
}

.calendar.active {
  transform: translateX(0);
  opacity: 1;
}

/* Стили для операций */
.operation-names,
.day .operation-names {
  /* ВОССТАНОВЛЕНО ДЛЯ ДЕСКТОПА */
  font-size: 18px;
  color: #000000;
  margin: 5px 4px 0 4px !important;
  /* добавили боковые отступы с !important */
  padding: 8px 12px;
  white-space: normal;
  text-align: left;
  text-indent: 0;
  padding-left: 2.5em;
  border-radius: 5px;
  display: block !important;
  word-break: break-word;

  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  background: #fff;
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  transform-origin: center center;
  border: #2b2a2a42 solid 1px;
  line-height: 1.15;
  /* чуть более свободно на десктопе */
}

.operation-names:hover {
  transform: scale(1.1);
  /* Увеличиваем на 10% при наведении */
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  /* Усиленная тень при наведении */
  z-index: 10000;
  /* Поверх других элементов */
}

/* ...existing code until the smaller nested .day .operation-names definition... */
.day .operation-names {
  /* ВОССТАНОВЛЕНО ДЛЯ ДЕСКТОПА */
  font-size: clamp(8px, 0.7vw, 12px);

  max-width: 100%;
  overflow: visible;
  line-height: 1.1;
  padding: 3px 6px;
  /* Увеличили боковые отступы */
  margin: 4px 4px 0 4px !important;
  /* добавили боковые отступы с !important */
  white-space: pre-line;
  text-align: left;
  text-indent: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  background: #fff;
  border-radius: 5px;
  box-sizing: border-box;
  display: block !important;
  /* принудительно блочный элемент */
}

.operation-names.operation-hidden,
.day .operation-names.operation-hidden {
  display: none !important;
}

.operations-placeholder {
  display: block;
}

.operations-toggle {
  margin: 6px 4px 4px 4px;
  width: calc(100% - 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(59, 161, 201, 0.12);
  border: 1px solid rgba(59, 161, 201, 0.35);
  border-radius: 6px;
  color: #0b4e68;
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  text-transform: none;
}

.operations-toggle:hover {
  background: rgba(59, 161, 201, 0.22);
  border-color: rgba(59, 161, 201, 0.55);
  color: #05364c;
}

.operations-toggle:focus-visible {
  outline: 2px solid rgba(59, 161, 201, 0.8);
  outline-offset: 2px;
}

.operations-toggle:active {
  transform: translateY(1px);
}

.operations-toggle-arrow {
  display: inline-flex;
  transition: transform 0.2s ease;
  font-size: 0.9em;
}

.operations-toggle-arrow.expanded {
  transform: rotate(180deg);
}

.operations-toggle--expanded {
  background: rgba(59, 161, 201, 0.18);
  border-color: rgba(59, 161, 201, 0.6);
  color: #043d50;
}

.operations-toggle--expanded:hover {
  background: rgba(59, 161, 201, 0.28);
}

.operations-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(100% + 12px);
  margin-left: -6px;
  padding: 10px 8px 12px;
  background: linear-gradient(to bottom, #ffffff, #f7fbff);
  border: 1px solid rgba(59, 161, 201, 0.35);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  border-radius: 10px;
  z-index: 60;
  max-height: 80vh;
  overflow-y: auto;
  display: none;
}

.operations-overlay::-webkit-scrollbar {
  width: 8px;
}

.operations-overlay::-webkit-scrollbar-thumb {
  background: rgba(59, 161, 201, 0.4);
  border-radius: 4px;
}

.day.operations-expanded-overlay {
  z-index: 100;
}

.day.operations-expanded-overlay .operations-overlay {
  display: block;
}

.day.operations-expanded-overlay .operations-toggle {
  position: relative;
  z-index: 120;
}

/* === Мобильные стили === */
@media (max-width: 768px) {

  /* Полностью нативная прокрутка без вмешательства */
  html {
    -webkit-overflow-scrolling: touch;
  }

  body {
    -webkit-overflow-scrolling: touch;
  }

  .calendar {
    width: 1400px !important;
    min-width: 1400px !important;
    max-width: 1400px !important;
    margin: 160px auto 40px !important;
    padding: 20px !important;
    /* Убираем внутреннюю прокрутку - возвращаем прокрутку всей страницы */
    -webkit-overflow-scrolling: touch;
    /* Добавляем минимальную высоту для стабилизации */
    min-height: calc(100vh - 200px);
  }

  .days {
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 2px !important;
  }

  .calendar .header {
    padding: 16px 12px !important;
    gap: 10px !important;
    border-radius: 8px !important;
  }

  .calendar .header h1 {
    font-size: 18px !important;
  }

  .calendar .header button {
    width: 34px !important;
    height: 34px !important;
    margin: 0 4px !important;
    font-size: 20px !important;
  }

  .day {
    min-height: 70px !important;
    height: auto !important;
    font-size: 6px !important;
    /* Увеличиваем размер текста дня */
  }

  /* Увеличиваем размер дней недели в заголовке календаря */
  .weekdays div {
    font-size: 16px !important;
  }

  /* Увеличиваем номер дня и название дня недели */
  .day-number {
    font-size: 20px !important;
    font-weight: bold !important;
  }

  .day-name {
    font-size: 22px !important;
  }

  .day-reservation-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
  }

  .day-reservation-toggle {
    width: 28px;
    height: 28px;
  }

  .day-reservation-toggle .shield-icon {
    width: 18px;
    height: 18px;
  }

  .shield-icon.shield-black {
    color: #000000;
  }

  /* Увеличиваем размер текста дежурных врачей */
  .anesthesiologist-info,
  .duty-doctor-info {
    font-size: 12px !important;
    line-height: 1.3 !important;
  }

  .operation-names,
  .day .operation-names {
    font-size: 16px !important;
    padding: 8px 12px !important;
    padding-left: 2.5em !important;
    line-height: 1.15 !important;
    margin: 4px 4px 0 4px !important;
  }

  .day .operation-names {
    font-size: clamp(12px, 0.7vw, 12px) !important;
    padding: 3px 3px !important;
    margin: 4px 4px 0 4px !important;
    line-height: 1.1 !important;
  }

  .header {
    align-items: stretch;
    gap: 12px;
  }

  .header-left,
  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .header h1 {
    font-size: 22px !important;
    text-align: center;
  }

  .legend-dropdown {
    position: static;
    width: 100%;
    max-height: none;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
  }
}

@media (max-width: 480px) {

  .operation-names,
  .day .operation-names {
    font-size: 11px !important;
    padding: 2px 3px !important;
    margin: 2px 2px 0 2px !important;
  }

  .day {
    min-height: 100px !important;
    font-size: 16px !important;
    /* Немного меньше для очень маленьких экранов */
  }

  /* Размеры текста для очень маленьких экранов */
  .weekdays div {
    font-size: 14px !important;
  }

  .day-number {
    font-size: 18px !important;
    font-weight: normal !important;
  }

  .day-name {
    font-size: 12px !important;
  }

  .anesthesiologist-info,
  .duty-doctor-info {
    font-size: 11px !important;
  }

  .day-back {
    margin-top: 2px !important;
    font-size: 18px !important;
  }
}

/* ...existing code after mobile overrides... */
.anesthesiologist-info {
  border: #b8b8b8 solid 1px;
  border-radius: 0;
  /* Убираем скругления для точного прилегания */
  margin: 0;
  /* Убираем все отступы */
  /* border-right: rgb(72, 219, 195) solid 4px; */
}

.duty-doctor-info {
  border: #b8b8b8 solid 1px;
  border-bottom-left-radius: 5px;
  /* Оставляем только нижние скругления */
  border-bottom-right-radius: 5px;
  /* Оставляем только нижние скругления */
  margin: 0;
  /* Убираем все отступы */
  /* border-right: rgb(192, 69, 69) solid 4px; */
}

/* Убираем все CSS правила для отступов - управляем только через JavaScript */

.operation-names:hover {
  transform: scale(1.1);
  /* Увеличиваем на 5% */
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  /* Усиленная тень при наведении */
  z-index: 100000;
  /* Поверх других элементов */
}

.operation-names br,
.day .operation-names br {
  display: block;
  content: "";
  margin-bottom: 0;
}

/* Заголовок месяца */
.header {
  position: relative;
  background: linear-gradient(to bottom, #4CAF50, #388E3C);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-radius: 5px;
  border: #0d460191 solid 1px;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.header-left {
  justify-content: flex-start;
}

.header-right {
  justify-content: flex-end;
  position: relative;
  gap: 8px;
}

.header h1 {
  font-size: clamp(18px, 2.5vw, 24px);
  /* Адаптивный размер от 18px до 24px */
  margin: 0;
  text-shadow: #000000 0.1em 0.1em 0.2em;
}

.header button {
  background: #205c2a;
  border: none;
  color: #fff;
  font-size: clamp(20px, 2.8vw, 28px);
  /* Адаптивный размер от 20px до 28px */
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  border-radius: 5px;
  width: clamp(36px, 4vw, 44px);
  /* Адаптивная ширина от 36px до 44px */
  height: clamp(36px, 4vw, 44px);
  /* Адаптивная высота от 36px до 44px */
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  margin: 0 8px;
  line-height: 1;
  padding: 0;
}

.header button:hover {
  background: #ffe066;
  color: #205c2a;
  opacity: 1;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
}

.legend-toggle {
  background: rgba(255, 255, 255, 0.15) !important;
  border-radius: 10px !important;
  width: clamp(36px, 3.4vw, 42px) !important;
  height: clamp(36px, 3.4vw, 42px) !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.4) !important;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.legend-toggle:hover,
.legend-toggle:focus-visible {
  background: #ffe066 !important;
  color: #205c2a;
  transform: rotate(5deg) scale(1.05);
}

.legend-toggle-icon {
  font-size: clamp(18px, 2.2vw, 22px);
  font-weight: 700;
  pointer-events: none;
}

.legend-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: -150px;
  background: rgba(247, 255, 249, 0.98);
  color: #14361b;
  border-radius: 10px;
  border: 1px solid rgba(13, 70, 1, 0.35);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
  padding: 16px 18px;
  width: min(320px, 90vw);
  max-height: 70vh;
  overflow-y: auto;
  display: none;
  z-index: 200000;
}

.legend-dropdown.open {
  display: block;
}

.legend-dropdown h2 {
  font-size: 16px;
  margin: 0 0 12px;
  text-align: left;
  color: #0a3d12;
  text-shadow: none;
}

.legend-dropdown ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-dropdown li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.legend-symbol,
.legend-emoji {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 18px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.legend-symbol {
  padding: 2px;
}

.legend-symbol--green {
  background: #e7f7eb;
  border: 1px solid #78c77c;
  color: #369b3d;
}

.legend-symbol--blue {
  background: #e4f1ff;
  border: 1px solid #2b66c2;
  color: #2b66c2;
}

.legend-symbol--yellow {
  background: #fff5d4;
  border: 1px solid #ba8e6a;
  color: #db824a;
}

.legend-symbol--black {
  background: #f2f2f2;
  border: 1px solid #4f4f4f;
  color: #2c2c2c;
}

.legend-shield {
  width: 20px;
  height: 20px;
}

.legend-emoji {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(12, 70, 1, 0.3);
}

.legend-dropdown li span:last-child {
  flex: 1;
  line-height: 1.3;
}

/* Названия дней недели */
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #ddd;
  padding: 10px 0;
  border-radius: 5px;
}

.weekdays div {
  font-weight: bold;
  color: #555;
  text-transform: uppercase;
  text-align: center;
  font-size: clamp(10px, 1.1vw, 14px);
  /* Адаптивный размер шрифта */
}

/* Сетка дней */
.days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(80px, auto);
  /* Автоматические строки с минимальной высотой */
  gap: 3px;
  /* Минимальные отступы */
  padding: 10px;
  align-items: stretch;
  /* Растягиваем элементы по высоте */
  flex: 1;
  /* Занимает все доступное пространство */
  min-height: 600px;
  /* Уменьшаем минимальную высоту */
  perspective: 1000px;
  /* Добавляем перспективу для 3D эффекта */
}

.day {
  min-width: auto;
  min-height: 70px;
  /* Уменьшаем минимальную высоту */
  height: auto;
  /* Автоматическая высота под содержимое */
  max-height: none;
  /* Убираем ограничение максимальной высоты */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  cursor: pointer;
  background: linear-gradient(to bottom, #e7ebff, #ffffff);
  border-radius: 5px;
  font-size: clamp(10px, 1.2vw, 16px);
  /* Адаптивный размер шрифта */
  border: 1px solid #bababa;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: 0.3s;
  text-align: center;
  overflow: visible;
  box-sizing: border-box;
  position: relative;
  transform-style: preserve-3d;
  /* Включаем 3D трансформации */
  transition: transform 0.6s ease-in-out;
  /* Анимация поворота */
}

.day.reservation-dropdown-open {
  z-index: 20000;
  overflow: visible;
}

/* Стили для переворота дня */
.day.flipped {
  transform: rotateY(180deg);
}

/* Передняя и задняя стороны дня */
.day-front,
.day-back {
  width: 100%;
  min-height: 100%;
  backface-visibility: hidden;
  border-radius: 5px;
  padding: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}

.day-front {
  background: linear-gradient(to bottom, #e7ebff, #ffffff);
  border: 1px solid #bababa;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transform: rotateY(0deg);
  /* Передняя сторона не повернута */
  position: relative;
  /* Передняя сторона относительная - задает высоту */
  overflow: visible;
  z-index: 2;
}

.day-header {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 2px 4px 8px;
  margin: 0 0 2px;
}

.day-name-wrapper {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  width: 100%;
}

.day-name-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1;
  flex-wrap: nowrap;
}

.day-reservation-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  z-index: 50;
}

.day.shield-tooltip-open {
  z-index: 40000;
}

.reservation-shield {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 26px;
  height: 26px;
  display: none;
  align-items: flex-start;
  justify-content: flex-start;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-bottom-right-radius: 25px;
  border-top-left-radius: 5px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  color: #31843f;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  z-index: 120;
}

.reservation-shield.active,
.reservation-shield:hover {
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.18);
  transform: scale(1.1);
}

.reservation-shield:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.shield-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.reservation-shield.shield-green {
  background: #e7f7eb;
  border-color: #78c77c;
  color: #369b3d;
}

.reservation-shield.shield-blue {
  background: #e4f1ff;
  border-color: #2b66c2;
  color: #2b66c2;
}

.reservation-shield.shield-yellow {
  background: #fff5d4;
  border-color: #ba8e6a;
  color: #db824a;
}

.reservation-shield-tooltip {
  position: absolute;
  top: 32px;
  left: 0;
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 8px 10px;
  max-width: 220px;
  width: max-content;
  background: rgba(245, 255, 246, 0.98);
  border: 1px solid #367143;
  border-radius: 6px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
  font-size: 0.72em;
  color: #123214;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 200000;
}

.reservation-shield-tooltip.visible {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.shield-tooltip-line {
  display: flex;
  flex-direction: row;
  gap: 6px;
  white-space: nowrap;
}

.shield-tooltip-half {
  font-weight: 600;
  color: #0a3d12;
}

.shield-tooltip-separator {
  color: #0a3d12;
  font-weight: 600;
}

.shield-tooltip-name {
  font-weight: 600;
  color: #20552a;
}


.day-reservation-toggle--hidden {
  display: none;
}

.day-reservation-toggle {
  background: transparent;
  border: none;
  color: #5a5353;
  cursor: pointer;
  width: 15px;
  height: 15px;
  margin-left: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.2s ease;
  opacity: 0.8;
}

.day-reservation-toggle:hover {
  transform: scale(1.2);
}

.day-reservation-toggle:focus-visible {
  outline: 2px solid #20552a;
  outline-offset: 2px;
}

.day-reservation-toggle:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.day-reservation-toggle .shield-icon {
  width: 20px;
  height: 20px;
}

.shield-icon.shield-black {
  color: #5a5353;
}

.day-reservation-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: auto;
  left: 0;
  transform: translateX(-4px);
  background: #d6ffdd;
  border: 1px solid #505e50;
  border-radius: 8px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
  padding: 4px 0;
  min-width: 180px;
  width: max-content;
  max-width: 280px;
  overflow-x: auto;
  z-index: 9999999;
  display: none;
}

.day-reservation-dropdown.open {
  display: block;
}

.day-reservation-dropdown.loading {
  opacity: 0.6;
  pointer-events: none;
}

.day-reservation-half {
  display: flex;
  flex-direction: column;
  border-top: 1px solid rgba(32, 76, 39, 0.15);
}

.day-reservation-half:first-child {
  border-top: none;
}

.day-reservation-half-toggle {
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  padding: 6px 12px;
  font-size: 0.85em;
  font-weight: 600;
  color: #0a2d10;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: color 0.2s ease, background 0.2s ease;
}

.day-reservation-half-toggle::after {
  content: '\25B8';
  font-size: 0.7em;
  opacity: 0.8;
  transition: transform 0.2s ease;
}

.day-reservation-half.open .day-reservation-half-toggle::after {
  transform: rotate(90deg);
}

.day-reservation-half-toggle:hover,
.day-reservation-half-toggle:focus-visible {
  color: #073b11;
  background: rgba(93, 138, 102, 0.18);
}

.day-reservation-half-toggle--selected {
  color: #054018;
}

.day-reservation-half-options {
  display: none;
  padding: 2px 0 4px;
  background: rgba(214, 255, 221, 0.6);
}

.day-reservation-half.open .day-reservation-half-options {
  display: block;
}

.day-reservation-option {
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  padding: 6px 12px;
  font-size: 0.85em;
  cursor: pointer;
  line-height: 1.2;
  color: #1d3b1f;
}

.day-reservation-option:hover {
  background: #5d8a66;
  color: #ffffff;
}

.day-reservation-option--active {
  background: linear-gradient(to right, #82eb93, #a4daac);
  font-weight: 600;
}

.day-reservation-option.day-reservation-clear {
  color: #000000;
  font-weight: 600;
  border-bottom: 1px solid #e6ece6;
}

.day-back {
  background: linear-gradient(to bottom, #fff7e6, #ffeaa7);
  border: 1px solid #ddb347;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transform: rotateY(180deg);
  /* Задняя сторона изначально повернута */
  padding: 10px;
  text-align: center;
  position: absolute;
  /* Только задняя сторона абсолютная */
  top: 0;
  left: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  word-wrap: break-word;
  word-break: break-word;
}

.day-back::-webkit-scrollbar {
  width: 6px;
}

.day-back::-webkit-scrollbar-track {
  background: transparent;
}

.day-back::-webkit-scrollbar-thumb {
  background: #c9a851;
  border-radius: 3px;
}

/* Кнопка поворота */
.flip-button {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 25px;
  height: 25px;
  background: rgba(59, 161, 201, 0.685);
  border: none;
  border-bottom-left-radius: 25px;
  border-top-right-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  color: white;
  z-index: 10;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.flip-button:hover {
  background: rgba(76, 175, 80, 1);
  transform: scale(1.1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.flip-button:active {
  transform: scale(0.95);
}

.day:hover .day-front {
  background: linear-gradient(to bottom, #cde, #f0f0f0);
}

/* Выходные дни - стили применяются к day-front и day-back */

.weekend .day-front {
  background: linear-gradient(to bottom, #f9e7da, #f0f0f0);
  /* Светлый фон для выходных */
  color: #000000;
  /* Темный текст для контраста */
  border: 1px solid #bababa;
  /* Легкая рамка для отделения */
  transition: background 0.3s ease, color 0.3s ease;
  /* Плавный переход фона и цвета */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  /* Легкая тень для глубины */
}

.weekend .day-back {
  background: linear-gradient(to bottom, #ffe5cc, #ffd4a3);
}

.weekend:hover .day-front {
  background: linear-gradient(to bottom, #fcd4b7, #ffe6e6);
}

/* Текущая дата */
.today .day-front {
  background: linear-gradient(to bottom, #9ddada, #ffffff) !important;
  color: rgb(0, 0, 0);
  font-weight: bold;
}

.today .day-back {
  background: linear-gradient(to bottom, #7dd3c0, #a8e6cf) !important;
}

/* Пустые ячейки (чтобы заполнять месяц корректно) */
.empty {
  visibility: hidden;
}

/* Блок для информации о запланированных операциях */
.day .operations {
  font-size: 12px;
  color: #333;
  margin-top: 5px;
  max-height: 80px;
  overflow: visible;
  text-overflow: ellipsis;
}

.comment-bubble {
  position: fixed !important;
  background: #e0e8f3;
  border: 1px solid #7fa1e0;
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-size: 1em;
  z-index: 999999 !important;
  display: none;
  max-width: 220px;
  width: 160px;
  overflow-wrap: break-word;
  /* корректный перенос слов */
  white-space: normal;
  /* перенос строк по пробелам */
  left: 0;
  top: 2em;
  /* Принудительно помещаем поверх всех элементов */
  transform: translateZ(999px) !important;
  -webkit-transform: translateZ(999px) !important;
}

/* Flip vendor support */
.day {
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.day.flipped {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}

.day-front,
.day-back {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.day:not(.flipped) .day-back {
  pointer-events: none;
}

.day.flipped .day-front {
  pointer-events: none;
}

.day.flipped .day-back {
  pointer-events: auto;
}

/* Разрешаем 3D внутри */
.day {
  overflow: visible;
}

/* Стили для кнопки массового переворота */
.header #flipAllDays {
  margin-left: 8px;
  background: #2d6a32;
  font-size: clamp(16px, 2vw, 22px);
  width: clamp(40px, 4.2vw, 50px);
  height: clamp(36px, 4vw, 44px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: background .25s, transform .2s;
}

.header #flipAllDays:hover {
  background: #ffd95e;
  color: #1d4f23;
  transform: translateY(-2px);
}

.header #flipAllDays:active {
  transform: scale(.92);
}

.header #flipAllDays[aria-pressed="true"] {
  background: #ffd95e;
}

.header .month-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header .month-block h1 {
  margin: 0;
}

.header .month-block #flipAllDays {
  margin-left: 0;
}