.sg-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
}

.sg-modal--open {
  display: block;
}

.sg-modal__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
}

.sg-modal__container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-sizing: border-box;
}

.sg-modal__close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.3s;
}

.sg-modal__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sg-modal__main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding-bottom: 120px; /* Место для превью */
}

.sg-modal__image-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sg-modal__image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  animation: fadeIn 0.3s ease;
  max-height: 70vh;
}

@keyframes fadeIn {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

.sg-modal__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: background 0.3s;
}

.sg-modal__nav:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sg-modal__prev {
  left: 20px;
}

.sg-modal__next {
  right: 20px;
}

.sg-modal__thumbs {
  position: absolute;
  bottom: 20px;
  left: 0;
  width: 100%;
  padding: 0 60px;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
}

.sg-modal__thumbs::-webkit-scrollbar {
  display: none; /* Chrome, Safari */
}

.sg-modal__thumb {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.3s;
}

.sg-modal__thumb:hover {
  opacity: 0.8;
}

.sg-modal__thumb--active {
  border-color: white;
  opacity: 1;
}

.sg-modal__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Адаптивность */
@media (max-width: 768px) {
  .sg-modal__container {
    padding: 10px;
  }
  
  .sg-modal__close {
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
  }
  
  .sg-modal__nav {
    width: 40px;
    height: 40px;
    bottom: 100px;
    top: auto;
    transform: none;
  }
  
  .sg-modal__prev {
    left: 10px;
  }
  
  .sg-modal__next {
    right: 10px;
  }
  
  .sg-modal__main {
    padding-bottom: 100px;
  }
  
  .sg-modal__thumbs {
    padding: 0 50px;
    gap: 8px;
  }
  
  .sg-modal__thumb {
    width: 60px;
    height: 60px;
  }
}

/* Стили для элементов галереи на странице */
.sugar-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
}

.sugar-gallery-item {
  display: block;
  width: 120px;
  height: 120px;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s;
  transition: .3s all;

}

@media(min-width: 991px) {
  .sugar-gallery-item {
    width: 100%;
    height: 100%;
  }
}

.sugar-gallery-item:hover {
  transform: scale(1.05);
  transition: .3s all;
}

.sugar-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}