/* Кадр фото в каталозі
   Absolute fill avoids Safari/mobile bugs where height:100% inside
   aspect-ratio parents resolves incorrectly and crops/hides photos. */
.catalog-image-frame {
  width: 100%;
  overflow: hidden;
  flex-shrink: 0;
  background:
    radial-gradient(120% 110% at 0% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 60%),
    radial-gradient(120% 110% at 100% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.03) 0%, transparent 70%),
    #080a0e;
  position: relative;
  isolation: isolate;
}

/* Fallback height when aspect-ratio is unsupported (older mobile WebKit). */
@supports not (aspect-ratio: 1 / 1) {
  .catalog-image-frame::before {
    content: '';
    display: block;
    width: 100%;
    padding-top: calc(100% / (var(--catalog-ar, 1.333333)));
  }
}

.catalog-image-frame img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  image-orientation: from-image;
  user-select: none;
  -webkit-user-drag: none;
}

.product .catalog-image-frame,
.horizontal-product .catalog-image-frame {
  flex-shrink: 0;
  height: auto;
}

.product .catalog-image-frame img,
.horizontal-product .catalog-image-frame img {
  width: 100%;
  height: 100%;
  max-height: none;
}

/* Редактор в адмінці */
.catalog-image-editor-backdrop {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: rgba(0, 0, 0, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.catalog-image-editor-backdrop.is-open {
  display: flex;
}

.catalog-image-editor-modal {
  width: min(980px, 100%);
  max-height: min(94vh, 920px);
  overflow: auto;
  background: #141820;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 20px 22px 22px;
  color: #fff;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.catalog-image-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.catalog-image-editor-head h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.catalog-image-editor-head p {
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.58);
  line-height: 1.45;
}

.catalog-image-editor-close {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.catalog-image-editor-design-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.catalog-image-editor-design-tab {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
}

.catalog-image-editor-design-tab.active {
  border-color: rgba(229, 198, 123, 0.55);
  background: rgba(229, 198, 123, 0.16);
  color: #e5c67b;
}

.catalog-image-editor-layout {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 18px;
  align-items: start;
}

@media (max-width: 760px) {
  .catalog-image-editor-layout {
    grid-template-columns: 1fr;
  }
}

/* Робоча область з видимою рамкою обрізки */
.catalog-image-editor-crop-wrap {
  padding: 16px;
  border-radius: 12px;
  background: #0c0f14;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.catalog-crop-workspace {
  position: relative;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.04) 0%, transparent 65%),
    #080a0e;
  border-radius: 10px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  isolation: isolate;
}

.catalog-crop-workspace.is-dragging {
  cursor: grabbing;
}

.catalog-crop-stage {
  position: relative;
  width: min(100%, 380px);
  max-height: calc(72vh - 80px);
  margin: 0 auto;
  flex-shrink: 0;
}

.catalog-crop-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.catalog-crop-workspace .catalog-crop-frame {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  border: 2px solid #e5c67b;
  border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.62);
  background: transparent;
  pointer-events: none;
}

.catalog-crop-workspace .catalog-crop-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 2px;
}

.catalog-image-editor-preview-label {
  margin: 12px 0 0;
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.45;
}

/* Прев’ю всіх дизайнів */
.catalog-image-editor-all-previews {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 640px) {
  .catalog-image-editor-all-previews {
    grid-template-columns: 1fr;
  }
}

.catalog-image-editor-mini {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.catalog-image-editor-mini:hover {
  border-color: rgba(229, 198, 123, 0.35);
  background: rgba(255, 255, 255, 0.05);
}

.catalog-image-editor-mini.is-active {
  border-color: rgba(229, 198, 123, 0.65);
  background: rgba(229, 198, 123, 0.1);
  box-shadow: inset 0 0 0 1px rgba(229, 198, 123, 0.25);
}

.catalog-image-editor-mini.is-custom .catalog-image-editor-mini-label::after {
  content: ' •';
  color: #e5c67b;
}

.catalog-image-editor-mini-label {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.catalog-image-editor-mini-frame {
  width: 100%;
  overflow: hidden;
  background:
    radial-gradient(120% 110% at 0% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 60%),
    radial-gradient(120% 110% at 100% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.03) 0%, transparent 70%),
    #080a0e;
}

.catalog-image-editor-mini-frame img {
  display: block;
  width: 100%;
  height: 100%;
}

.catalog-image-editor-mini[data-home-design="forest"] .catalog-image-editor-mini-frame {
  border-radius: 10px;
}

.catalog-image-editor-mini[data-home-design="modern"] .catalog-image-editor-mini-frame {
  border-radius: 0;
}

.catalog-image-editor-controls label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 8px;
}

.catalog-image-editor-ar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.catalog-image-editor-ar-btn {
  min-width: 52px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.catalog-image-editor-ar-btn.active {
  border-color: rgba(229, 198, 123, 0.55);
  background: rgba(229, 198, 123, 0.16);
  color: #e5c67b;
}

.catalog-image-editor-scale {
  width: 100%;
  margin: 8px 0 4px;
}

.catalog-image-editor-scale-value {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 14px;
}

.catalog-image-editor-hint {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.48);
  margin: 0 0 14px;
}

.catalog-image-editor-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
  justify-content: flex-end;
}

.catalog-image-editor-actions .add-btn,
.catalog-image-editor-actions .rate-recalc-btn {
  margin: 0;
}

.catalog-image-editor-crop-wrap[data-home-design="forest"] .catalog-crop-frame {
  border-radius: 12px;
}

.catalog-image-editor-crop-wrap[data-home-design="modern"] .catalog-crop-frame {
  border-radius: 0;
}

.images-list .image-crop-btn {
  flex-shrink: 0;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid rgba(229, 198, 123, 0.4);
  background: rgba(229, 198, 123, 0.12);
  color: #e5c67b;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
}

.images-list .image-crop-btn:hover {
  background: rgba(229, 198, 123, 0.22);
}
