/* =============================================
   MRT Custom Product Gallery
   Optimized for 30+ robot model images
   ============================================= */

.mrt-gallery {
  width: 100%;
  max-width: 520px;
}

/* Main Image Area */
.mrt-gallery__main {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.mrt-gallery__viewport {
  width: 100%;
  height: 100%;
  position: relative;
}

.mrt-gallery__slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  padding: 12px;
}

.mrt-gallery__slide.active {
  opacity: 1;
  pointer-events: auto;
}

/* Navigation Arrows */
.mrt-gallery__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #333;
  padding: 0;
}

.mrt-gallery__nav:hover {
  background: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  transform: translateY(-50%) scale(1.08);
}

.mrt-gallery__nav--prev {
  left: 10px;
}

.mrt-gallery__nav--next {
  right: 10px;
}

/* Counter Badge */
.mrt-gallery__counter {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  z-index: 5;
}

/* Thumbnail Strip */
.mrt-gallery__thumbs-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-top: 12px;
  gap: 6px;
}

.mrt-gallery__thumb-nav {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: #555;
  transition: all 0.2s ease;
  padding: 0;
}

.mrt-gallery__thumb-nav:hover {
  background: var(--color-primary, #4361ee);
  color: #fff;
  border-color: var(--color-primary, #4361ee);
}

.mrt-gallery__thumbs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
  padding: 4px 0;
}

.mrt-gallery__thumbs::-webkit-scrollbar {
  display: none;
}

.mrt-gallery__thumb {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.mrt-gallery__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mrt-gallery__thumb:hover {
  border-color: rgba(67, 97, 238, 0.4);
  transform: scale(1.05);
}

.mrt-gallery__thumb.active {
  border-color: var(--color-primary, #4361ee);
  box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

/* View All Button */
.mrt-gallery__view-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 10px 16px;
  background: transparent;
  border: 1px dashed rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  color: var(--color-primary, #4361ee);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mrt-gallery__view-all:hover {
  background: rgba(67, 97, 238, 0.05);
  border-color: var(--color-primary, #4361ee);
}

/* Grid Overlay */
.mrt-gallery__grid-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 40px 20px;
}

.mrt-gallery__grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1100px;
  padding: 0 0 20px;
  color: #fff;
}

.mrt-gallery__grid-header h3 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
}

.mrt-gallery__grid-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.mrt-gallery__grid-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.mrt-gallery__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 1100px;
}

.mrt-gallery__grid-item {
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  transition: all 0.2s ease;
  position: relative;
}

.mrt-gallery__grid-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
}

.mrt-gallery__grid-item:hover {
  transform: scale(1.04);
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.15);
}

.mrt-gallery__grid-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsive */
@media (max-width: 768px) {
  .mrt-gallery {
    max-width: 100%;
  }
  
  .mrt-gallery__main {
    border-radius: 12px;
  }
  
  .mrt-gallery__nav {
    width: 36px;
    height: 36px;
  }
  
  .mrt-gallery__thumb {
    width: 48px;
    height: 48px;
  }
  
  .mrt-gallery__grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}
