/*
  ============================================================
  PATHREST / INTOURS
  Booking popup: prepayment — CLEAN V13
  ------------------------------------------------------------
  Что делает:
  - скрывает стандартный Tilda select/input name="prepayment";
  - строит красивый inline-блок с вариантами предоплаты из текущего тура;
  - записывает выбранный вариант обратно в стандартное поле prepayment;
  - скрывает технические поля prepaymentprice;
  - записывает сумму/процент/статус предоплаты в техническое поле цены;
  - создаёт скрытое поле name="prepayment_for_telegram" для чистой отправки в Telegram/Email/CRM;
  - если тур без предоплаты — автоматически отправляет "Без предоплаты";
  - не даёт отправить форму, если для тура с предоплатой вариант не выбран;
  - после успешной отправки формы сбрасывает выбор предоплаты;
  - V12: исправлен resetForm ReferenceError и зацикливание MutationObserver на select/options.
  - V13: остановлен цикл render → mutation → render и повторные 401-запросы auth widget.
  ============================================================
*/

#allrecords .pathrest-booking-prepayment-field {
  width: 100%;
  box-sizing: border-box;
  font-family: "Arian AMU Serif", "ArianAMUSerif", "Times New Roman", serif;
  color: #006c83;
}

#allrecords .pathrest-booking-prepayment-field,
#allrecords .pathrest-booking-prepayment-field * {
  box-sizing: border-box;
}

#allrecords .pathrest-booking-prepayment-field__button {
  width: 100%;
  min-height: 58px;
  padding: 10px 54px 10px 22px;
  border: 1px solid #ffffff;
  border-radius: 30px;
  background: #ffffff;
  color: #006c83;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-family: "Arian AMU Serif", "ArianAMUSerif", "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

#allrecords .pathrest-booking-prepayment-field__button:hover,
#allrecords .pathrest-booking-prepayment-field.is-open .pathrest-booking-prepayment-field__button {
  border-color: rgba(255, 139, 33, 0.48);
  box-shadow: 0 0 0 4px rgba(255, 139, 33, 0.10);
}

#allrecords .pathrest-booking-prepayment-field__button::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 24px;
  width: 9px;
  height: 9px;
  border-right: 1.8px solid #006c83;
  border-bottom: 1.8px solid #006c83;
  transform: translateY(-65%) rotate(45deg);
  transition: transform 0.2s ease;
}

#allrecords .pathrest-booking-prepayment-field.is-open .pathrest-booking-prepayment-field__button::after {
  transform: translateY(-35%) rotate(-135deg);
}

#allrecords .pathrest-booking-prepayment-field.is-open .pathrest-booking-prepayment-field__button,
#allrecords .pathrest-booking-prepayment-field.is-saved .pathrest-booking-prepayment-field__button,
#allrecords .pathrest-booking-prepayment-field.is-no-prepayment .pathrest-booking-prepayment-field__button {
  display: none !important;
}

#allrecords .pathrest-booking-prepayment-field__button-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#allrecords .pathrest-booking-prepayment-field__button-title {
  color: rgba(0, 108, 131, 0.62);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 400;
}

#allrecords .pathrest-booking-prepayment-field__value {
  color: #006c83;
  font-size: 16px;
  line-height: 1.25;
}

#allrecords .pathrest-booking-prepayment-field__placeholder {
  color: rgba(0, 108, 131, 0.62);
}

#allrecords .pathrest-booking-prepayment-field__panel,
#allrecords .pathrest-booking-prepayment-field__summary,
#allrecords .pathrest-booking-prepayment-field__no-prepayment {
  display: none;
  width: 100%;
  margin: 0;
  padding: 18px;
  border: 1px solid rgba(42, 101, 131, 0.24);
  border-radius: 30px;
  background: #f5fdff;
  color: #006c83;
  box-shadow: none;
}

#allrecords .pathrest-booking-prepayment-field.is-open .pathrest-booking-prepayment-field__panel {
  display: block !important;
}

#allrecords .pathrest-booking-prepayment-field.is-saved .pathrest-booking-prepayment-field__summary {
  display: block !important;
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

#allrecords .pathrest-booking-prepayment-field.is-saved .pathrest-booking-prepayment-field__summary:hover {
  border-color: rgba(255, 139, 33, 0.34);
  box-shadow: 0 6px 18px rgba(255, 139, 33, 0.08);
}

#allrecords .pathrest-booking-prepayment-field.is-no-prepayment .pathrest-booking-prepayment-field__no-prepayment {
  display: block !important;
  cursor: default;
}

#allrecords .pathrest-booking-prepayment-field__panel-head,
#allrecords .pathrest-booking-prepayment-field__summary-head,
#allrecords .pathrest-booking-prepayment-field__no-prepayment-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 12px;
  min-height: 34px;
  margin: 0 0 12px;
  padding: 0;
}

#allrecords .pathrest-booking-prepayment-field__panel-head {
  cursor: pointer;
  border-radius: 20px;
  transition:
    background 0.18s ease,
    box-shadow 0.18s ease;
}

#allrecords .pathrest-booking-prepayment-field__panel-head:hover {
  background: rgba(255, 255, 255, 0.42);
}

#allrecords .pathrest-booking-prepayment-field__title,
#allrecords .pathrest-booking-prepayment-field__summary-title,
#allrecords .pathrest-booking-prepayment-field__no-prepayment-title {
  min-width: 0;
  color: #2a6583;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
}

#allrecords .pathrest-booking-prepayment-field__title {
  position: relative;
  padding-right: 34px;
}

#allrecords .pathrest-booking-prepayment-field__title::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255, 139, 33, 0.28);
  border-radius: 50%;
  background: rgba(255, 139, 33, 0.11);
  box-shadow: 0 5px 12px rgba(255, 139, 33, 0.08);
  transform: translateY(-50%);
}

#allrecords .pathrest-booking-prepayment-field__title::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 8px;
  z-index: 2;
  width: 7px;
  height: 7px;
  border-right: 1.7px solid #ff8b21;
  border-bottom: 1.7px solid #ff8b21;
  transform: translateY(-35%) rotate(-135deg);
  transition:
    border-color 0.18s ease,
    transform 0.18s ease;
}

#allrecords .pathrest-booking-prepayment-field__panel-head:hover .pathrest-booking-prepayment-field__title::before {
  border-color: #006c83;
  transform: translateY(-45%) rotate(-135deg);
}

#allrecords .pathrest-booking-prepayment-field__edit,
#allrecords .pathrest-booking-prepayment-field__no-prepayment-status {
  min-height: auto;
  max-width: none;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: rgba(42, 101, 131, 0.66);
  font-family: "Arian AMU Serif", "ArianAMUSerif", "Times New Roman", serif;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

#allrecords .pathrest-booking-prepayment-field__edit:hover {
  color: #ff8b21;
  text-decoration: underline;
}

#allrecords .pathrest-booking-prepayment-field__hint {
  margin: 0 0 14px;
  padding: 13px 14px;
  border: 1px solid rgba(255, 139, 33, 0.22);
  border-radius: 24px;
  background: rgba(255, 248, 241, 0.72);
  color: rgba(42, 101, 131, 0.82);
  font-size: 14px;
  line-height: 1.45;
}

#allrecords .pathrest-booking-prepayment-field__options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

#allrecords .pathrest-booking-prepayment-field__option {
  position: relative;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid rgba(0, 108, 131, 0.15);
  border-radius: 28px;
  background: #ffffff;
  color: #006c83;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  column-gap: 10px;
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

#allrecords .pathrest-booking-prepayment-field__option:hover {
  border-color: rgba(255, 139, 33, 0.48);
  background: #fffaf5;
  box-shadow: 0 6px 18px rgba(255, 139, 33, 0.08);
}

#allrecords .pathrest-booking-prepayment-field__option.is-selected {
  border-color: rgba(255, 139, 33, 0.72);
  background: #fff8f1;
  box-shadow: 0 7px 16px rgba(255, 139, 33, 0.08);
}

#allrecords .pathrest-booking-prepayment-field__radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

#allrecords .pathrest-booking-prepayment-field__mark {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border: 1.5px solid rgba(0, 108, 131, 0.32);
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  grid-column: 1;
  grid-row: 1 / span 3;
  transition:
    border-color 0.18s ease,
    background 0.18s ease;
}

#allrecords .pathrest-booking-prepayment-field__option.is-selected .pathrest-booking-prepayment-field__mark {
  border-color: #ff8b21;
  background: #ff8b21;
}

#allrecords .pathrest-booking-prepayment-field__mark::after {
  content: "✓";
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  transform: scale(0.7);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

#allrecords .pathrest-booking-prepayment-field__option.is-selected .pathrest-booking-prepayment-field__mark::after {
  opacity: 1;
  transform: scale(1);
}

#allrecords .pathrest-booking-prepayment-field__topline {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  grid-column: 2;
}

#allrecords .pathrest-booking-prepayment-field__option-title {
  min-width: 0;
  color: #006c83;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

#allrecords .pathrest-booking-prepayment-field__badge {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 139, 33, 0.14);
  color: #ff8b21;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
}

#allrecords .pathrest-booking-prepayment-field__desc {
  grid-column: 2;
  margin: 5px 0 0;
  color: rgba(0, 108, 131, 0.74);
  font-size: 13px;
  line-height: 1.38;
}

#allrecords .pathrest-booking-prepayment-field__summary-body,
#allrecords .pathrest-booking-prepayment-field__no-prepayment-body {
  width: 100%;
  min-height: 50px;
  padding: 14px 16px;
  border: 1px solid rgba(42, 101, 131, 0.18);
  border-radius: 28px;
  background: #ffffff;
  color: rgba(0, 108, 131, 0.84);
  display: block;
  font-size: 14px;
  line-height: 1.45;
}

#allrecords .pathrest-booking-prepayment-field__summary-empty {
  color: rgba(0, 108, 131, 0.68);
  font-size: 14px;
  line-height: 1.45;
}

#allrecords .pathrest-booking-prepayment-field__summary-value {
  position: relative;
  padding-left: 18px;
  color: #006c83;
}

#allrecords .pathrest-booking-prepayment-field__summary-value::before {
  content: "✓";
  position: absolute;
  top: 0;
  left: 0;
  color: #ff8b21;
  font-weight: 700;
}

#allrecords .pathrest-booking-prepayment-field__footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(42, 101, 131, 0.10);
}

#allrecords .pathrest-booking-prepayment-field__save {
  min-height: 42px;
  padding: 11px 22px;
  border: 1px solid #ff8b21;
  border-radius: 999px;
  background: #ff8b21;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Arian AMU Serif", "ArianAMUSerif", "Times New Roman", serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

#allrecords .pathrest-booking-prepayment-field__save:hover {
  background: #ffffff;
  color: #ff8b21;
  box-shadow: 0 6px 16px rgba(255, 139, 33, 0.16);
  transform: translateY(-1px);
}

#allrecords .pathrest-booking-prepayment-field__save:active {
  transform: translateY(0) scale(0.98);
}

#allrecords .pathrest-booking-prepayment-field__error {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 139, 33, 0.44);
  border-radius: 22px;
  background: rgba(255, 248, 241, 0.92);
  color: #c66200;
  font-size: 13px;
  line-height: 1.35;
}

#allrecords .pathrest-booking-prepayment-field.is-error .pathrest-booking-prepayment-field__error {
  display: block;
}

/*
  Надёжно скрываем стандартное Tilda-поле prepayment.
  Само поле не отключается, чтобы Tilda могла отправить его значение.
*/
#allrecords .t-input-group[data-field-name="prepayment"] .t-select__wrapper.pathrest-native-prepayment-select-hidden,
#allrecords .t-input-group[data-field-name="prepayment"] select[name="prepayment"].pathrest-native-prepayment-select-hidden,
#allrecords [name="prepayment"].pathrest-native-prepayment-select-hidden {
  position: absolute !important;
  left: -99999px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 1px !important;
  min-height: 1px !important;
  max-width: 1px !important;
  max-height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

#allrecords .t-input-group[data-field-name="prepaymentprice"],
#allrecords .pathrest-booking-prepayment-price-field-hidden {
  display: none !important;
}

#allrecords [name="prepaymentprice"].pathrest-booking-prepayment-price-input-hidden,
#allrecords [name="prepayment_for_telegram"].pathrest-booking-prepayment-telegram-hidden {
  position: absolute !important;
  left: -99999px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 1px !important;
  min-height: 1px !important;
  max-width: 1px !important;
  max-height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

#allrecords .t-input-group[data-field-name="prepayment"].pathrest-booking-prepayment-ready .t-input-block {
  border-radius: 0 !important;
  overflow: visible !important;
}

#allrecords .t-input-group[data-field-name="prepayment"].pathrest-booking-prepayment-ready .pathrest-booking-prepayment-field {
  margin: 0 !important;
}

#allrecords .t-popup.pathrest-booking-prepayment-popup-ready .t-popup__container {
  max-height: calc(100vh - 36px) !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

#allrecords .t-popup.pathrest-booking-prepayment-popup-ready .t-form__screen-wrapper_active,
#allrecords .t-popup.pathrest-booking-prepayment-popup-ready .t-form__inputsbox {
  overflow: visible !important;
}

@media (min-width: 768px) {
  #allrecords .pathrest-booking-prepayment-field__options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  #allrecords .t-input-group[data-field-name="prepayment"] .pathrest-booking-prepayment-field {
    position: relative !important;
    left: 50% !important;
    width: min(calc(100% + 20px), calc(100vw - 32px)) !important;
    max-width: calc(100vw - 32px) !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    transform: translateX(-50%) !important;
  }

  #allrecords .pathrest-booking-prepayment-field__button {
    min-height: 54px !important;
    padding: 14px 48px 14px 18px !important;
    font-size: 15px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__button::after {
    right: 20px;
  }

  #allrecords .pathrest-booking-prepayment-field__button-title {
    font-size: 11.5px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__value {
    font-size: 15px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__panel,
  #allrecords .pathrest-booking-prepayment-field__summary,
  #allrecords .pathrest-booking-prepayment-field__no-prepayment {
    padding: 15px 14px 16px !important;
    border-radius: 26px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__panel-head,
  #allrecords .pathrest-booking-prepayment-field__summary-head,
  #allrecords .pathrest-booking-prepayment-field__no-prepayment-head {
    column-gap: 8px !important;
    margin-bottom: 12px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__title,
  #allrecords .pathrest-booking-prepayment-field__summary-title,
  #allrecords .pathrest-booking-prepayment-field__no-prepayment-title {
    font-size: 14.5px !important;
    line-height: 1.22 !important;
  }

  #allrecords .pathrest-booking-prepayment-field__edit,
  #allrecords .pathrest-booking-prepayment-field__no-prepayment-status {
    font-size: 11.5px !important;
    line-height: 1.2 !important;
  }

  #allrecords .pathrest-booking-prepayment-field__hint {
    margin-bottom: 12px !important;
    padding: 11px 12px !important;
    border-radius: 22px !important;
    font-size: 12.4px !important;
    line-height: 1.34 !important;
  }

  #allrecords .pathrest-booking-prepayment-field__summary-body,
  #allrecords .pathrest-booking-prepayment-field__no-prepayment-body {
    min-height: 48px !important;
    padding: 12px 14px !important;
    border-radius: 24px !important;
    font-size: 12.8px !important;
    line-height: 1.36 !important;
  }

  #allrecords .pathrest-booking-prepayment-field__summary-empty,
  #allrecords .pathrest-booking-prepayment-field__summary-value {
    font-size: 12.8px !important;
    line-height: 1.36 !important;
  }

  #allrecords .pathrest-booking-prepayment-field__options {
    gap: 7px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__option {
    padding: 10px 12px !important;
    border-radius: 22px !important;
    grid-template-columns: 21px minmax(0, 1fr) !important;
    column-gap: 8px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__mark {
    width: 20px !important;
    height: 20px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__option-title {
    font-size: 12.8px !important;
    line-height: 1.24 !important;
  }

  #allrecords .pathrest-booking-prepayment-field__desc {
    margin-top: 4px !important;
    font-size: 11.8px !important;
    line-height: 1.32 !important;
  }

  #allrecords .pathrest-booking-prepayment-field__badge {
    padding: 3px 7px !important;
    font-size: 10.8px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__footer {
    margin-top: 12px !important;
    padding-top: 12px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__save {
    width: 100% !important;
    min-height: 39px !important;
    padding: 10px 18px !important;
    font-size: 13px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__error {
    padding: 9px 11px !important;
    border-radius: 20px !important;
    font-size: 12px !important;
    line-height: 1.32 !important;
  }
}

@media (max-width: 420px) {
  #allrecords .t-input-group[data-field-name="prepayment"] .pathrest-booking-prepayment-field {
    width: min(calc(100% + 16px), calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
  }

  #allrecords .pathrest-booking-prepayment-field__title,
  #allrecords .pathrest-booking-prepayment-field__summary-title,
  #allrecords .pathrest-booking-prepayment-field__no-prepayment-title {
    font-size: 14px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__option-title {
    font-size: 12.4px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__desc {
    font-size: 11.5px !important;
  }
}

/* === CLEAN V10: exact prepayment fields + final rounded cards === */
#allrecords .pathrest-booking-prepayment-field.is-saved .pathrest-booking-prepayment-field__summary,
#allrecords .pathrest-booking-prepayment-field.is-no-prepayment .pathrest-booking-prepayment-field__no-prepayment,
#allrecords .pathrest-booking-prepayment-field.is-open .pathrest-booking-prepayment-field__panel {
  border-radius: 30px !important;
}

#allrecords .pathrest-booking-prepayment-field__summary-body,
#allrecords .pathrest-booking-prepayment-field__no-prepayment-body,
#allrecords .pathrest-booking-prepayment-field__option {
  border-radius: 26px !important;
}

@media (max-width: 767px) {
  #allrecords .pathrest-booking-prepayment-field.is-saved .pathrest-booking-prepayment-field__summary,
  #allrecords .pathrest-booking-prepayment-field.is-no-prepayment .pathrest-booking-prepayment-field__no-prepayment,
  #allrecords .pathrest-booking-prepayment-field.is-open .pathrest-booking-prepayment-field__panel {
    border-radius: 26px !important;
  }

  #allrecords .pathrest-booking-prepayment-field__summary-body,
  #allrecords .pathrest-booking-prepayment-field__no-prepayment-body,
  #allrecords .pathrest-booking-prepayment-field__option {
    border-radius: 22px !important;
  }
}

