/* Modal base */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

/* When open */
.modal.is-open {
  display: flex;
}

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}

/* ✅ IMPORTANT: make dialog a flex column + limit height */
.modal__dialog {
  position: relative;
  width: min(560px, calc(100% - 24px));
  max-height: 90vh;                 /* ✅ ограничение по высоте */
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.18);

  display: flex;                    /* ✅ */
  flex-direction: column;           /* ✅ */
  overflow: hidden;                 /* ✅ скролл будет в body */
}

/* Header */
.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;

  flex: 0 0 auto;                   /* ✅ фиксируем */
}

.modal__title h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  color: #0f172a;
}

.modal__subtitle {
  margin-top: 3px;
  font-size: 13px;
  color: #64748b;
}


.modal__body {
  padding: 16px;
background: #ffffff;
  flex: 1 1 auto;                   
  overflow: auto;                   
  -webkit-overflow-scrolling: touch;
}

/* Footer */
.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;

  flex: 0 0 auto;                   /* ✅ фиксируем */
}

/* (опционально) запрет скролла фона когда модалка открыта */
body.modal-open {
  overflow: hidden;
}

/* Form fields */
.field {
  display: grid;
  gap: 6px;
}

.field__label {
  font-size: 13px;
  color: #475569;
  font-weight: 600;
}

.input, select {
  height: 36px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  padding: 0 10px;
  font-size: 14px;
  outline: none;
  background: #ffffff;
}

textarea {
  min-height: 150px;
}

.input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Buttons */
.btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  /*background: #ffffff;*/
  cursor: pointer;
  margin-left:1em;
  margin-bottom:1em;
}

.btn:hover {
  background: #ca938c;
}

.btn--primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.btn--primary:hover {
  background: #1d4ed8;
}

/* Close icon button */
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: #64748b;
  display: grid;
  place-items: center;
}

.icon-btn:hover {
  background: #eef2f7;
  color: #0f172a;
}

.icon {
  width: 18px;
  height: 18px;
}

.property-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
  padding: 10px 0;
  border-bottom: 1px solid #e5e7eb;
}

.property-row:last-child {
  border-bottom: 0;
}

@media (max-width: 640px) {
  .property-row {
    grid-template-columns: 1fr;
  }
}

.property-row {
  position: relative;
   background:#eff3f3;
   margin: 1em 0;  
   border-radius:0.5em;
   padding:0 0.5em;
}

.property-remove {
     
  justify-self: end;
  align-self: start;
  height: 32px;
  padding: 0 10px;
  color: red;
    font-weight: 600;
}

/* Photos section */
.photos { 
    margin-top: 1em;
    margin-bottom: 1em;
    padding-top: 1em; 
    padding-bottom: 1em; 
    border-top:1px solid #e5e7eb;
    border-bottom:1px solid #e5e7eb;
}

.photos__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.photos__title {
    font-size: 13px;
  font-weight: 600;
}

.photos__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* fixed height box with internal scroll */
.photos__box {
  position: relative;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 10px;
  margin-top:0.5em;
  padding: 10px;
  height:auto;
  max-height: 200px;              /* ~2 rows of 84px thumbs + gaps/padding */
  overflow: auto;
  background: rgba(0,0,0,0.02);
}

/* grid with thumbs */
.photos__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
}

/* thumb tile */
.photo-tile {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.08);
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* remove button on tile */
.photo-tile__remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  background: rgba(0,0,0,0.65);
  color: #fff;
  display: grid;
  place-items: center;
}

.photo-tile__remove:hover { background: rgba(0,0,0,0.8); }

.photos__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  text-align: center;
  color: rgba(0,0,0,0.55);
  pointer-events: none;
}

.photos__hint {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(0,0,0,0.55);
}

.photo-tile.is-removed {
  opacity: 0.35;
  filter: grayscale(1);
}

.photo-tile.is-removed::after {
  content: "Будет удалено";
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
}

.modal__saving {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(2px);
  z-index: 10;
}

.modal__saving.is-on { display: flex; }

.modal__savingBox {
  width: min(360px, calc(100% - 32px));
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.18);
  padding: 14px 16px;
}

.modal__savingTitle {
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 8px;
  font-size: 14px;
}

.modal__progress {
  height: 10px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.modal__progress > div {
  height: 100%;
  width: 0%;
  background: #2563eb;
  transition: width .15s linear;
}

.modal__savingMeta {
  margin-top: 8px;
  font-size: 12px;
  color: #64748b;
}