/* images.css */

/* Ensure all preview containers are positioned for the × button */
.image-preview-wrapper,
.ll-gallery-item,
.ll-logo-thumb,
#ll_logo_preview_wrapper,
#ll_images_gallery {
  position: relative;
}

/* Gallery thumb layout */
.ll-gallery-item {
  display: inline-block;
}

/*
 * Keep gallery previews large enough to inspect in forms.
 * The !important declarations intentionally override legacy ll-img-64
 * utility sizing used by dynamically-added media previews.
 */
.ll-field-images .ll-gallery-item img {
  width: 180px !important;
  max-width: 180px !important;
  height: 120px !important;
  object-fit: contain;
}

/* Unified remove "×" button for logo + gallery */
.ll-remove-image {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  line-height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  border: 1px solid #fff;
  cursor: pointer;
  padding: 0;
  z-index: 2;
}

.ll-remove-image:hover {
  background: rgba(0, 0, 0, 0.9);
}

/* Optional decorative gallery extras */
.image-gallery { text-align: center; margin-top: 20px; }
.image-gallery img {
  display: inline-block;
  border: 2px solid #ddd;
  border-radius: 5px;
  transition: transform .3s ease, border-color .3s ease;
}

.image-gallery img:hover { transform: scale(1.05); border-color: #aaa; }

.business-logo img { max-width: 250px; height: auto; }
.featured-image img { max-width: 500px; height: auto; }

.logo-container, .images-container { margin-bottom: 15px; }
.logo-controls, .images-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}

.logo-preview, .images-gallery { margin-top: 5px; }
.logo-preview { display: inline-block; }

/* Safety: ensure the × can't be clipped by the thumb wrapper */
.ll-gallery-item { overflow: visible; }

/* Better keyboard accessibility */
.ll-remove-image:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 1px;
  box-shadow: 0 0 0 3px rgba(0,0,0,.35);
}

/* Touch comfort: bump target slightly on narrow screens */
@media (max-width: 640px) {
  .ll-field-images .ll-gallery-item img {
    width: 150px !important;
    max-width: 150px !important;
    height: 100px !important;
  }

  .ll-remove-image {
    width: 24px;
    height: 24px;
    line-height: 22px;
    font-size: 18px;
  }
}

/* RTL support: move the × to the top-left when in RTL context */
[dir="rtl"] .ll-remove-image {
  right: auto;
  left: 4px;
}

/* If you ever toggle with [hidden], make sure it actually hides */
.ll-remove-image[hidden] { display: none !important; }


/* Immediate local preview while WordPress processes image metadata. */
.ll-anonymous-upload-status {
  display: block;
  margin-top: 6px;
  color: #1d4ed8;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.3;
}

.image-preview-wrapper.is-uploading .ll-logo-thumb,
.ll-gallery-item--uploading {
  opacity: 0.82;
}

.image-preview-wrapper.is-uploading .ll-logo-thumb::after,
.ll-gallery-item--uploading::after {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-top-color: #2563eb;
  border-radius: 50%;
  content: "";
  animation: ll-image-upload-spin 0.8s linear infinite;
  pointer-events: none;
}

.image-preview-wrapper.is-upload-ready .ll-anonymous-upload-status {
  color: #166534;
}

.image-preview-wrapper.is-upload-error .ll-anonymous-upload-status,
.ll-gallery-item--uploading.is-upload-error .ll-anonymous-upload-status {
  color: #b91c1c;
}

@keyframes ll-image-upload-spin {
  to { transform: rotate(360deg); }
}
