/* Основная галерея превью */
.gallery-preview {
  margin: 20px 0;
}

.gallery-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  grid-template-rows: 200px 200px;
  gap: 8px;
  border-radius: 15px;
  overflow: hidden;
  height: 408px;
}

.gallery-grid-products {
  display: block;
  height: 408px;
  border-radius: 15px;
  overflow: hidden;
}

.gallery-item {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.3s ease;
  border-radius: 15px;
  background: #f5f5f5;
}

.gallery-item:hover {
  transform: scale(1.02);
}

.gallery-item:first-child {
  grid-row: 1 / 3;
  grid-column: 1 / 2;
}

.gallery-item:nth-child(2), .gallery-item-similar:nth-child(2) {
  grid-row: 1 / 2;
  grid-column: 2 / 3;
}

.gallery-item:nth-child(3), .gallery-item-similar:nth-child(3) {
  grid-row: 1 / 2;
  grid-column: 3 / 4;
}

.gallery-item:nth-child(4), .gallery-item-similar:nth-child(4) {
  grid-row: 2 / 3;
  grid-column: 2 / 3;
}

.gallery-item:nth-child(5), .gallery-item-similar:nth-child(5) {
  grid-row: 2 / 3;
  grid-column: 3 / 4;
}

/* Скрываем лишние элементы после 5-го */
.gallery-item:nth-child(n+6), .gallery-item-similar:nth-child(n+6) {
  display: none;
}

.gallery-item img, .gallery-item-similar img {
  width: 100%;
  height: 100%;
  max-height: 400px;
  object-fit: contain;
  display: block;
  border-radius: 15px;
}

.gallery-more {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  border-radius: 15px;
}

/* Popup галерея */
.gallery-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 99999;
  display: none;
}

.popup-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(5px);
}

.popup-container {
  position: relative;
  width: 95%;
  height: 95%;
  max-width: 1300px;
  background: white;
  border-radius: 12px;
  margin: 1.5% auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  border-bottom: 1px solid #e5e5e5;
}

.popup-title {
  margin: 0;
  font-size: 20px;
  font-weight: bold;
  color: #141414;
}

.popup-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.2s;
  color: #666;
}

.popup-close:hover {
  background-color: #f5f5f5;
  color: #333;
}

.popup-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

/* Левая часть - фото */
.gallery-main {
  flex: 0 0 65%;
  display: flex;
  flex-direction: column;
  padding: 20px;
  position: relative;
  min-width: 0;
  max-width: 65%;
}

.gallery-slider {
  flex: 1;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  min-height: 0;
}

.slide-container {
  display: flex;
  height: 100%;
  transition: transform 0.3s ease;
}

.gallery-slide {
  min-width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.gallery-slide img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 15px;
}

/* Счетчик над фото */
.slide-counter-top {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 10;
  backdrop-filter: blur(10px);
}

/* Навигация - кнопки по центру */
.gallery-nav-center {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  pointer-events: none;
  z-index: 5;
}

.nav-btn-center {
  background: #464a4f;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: white;
  pointer-events: all;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.nav-btn-center:hover {
  background: #5a5f64;
  transform: scale(1.05);
}

.nav-btn-center:active {
  transform: scale(0.95);
}

.nav-btn-center svg {
  width: 20px;
  height: 20px;
}

.prev-btn-center svg {
  transform: rotate(0deg);
}

.next-btn-center svg {
  transform: rotate(-180deg);
}

/* Миниатюры */
.thumbnails {
  padding: 10px 0;
  min-width: 0;
}

.thumbnails-container {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0;
  scrollbar-width: thin;
  scrollbar-color: #c1c1c1 transparent;
}

.thumbnails-container::-webkit-scrollbar {
  height: 6px;
}

.thumbnails-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.thumbnails-container::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.thumbnails-container::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.thumbnail {
  width: 120px;
  height: 80px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
  opacity: 0.4;
  background: #f5f5f5;
  /*border: 2px solid transparent;*/
}

.thumbnail:hover {
  border-color: #ddd;
  opacity: 0.8;
  transform: scale(1.05);
}

.thumbnail.active {
  opacity: 1;
  transform: scale(1.05);
  /*box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);*/
}

.thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Правая часть - информация */
.gallery-sidebar {
  flex: 0 0 35%;
  background: #f8f9fa;
  border-left: 1px solid #e5e5e5;
  overflow-y: auto;
  min-width: 0;
  max-width: 35%;
}

.sidebar-content {
  padding: 25px;
}

.sidebar-content h4 {
  margin: 0 0 20px 0;
  font-size: 18px;
  color: #2D3137;
}

.amenities-list {
  margin-bottom: 30px;
}

.amenity-item {
  padding: 10px 0;
  border-bottom: 1px solid #e5e5e5;
  color: #555;
  font-size: 14px;
  line-height: 1.4;
}

.amenity-item:last-child {
  border-bottom: none;
}

.price-block {
  background: white;
  padding: 25px;
  border-radius: 8px;
  border: 1px solid #e5e5e5;
  margin-top: 20px;
}

.price-title {
  font-size: 24px;
  font-weight: 600;
  color: #2D3137;
  margin: 0 0 8px 0;
}

.price-subtitle {
  font-size: 14px;
  color: #666;
  margin: 0 0 16px 0;
}

.price-button {
  width: 100%;
  padding: 12px;
  background: #2D3137;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.price-button:hover {
  background: #40444d;
}

/* Адаптивность */
@media (max-width: 1024px) {
  .popup-container {
    width: 98%;
    height: 98%;
    margin: 1% auto;
  }

  .popup-content {
    flex-direction: column;
  }

  .gallery-main {
    flex: 1;
    width: 100%;
    max-width: 100%;
  }

  .gallery-sidebar {
    flex: 1;
    width: 100%;
    max-width: 100%;
    border-left: none;
    border-top: 1px solid #e5e5e5;
  }

  .nav-btn-center {
    width: 44px;
    height: 44px;
  }

  /* Адаптивность для превью на планшетах */
  .gallery-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 200px 200px;
    height: 408px;
  }

  .gallery-grid-products {
    height: 408px;
  }

  .gallery-item:first-child {
    grid-row: 1 / 2;
    grid-column: 1 / 3;
  }

  .gallery-item:nth-child(2) {
    grid-row: 2 / 3;
    grid-column: 1 / 2;
  }

  .gallery-item:nth-child(3) {
    grid-row: 2 / 3;
    grid-column: 2 / 3;
  }

  .gallery-item:nth-child(4),
  .gallery-item:nth-child(5) {
    display: none;
  }
}

@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 250px;
    height: 250px;
    gap: 6px;
  }

  .gallery-grid-products {
    height: 250px;
  }

  .gallery-item:first-child {
    grid-row: 1 / 2;
    grid-column: 1 / 2;
  }

  .gallery-item:nth-child(2),
  .gallery-item:nth-child(3),
  .gallery-item:nth-child(4),
  .gallery-item:nth-child(5) {
    display: none;
  }

  .popup-header {
    padding: 15px 20px;
  }

  .gallery-main {
    padding: 15px;
  }

  .sidebar-content {
    padding: 20px;
  }

  .nav-btn-center {
    width: 40px;
    height: 40px;
    padding: 0 15px;
  }

  .nav-btn-center svg {
    width: 18px;
    height: 18px;
  }

  .thumbnail {
    width: 100px;
    height: 70px;
  }
}

/* Для очень больших экранов */
@media (min-width: 1600px) {
  .popup-container {
    max-width: 1400px;
  }

  .gallery-main {
    flex: 0 0 60%;
    max-width: 60%;
  }

  .gallery-sidebar {
    flex: 0 0 30%;
    max-width: 30%;
  }
}

/* Исправление для очень широких изображений */
@media (min-width: 1200px) {
  .gallery-slide img {
    max-width: 90%;
    max-height: 90%;
  }
}

/* Индикатор количества фото */
.gallery-indicator {
  position: absolute;
  bottom: 15px;
  left: 15px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 2;
}
