.sale-section {
  padding: 60px;
  width: 100%;
  box-sizing: border-box;
}
#product-grid {
  color: white;
  font-size: 100px;
}

/* Стиль select — белый текст и фон при наведении */
.filter-group select,
#filter-subtype {
  color: white;
  background-color: #333;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 1rem;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

/* При наведении на select */
.filter-group select:hover,
#filter-subtype:hover {
  background-color: #dfbf97;
  color: #222;
  cursor: pointer;
}

/* Стиль option — работает только в некоторых браузерах */
.filter-group select option,
#filter-subtype option {
  background-color: #222;
  color: white;
}

/* Выбранный элемент */
.filter-group select:focus,
#filter-subtype:focus {
  outline: none;
  box-shadow: 0 0 8px #dfbf97;
  background-color: #dfbf97;
  color: #222;
}

.filters-container {
  background: #222;
  padding: 20px 25px;
  border-radius: 12px;
  max-width: 900px;
  margin: 0 auto 40px auto;
  color: white;
  font-family: "Josefin Sans", sans-serif;
  box-sizing: border-box;
  box-shadow: 0 0 15px rgb(223 191 151 / 0.3);
  text-align: center; /* Центрирование содержимого */
}

.filters-container label {
  font-weight: 600;
  font-size: 1rem;
  display: block;
  margin-bottom: 6px;
  color: #dfbf97;
  user-select: none;
}

.filter-group {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center; /* Центрирование группы */
  gap: 12px;
}

.filter-group input[type="number"],
.filter-group select {
  background: #333;
  border: none;
  border-radius: 8px;
  color: white;
  padding: 10px 14px;
  font-size: 1rem;
  box-shadow: inset 0 0 5px #000;
  transition: background 0.3s ease, box-shadow 0.3s ease;
  min-width: 100px;
}

.filter-group input[type="number"]:focus,
.filter-group select:focus {
  background: #444;
  outline: none;
  box-shadow: 0 0 8px #dfbf97;
}

.filter-group label.inline {
  margin-right: 8px;
  font-weight: 400;
  color: #fff;
}

/* Кнопка "Применить фильтры" */
#apply-filters {
  background: #dfbf97;
  color: #222;
  font-weight: 700;
  border: none;
  border-radius: 25px;
  padding: 12px 32px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background-color 0.3s ease;
  user-select: none;
  align-self: flex-start;
  box-shadow: 0 4px 8px rgb(223 191 151 / 0.5);
}

#apply-filters:hover {
  background: #c0a765;
  color: #fff;
  box-shadow: 0 6px 12px rgb(223 191 151 / 0.7);
}

/* Контейнер подтипов */
#subtype-container {
  display: none;
  flex-direction: column;
}

/* Начальное состояние — скрыт */
.filters-container.hidden {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.7s ease, max-height 0.7s ease, padding 0.7s ease, margin 0.7s ease;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
}

.filters-container.visible {
  opacity: 1;
  max-height: 1000px;
  transition: opacity 0.7s ease, max-height 0.7s ease, padding 0.7s ease, margin 0.7s ease;
  padding-top: 20px;
  padding-bottom: 20px;
  margin-bottom: 40px;
}

/* Кнопка "Фильтр" */
#toggle-filters {
  display: block;
  margin: 30px auto 20px auto;
  background: #dfbf97;
  color: #222;
  font-weight: 700;
  border: none;
  border-radius: 25px;
  padding: 12px 32px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background-color 0.3s ease;
  box-shadow: 0 4px 8px rgb(223 191 151 / 0.5);
}

.form-control {
  color: White !important;
}

#toggle-filters:hover {
  background: #c0a765;
  color: #fff;
  box-shadow: 0 6px 12px rgb(223 191 151 / 0.7);
}

/* Мобильная адаптация */
@media (max-width: 720px) {
  .filters-container {
    padding: 15px 20px;
  }
  .filter-group {
    flex-direction: column;
    align-items: stretch;
  }
  #apply-filters {
    width: 100%;
    padding: 14px 0;
    font-size: 1.2rem;
  }
}

.categories-container {
  max-width: 1600px;
  margin: 0 auto;
}

.sale-title {
  font-size: 48px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 60px;
  text-transform: uppercase;
  color: white;
}

/* Базовая сетка: карточки адаптивные */
.categories-grid {
  justify-content: center;
  align-content: center; /* вертикальное центрирование */
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 35px 40px; /* Горизонтальный gap установлен в 40px */
  align-items: start;
}

.sale-card-wrapper {
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  width: 100%;
}

#card-big-wrapper {
  grid-column: span 2;
  width: 100%;
}

.sale-card {
  position: relative;
  border-radius: 15%;
  overflow: hidden;
  margin: 0 auto;
  width: 100%;
  aspect-ratio: 1/1;
  box-sizing: border-box;
}

#card-big {
  border: solid #FFD700;
  border-radius: 5% !important;
  width: 100%;
  aspect-ratio: 2/1;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.5s ease;
  box-sizing: border-box;
}

.card-image:hover {
  opacity: 30%;
}

.card-label {
  color: #ffffff;
  display: block;
  width: 100%;
  text-align: center;
  font-size: 20px;
  font-weight: 500;
  margin-top: 15px;
  padding: 0 10px;
  box-sizing: border-box;
}

#ad {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  width: 100%;
  height: 100%;
  background-color: #666666;
  color: white;
  font-size: 60px;
}

/* Большие экраны */
@media (max-width: 1520px) {
  .categories-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }

  #card-big-wrapper {
    grid-column: span 2;
  }
}

/* Средние экраны */
@media (max-width: 1200px) {
  .categories-grid {
    gap: 60px 40px; /* Изменено с 30px на 40px */
  }

  #ad {
    font-size: 48px;
  }
}

/* Мобильная версия от 800px и ниже — 2 карточки */
@media (max-width: 799px) and (min-width: 100px) {
  .sale-section {
    padding: 30px 15px;
  }

  .sale-title {
    font-size: 32px;
    margin-bottom: 30px;
  }

  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 30px 20px; /* Добавлен горизонтальный gap 40px */
    max-width: none;
  }

  #card-big-wrapper {
    grid-column: span 2;
  }

  #card-big {
    aspect-ratio: 2/1;
  }

  #ad {
    font-size: 32px;
  }

  .card-label {
    font-size: 16px;
    margin-top: 10px;
  }
}

@media (max-width: 315px) {
  .categories-grid {
    grid-template-columns: 1fr !important;
    gap: 25px 40px !important; /* Добавлен горизонтальный gap 40px */
  }

  #card-big-wrapper {
    grid-column: 1 !important;
  }

  #card-big {
    aspect-ratio: 1.5/1;
  }
}



.interactive-card {
  cursor: pointer;
  position: relative;
}

@media (min-width: 1359px) {
  #choose-container {
    max-width: 1020px;
  }
}

/* убрать старые жёсткие max-ограничения — пусть базовые правила управляют размерами */
.sale-card {
  max-width: 520px !important;
  max-height: 520px !important;
  box-sizing: border-box;
}
.card-image {
  max-width: 520px !important;
  max-height: 520px !important;
  box-sizing: border-box;
}

/* Для категорий с разным количеством колонок */
@media (min-width: 1200px) {
  .categories-grid.two-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .categories-grid.three-cols {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .categories-grid.four-cols {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}

/* --- Исправленные медиазапросы: управление числом колонок и корректная ширина 220px >=1601px --- */
@media (min-width: 1601px) {
  .categories-grid {
    grid-template-columns: repeat(5, 1fr) !important;
    justify-content: center;
    gap: 45px 50px !important;
    align-items: start;
  }

  .categories-grid.two-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .categories-grid.three-cols {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .categories-grid.four-cols {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}

/* 4 карточки в ряд для экранов 998px — 1600px */
@media (min-width: 998px) and (max-width: 1600px) {
  .categories-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 45px 50px !important;
    align-items: start;
  }

  .categories-grid.two-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .categories-grid.three-cols {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .categories-grid.four-cols {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}

/* 3 карточки в ряд для экранов 800px — 997px */
@media (min-width: 800px) and (max-width: 997px) {
  .categories-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 40px 45px !important;
    align-items: start;
  }

  .categories-grid.two-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .categories-grid.three-cols {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .categories-grid.four-cols {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

/* --- Увеличенные размеры карточек для всех кроме 2-cols --- */
@media (min-width: 998px) {
  .sale-card {
    max-width: 1400px !important;
    max-height: 1400px !important;
  }
  .card-image {
    max-width: 1400px !important;
    max-height: 1400px !important;
    object-fit: cover;
  }

  /* оставляем 2 в ряд без изменений */
  .categories-grid.two-cols .sale-card,
  .categories-grid.two-cols .card-image {
    max-width: 1800px !important;
    max-height: 1800px !important;
  }

  /* увеличенные размеры для 3 в ряд */
  .categories-grid.three-cols .sale-card,
  .categories-grid.three-cols .card-image {
    max-width: 1600px !important;
    max-height: 1600px !important;
  }

  /* увеличенные размеры для 4 в ряд */
  .categories-grid.four-cols .sale-card,
  .categories-grid.four-cols .card-image {
    max-width: 1500px !important;
    max-height: 1500px !important;
  }

  .sale-title {
    font-size: 56px;
  }
  .categories-grid {
    align-items: start;
  }
}
