/* Gallery positioned inside product-options-panel - FINAL FIX */

/* Option gallery - Smooth expansion within flow */
.option-gallery {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin: 0;
  padding: 0;
  overflow: hidden;

  /* Lock width */
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;

  /* Start collapsed */
  max-height: 0;
  opacity: 0;

  /* Smooth transitions */
  transition:
    max-height 350ms cubic-bezier(0.4, 0, 0.2, 1),
    opacity 300ms ease,
    margin 350ms ease,
    padding 350ms ease;
}

.option-gallery.active {
  max-height: 280px;
  opacity: 1;
  padding: var(--space-2);
  margin: var(--space-2) 0;
}

/* --- NO-FIRST-IMAGE-FLASH FIX --- */
/* Keep carousels hidden until JS mounts Glide */
.option-gallery .glide {
  opacity: 0;
  visibility: hidden;
}

/* Reveal only after JS adds .is-ready post-mount */
.option-gallery .glide.is-ready {
  opacity: 1;
  visibility: visible;
  transition: opacity 220ms ease;
}

/* (Hardening) keep slides in a row even pre-mount to avoid layout jump */
.option-gallery .glide__slides {
  display: flex; /* lets first li sit inline rather than full-bleed */
}

/* Gallery header */
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.gallery-header h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin: 0;
  letter-spacing: 0.5px;
}

/* Close button */
.gallery-close {
  background: rgba(255,255,255,0.9);
  border: 1px solid #ddd;
  font-size: 16px;
  cursor: pointer;
  color: #666;
  z-index: 10;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.gallery-close:hover {
  background: #f0f0f0;
  color: #333;
  border-color: #bbb;
}

/* Glide container */
.glide {
  position: relative;
  width: 100%;
  max-width: 100%;
}

/* Ensure glide track has proper height and stays contained */
.glide__track {
  min-height: 160px;
  overflow: hidden;
  width: 100%;
}

/* Glide slides container (display:flex declared above in fix) */
.glide__slides {
  width: 100%;
}

/* Glide slide styling */
.glide__slide {
  text-align: center;
  padding: 8px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.glide__slide img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 8px;
  border: 1px solid #eee;
}

.glide__slide span {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #333;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

/* Navigation arrows */
.glide__arrow {
  background: rgba(255,255,255,0.9);
  border: 1px solid #ddd;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: #333;
  font-size: 16px;
  cursor: pointer;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: all 0.2s ease;
}

.glide__arrow--left { left: 10px; }
.glide__arrow--right { right: 10px; }

.glide__arrow:hover {
  background: var(--brand-accent, #58c4c0);
  color: #fff;
  border-color: var(--brand-accent, #58c4c0);
}

.glide__arrow:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Option item active state when gallery is open */
.option-item.active-gallery-item {
  border-color: var(--brand-accent, #58c4c0);
  background: #f0f9f8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(88, 196, 192, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .option-gallery.active {
    max-height: 250px;
    padding: 15px;
  }
  .glide__slide { min-height: 140px; }
  .glide__slide img { height: 100px; }
  .glide__arrow { width: 28px; height: 28px; font-size: 14px; }
  .glide__track { min-height: 140px; }
}

@media (max-width: 480px) {
  .option-gallery.active {
    max-height: 220px;
    padding: 12px;
  }
  .glide__slide { min-height: 120px; }
  .glide__slide img { height: 80px; }
  .gallery-header h4 { font-size: 1rem; }
  .glide__track { min-height: 120px; }
}
