/* ---------- Редактор фотографий квартиры (#rental-lightbox-photos) ----------
   Рендерится JS-ом (js/components/gallery-editor.js) вместо обычной сетки
   миниатюр внутри папки объекта аренды — только администратору. Использует
   те же токены, что и остальной .rental-lightbox__*, чтобы не выбиваться
   из дизайна. */

.gallery-editor {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border-subtle);
}

/* Внутри #rental-lightbox-photos (см. rentals.js) этот элемент уже имеет
   .rental-lightbox__photos с собственным display:grid — отменяем его,
   иначе .gallery-editor__head и .gallery-editor__grid встанут в чужую
   3-колоночную сетку вместо обычного блочного потока. */
.rental-lightbox__photos.gallery-editor {
  display: block;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.gallery-editor__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.gallery-editor__heading {
  margin: 0 0 0.35rem;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--color-text-primary);
}

.gallery-editor__hint {
  margin: 0;
  max-width: 52ch;
  font-size: var(--fs-small);
  color: var(--color-text-tertiary);
}

.gallery-editor__upload {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-full);
  background: var(--gradient-emerald);
  color: var(--color-text-on-accent);
  font-size: var(--fs-small);
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-premium), box-shadow var(--duration-fast) var(--ease-premium);
}

.gallery-editor__upload:hover,
.gallery-editor__upload:focus-within {
  transform: translateY(-1px);
  box-shadow: var(--glow-emerald);
}

.gallery-editor__upload svg {
  width: 18px;
  height: 18px;
}

/* Пока идёт запрос к backend (upload/reorder/cover/remove) — блокирует
   повторные клики и наглядно показывает, что операция выполняется. */
.gallery-editor.is-busy {
  pointer-events: none;
  opacity: 0.6;
}

.gallery-editor__error {
  margin: 0 0 var(--space-sm);
  font-size: var(--fs-small);
  color: var(--color-error);
}

.gallery-editor__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-sm);
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery-editor__tile {
  position: relative;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-graphite-950);
  aspect-ratio: 4 / 3;
  cursor: grab;
  transition: border-color var(--duration-fast) var(--ease-premium), opacity var(--duration-fast) var(--ease-premium);
}

.gallery-editor__tile.is-cover {
  border-color: var(--color-lime-300);
}

.gallery-editor__tile.is-dragging {
  opacity: 0.4;
}

.gallery-editor__tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.gallery-editor__cover-flag {
  position: absolute;
  inset-block-start: 0.5rem;
  inset-inline-start: 0.5rem;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  background: var(--color-lime-300);
  color: var(--color-text-on-accent);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.gallery-editor__cover-flag svg {
  width: 12px;
  height: 12px;
}

.gallery-editor__tile-actions {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.4rem;
  background: linear-gradient(transparent, rgba(6, 10, 8, 0.9) 55%);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--duration-fast) var(--ease-premium), transform var(--duration-fast) var(--ease-premium);
}

.gallery-editor__tile:hover .gallery-editor__tile-actions,
.gallery-editor__tile:focus-within .gallery-editor__tile-actions {
  opacity: 1;
  transform: translateY(0);
}

.gallery-editor__icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: 50%;
  background: rgba(10, 15, 13, 0.85);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-premium), transform var(--duration-fast) var(--ease-premium);
}

.gallery-editor__icon-btn svg {
  width: 14px;
  height: 14px;
}

.gallery-editor__icon-btn:hover:not(:disabled),
.gallery-editor__icon-btn:focus-visible:not(:disabled) {
  background: var(--color-emerald-700);
  transform: scale(1.08);
  outline: none;
}

.gallery-editor__icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.gallery-editor__icon-btn--cover:not(:disabled):hover {
  background: var(--color-lime-400);
  color: var(--color-text-on-accent);
}

.gallery-editor__icon-btn--danger:not(:disabled):hover {
  background: var(--color-error);
  color: var(--color-text-on-accent);
}

.gallery-editor__icon-btn--prev svg {
  transform: rotate(90deg);
}

.gallery-editor__icon-btn--next svg {
  transform: rotate(-90deg);
}

@media (max-width: 900px) {
  .gallery-editor__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .gallery-editor__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .gallery-editor__upload {
    width: 100%;
    justify-content: center;
  }

  .gallery-editor__tile-actions {
    opacity: 1;
    transform: translateY(0);
    background: linear-gradient(transparent, rgba(6, 10, 8, 0.92) 45%);
  }
}
