/* Image Gallery Modal */
.image-gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  overflow-y: auto;
}

.image-gallery-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

.image-gallery-modal-content {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  padding-top: 50px;
  max-width: 1800px;
  min-width: 90vw;
  max-height: 80vh;
  height: 800px;
  overflow: auto;
  width: auto;
  position: relative;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.image-gallery-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 28px;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

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

.image-gallery-close-mobile {
  display: none;
}

.gallery-mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.gallery-mobile-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  flex: 1;
  padding-right: 10px;
  font-size: 14px;
  line-height: 16px;
}

/* Gallery Container */
.gallery-container {
  display: flex;
  gap: 30px;
  background: #fff;
  align-items: stretch;
  height: 100%;
}

.gallery-main-section {
  flex: 1;
  min-width: 300px;
  position: relative;
  background: white;
}

.gallery-main-wrapper {
  position: relative;
  overflow: hidden;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: zoom-in;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-main-image {
  background: white;
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  transition: opacity 0.3s ease, transform 0.05s linear;
  will-change: transform;
}

.gallery-main-wrapper.zoomed {
  cursor: move;
}

.gallery-main-wrapper.zoomed .gallery-main-image {
  cursor: move;
}

/* Zoomed Image Display */
.gallery-zoomed-display {
  position: absolute;
  top: 0;
  right: -420px;
  background: #f5f5f5;
  overflow: hidden;
  display: none;
  width: 400px;
  height: 400px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-size: cover;
  background-repeat: no-repeat;
}

.gallery-main-wrapper.zoomed ~ .gallery-zoomed-display {
  display: none;
}

/* Product Info */
.gallery-info-section {
  flex: 0 0 350px;
  width: 350px;
  min-width: 350px;
  display: flex;
  flex-direction: column;
}

.gallery-product-name {
  font-size: 20px;
  margin: 0 0 10px 0;
  line-height: 1.3;
  color: #333;
  text-align: justify;
}

/* Thumbnails */
.gallery-thumbnails-container {
  flex: 1;
  overflow-y: auto;
}

.gallery-thumbnails {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.gallery-thumb-item {
  position: relative;
  overflow: hidden;
  border: 2px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  background: #f9f9f9;
  transition: border-color 0.3s ease;
  aspect-ratio: 1;
}

.gallery-thumb-item:hover {
  border-color: #999;
}

.gallery-thumb-item.active {
  border-color: #ff9500;
}

.gallery-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-mobile-images {
  display: none;
  background: #d6d6d6;
  scroll-behavior: smooth;
}

.gallery-mobile-image-wrapper {
  display: flex;
  justify-content: center;
  padding: 5px 10px;
}

.gallery-mobile-image-wrapper img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

@media (min-width: 768px) {
  gallery-container {
    width: 90vw;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .gallery-container {
    flex-direction: column;
    gap: 20px;
  }

  .gallery-info-section {
    min-width: auto;
  }

  .gallery-thumbnails {
    grid-template-columns: repeat(4, 1fr);
  }

  .gallery-zoomed-display {
    position: static;
    width: 100%;
    height: 300px;
    margin-top: 20px;
  }

  .image-gallery-modal-content {
    padding: 15px;
  }

  .image-gallery-close {
    top: 20px;
    right: 40px;
  }
}

@media (max-width: 768px) {
  .image-gallery-modal-content {
    max-width: 100%;
    min-width: 100%;
    max-height: unset;
    height: 100vh;
    height: 100dvh;
    padding: 0;
    border-radius: 0;
    overflow: hidden;
    padding-bottom: 70px;
  }

  .image-gallery-close-desktop {
    display: none;
  }

  .image-gallery-close-mobile {
    display: flex;
    position: static;
    width: 40px;
    height: 40px;
    font-size: 32px;
  }

  .gallery-mobile-header {
    display: flex;
  }

  .gallery-container {
    flex-direction: column;
    height: 100%;
    gap: 0;
  }

  .gallery-main-section {
    flex: 1;
    min-width: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
  }

  .gallery-main-wrapper {
    display: none;
  }

  .gallery-mobile-images {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: auto;
  }

  .gallery-info-section {
    display: none;
  }
}

@media (max-width: 480px) {
  .gallery-container {
    gap: 15px;
  }

  .gallery-thumbnails {
    grid-template-columns: repeat(3, 1fr);
  }

  .gallery-main-wrapper {
    aspect-ratio: auto;
    min-height: 250px;
  }

  .gallery-product-name {
    font-size: 18px;
  }
}
