/* Стили для галереи */
.product-gallery-section {
  margin: 20px 0;
  padding: 0 20px;
}

.gallery-thumbs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 10px;
  padding: 10px 0;
}

.gallery-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 100px;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.gallery-thumb:hover {
  border-color: #007bff;
}

.thumb-container {
  position: relative;
  display: block;
  overflow: hidden;
  height: 100px;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-thumb:hover img {
  transform: scale(1.05);
}

/* Стили для главного изображения в галерее */
.gallery-thumb.main-thumb {
  border-color: #28a745;
  border-width: 3px;
}

.main-image-badge {
  position: absolute;
  top: 5px;
  left: 5px;
  background: #28a745;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: bold;
  z-index: 2;
}

/* Кнопка установки главного изображения - ИСПРАВЛЕНА АНИМАЦИЯ */
.set-main-button {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.9);
  padding: 8px 5px;
  text-align: center;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateY(100%);
  z-index: 3;
  backdrop-filter: blur(2px);
}

.gallery-thumb:hover .set-main-button {
  opacity: 1;
  transform: translateY(0);
}

.btn-set-main {
  background: #007bff;
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 3px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 90%;
  font-weight: 500;
}

.btn-set-main:hover {
  background: var(--link-color);
  transform: translateY(-1px);
}

.btn-set-main:active {
  transform: translateY(0);
}

/* Плавная смена главного изображения товара */
.product-image {
  transition: opacity 0.3s ease;
}

/* Убираем мигание при наведении */
.gallery-thumb .set-main-button {
  pointer-events: auto;
}

/* Скрываем кнопку на главном изображении */
.gallery-thumb.main-thumb .set-main-button {
  display: none;
}

/* Модальное окно галереи */
.gallery-modal {
  display: none;
  position: fixed;
  z-index: 1004;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  animation: fadeIn 0.3s ease;
}

.gallery-modal-content {
  position: relative;
  margin: auto;
  padding: 20px;
  width: auto;
  max-width: 90%;
  max-height: 90vh;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
}

.gallery-modal-content img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  animation: zoomIn 0.3s ease;
}

.gallery-close {
  position: absolute;
  top: 15px;
  right: 35px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1003 !important;
  transition: color 0.3s ease;
}

.gallery-close:hover {
  color: #555;
}

.gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-size: 50px;
  font-weight: bold;
  cursor: pointer;
  padding: 40px 16px;
  user-select: none;
  z-index: 1003 !important;
  transition: all 0.3s ease;
  border-radius: 10px;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(155, 155, 155, 0.45);
}

.gallery-prev {
  left: 20px;
}

.gallery-next {
  right: 20px;
}

.gallery-arrow:hover {
  background-color: rgba(100, 100, 100, 0.65);
  transform: translateY(-50%) scale(1.1);
}

.gallery-caption {
  color: #fff;
  text-align: center;
  padding: 10px 0;
  font-size: 16px;
  animation: fadeIn 0.5s ease;
}

/* Анимации */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Скрыть scrollbar для Chrome, Safari и Opera */
.gallery-thumbs::-webkit-scrollbar {
  height: 8px;
}

.gallery-thumbs::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.gallery-thumbs::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
  transition: background 0.3s ease;
}

.gallery-thumbs::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
  .product-gallery-section {
    padding: 0 10px;
  }

  .gallery-thumb {
    width: 80px;
  }

  .thumb-container {
    height: 80px;
  }

  .btn-set-main {
    font-size: 9px;
    padding: 4px 6px;
  }

  .main-image-badge {
    font-size: 8px;
    padding: 1px 4px;
  }

  .gallery-arrow {
    font-size: 30px;
    padding: 10px;
    width: 45px;
    height: 45px;
  }

  .gallery-close {
    font-size: 30px;
    top: 10px;
    right: 20px;
    z-index: 1003 !important;
  }

  .set-main-button {
    padding: 6px 3px;
  }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
  .gallery-thumb {
    width: 70px;
  }

  .thumb-container {
    height: 70px;
  }

  .btn-set-main {
    font-size: 8px;
    padding: 3px 4px;
  }
}
