.sale-section {
  padding: 60px;
  width: 100%;
  box-sizing: border-box;
}
#product-grid {
  color: white;
  font-size: 1rem;
}

/* ── FILTERS ── */
.filters-container {
  background: #1e1e1e;
  padding: 20px 24px;
  border-radius: 14px;
  max-width: 860px;
  margin: 0 auto 32px auto;
  color: white;
  font-family: "Josefin Sans", sans-serif;
  box-sizing: border-box;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4), 0 0 0 1px rgba(223,191,151,0.08);
}
[data-theme="light"] .filters-container {
  background: #f0ece6;
  border: 1px solid rgba(0,0,0,0.09);
  box-shadow: 0 4px 24px rgba(0,0,0,0.07);
  color: #1a1a1a;
}

.filter-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}
.filter-group:last-of-type { margin-bottom: 0; }

.filters-container label,
.filter-group label {
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #dfbf97;
  user-select: none;
  white-space: nowrap;
}
[data-theme="light"] .filters-container label,
[data-theme="light"] .filter-group label { color: #c9a36a; }

.filter-group .inline-label,
.filter-group label.inline {
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  color: #aaa;
  font-weight: 400;
}
[data-theme="light"] .filter-group .inline-label,
[data-theme="light"] .filter-group label.inline { color: #777; }

.filter-group input[type="number"],
.filter-group select,
#filter-subtype {
  background: #2a2a2a;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #e0e0e0;
  padding: 8px 12px;
  font-size: 0.92rem;
  font-family: "Josefin Sans", sans-serif;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 90px;
  box-shadow: none;
}
[data-theme="light"] .filter-group input[type="number"],
[data-theme="light"] .filter-group select,
[data-theme="light"] #filter-subtype {
  background: #e8e4de;
  border-color: rgba(0,0,0,0.12);
  color: #1a1a1a;
}

.filter-group input[type="number"]:focus,
.filter-group select:focus,
#filter-subtype:focus {
  border-color: rgba(223,191,151,0.6);
  box-shadow: 0 0 0 3px rgba(223,191,151,0.12);
  background: #333;
}
[data-theme="light"] .filter-group input[type="number"]:focus,
[data-theme="light"] .filter-group select:focus,
[data-theme="light"] #filter-subtype:focus {
  background: #fff;
  box-shadow: 0 0 0 3px rgba(201,163,106,0.15);
}

.filter-group select:hover,
#filter-subtype:hover { border-color: rgba(223,191,151,0.4); cursor: pointer; }

.filter-group select option,
#filter-subtype option { background: #222; color: white; }
[data-theme="light"] .filter-group select option,
[data-theme="light"] #filter-subtype option { background: #fff; color: #1a1a1a; }

/* Кнопка Применить */
#apply-filters {
  background: #dfbf97;
  color: #1a1a1a;
  font-weight: 700;
  font-family: "Josefin Sans", sans-serif;
  border: none;
  border-radius: 25px;
  padding: 10px 28px;
  cursor: pointer;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
  box-shadow: 0 3px 10px rgba(223,191,151,0.3);
  margin-top: 4px;
}
#apply-filters:hover {
  background: #c9a36a;
  color: #fff;
  box-shadow: 0 5px 16px rgba(223,191,151,0.45);
  transform: translateY(-1px);
}

/* Контейнер подтипов */
#subtype-container { display: none; flex-direction: column; }

/* Анимация показа/скрытия */
.filters-container.hidden {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.5s ease, max-height 0.5s ease, padding 0.5s ease, margin 0.5s ease;
  padding-top: 0; padding-bottom: 0; margin-bottom: 0;
}
.filters-container.visible {
  opacity: 1;
  max-height: 600px;
  transition: opacity 0.5s ease, max-height 0.5s ease, padding 0.5s ease, margin 0.5s ease;
  padding-top: 20px; padding-bottom: 20px; margin-bottom: 32px;
}

/* Кнопка Фильтр */
#toggle-filters {
  display: block;
  margin: 28px auto 18px auto;
  background: transparent;
  color: #dfbf97;
  font-weight: 700;
  font-family: "Josefin Sans", sans-serif;
  border: 1px solid rgba(223,191,151,0.4);
  border-radius: 25px;
  padding: 10px 28px;
  cursor: pointer;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
#toggle-filters:hover {
  background: #dfbf97;
  color: #1a1a1a;
  border-color: #dfbf97;
  box-shadow: 0 4px 14px rgba(223,191,151,0.3);
}
[data-theme="light"] #toggle-filters { color: #c9a36a; border-color: rgba(201,163,106,0.4); }
[data-theme="light"] #toggle-filters:hover { background: #c9a36a; color: #fff; border-color: #c9a36a; }

.form-control { color: white !important; }
[data-theme="light"] .form-control { color: #1a1a1a !important; background: #e8e4de !important; }

/* Строка цены */
.filter-price-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.filter-num-input {
  width: 90px !important;
  min-width: unset !important;
  text-align: center;
}

/* Мобильная адаптация */
@media (max-width: 720px) {
  .filters-container { padding: 16px; }
  .filter-group { flex-direction: column; align-items: center; }
  .filter-price-row { justify-content: center; }
  .filter-num-input { width: 80px !important; }
  #apply-filters { width: 100%; padding: 13px 0; font-size: 1rem; }
}

.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: var(--ml-text, white);
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  justify-content: center;
  gap: 32px 20px;
  align-items: start;
}

.sale-card-wrapper {
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  width: 100%;
  align-self: start;
  min-width: 0; /* prevent grid blowout */
  overflow: hidden; /* prevent content from expanding cell */
}

#card-big-wrapper {
  grid-column: span 2;
  width: 100%;
  min-width: 0;
}

.sale-card {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  margin: 0 auto;
  width: 100%;
  aspect-ratio: 1/1;
  background: transparent;
}

#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;
}

.card-image:hover {
  opacity: 30%;
}

/* Fix: <a> inside .sale-card defaults to display:inline which adds baseline gap */
.sale-card a.spa-link {
  display: block;
  width: 100%;
  height: 100%;
  line-height: 0;
}

.sale-card .card-image {
  display: block;
  vertical-align: top;
}

.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;
}



/* Большие экраны */
@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 30px;
  }


}

/* Мобильная версия — 2 карточки */
@media (max-width: 799px) and (min-width: 100px) {
  .sale-section {
    padding: 20px 12px;
  }
  .sale-title {
    font-size: 28px;
    margin-bottom: 20px;
  }
  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    max-width: none;
    align-items: start;
  }
  #card-big-wrapper {
    grid-column: span 2;
    min-width: 0;
    overflow: hidden;
  }
  /* Ensure carousel doesn't expand grid column width */
  #card-big-wrapper .carousel,
  #card-big-wrapper .carousel-inner,
  #card-big-wrapper .carousel-item {
    width: 100%;
    min-width: 0;
  }
  #card-big {
    aspect-ratio: 2/1;
  }
  .sale-card-wrapper {
    align-self: start;
    min-width: 0;
    overflow: hidden;
  }
  .card-label {
    font-size: 13px;
    margin-top: 6px;
    min-height: 2.2em;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    line-height: 1.1;
  }
  /* Product card label inside image (home/choose pages) */
  .sale-card .card-label {
    font-size: 12px !important;
    bottom: 8px;
    padding: 0 6px 6px;
  }
  /* Product list labels (outside image) */
  #product-grid .card-label {
    font-size: 12px !important;
  }
  #product-grid .price-new,
  #product-grid .price-regular {
    font-size: 1rem !important;
  }
  #product-grid .price-old {
    font-size: 0.8rem !important;
  }
  #product-grid .discount-badge {
    font-size: 0.7rem !important;
    padding: 1px 4px;
  }
}


@media (max-width: 315px) {
  .categories-grid {
    grid-template-columns: 1fr !important;
    gap: 25px !important;
  }

  #card-big-wrapper {
    grid-column: 1 !important;
  }

  #card-big {
    aspect-ratio: 1.5/1;
  }
}



/* Футер */
.footer {
  background: #000;
  color: #fff;
  padding: 40px 20px;
}

.footer a {
  color: #d4af7f;
}

.footer .container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0px;
  max-width: 1200px;
  margin: 0 auto;
  align-items: start;
}

.footer .logo {
  font-size: 48px;
  font-weight: bold;
  text-align: center;
  color: #d4af7f;
  font-family: kapakana, sans-serif;
}

.footer h4 {
  margin-bottom: 12px;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #fff;
}

.footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer ul li {
  margin-bottom: 8px;
}

.footer .social {
  display: flex;
  gap: 12px;
}

.footer .social a {
  font-size: 20px;
  color: #fff;
}

.footer .bottom {
  grid-column: 1 / -1;
  text-align: center;
  margin-top: 30px;
  font-size: 14px;
  color: #ccc;
}

/* Map container */
.footer .map-container {
  width: 100%;
  overflow: hidden;
  border-radius: 8px;
  max-height: 125px;
}

.footer .map-container iframe {
  width: 100%;
  height: 100%;
  border: 0;
  filter: grayscale(100%) brightness(0.6) contrast(1.2);
}

/* Tablet */
@media (max-width: 1024px) {
  .footer .container {
    grid-template-columns: repeat(2, 1fr);
    text-align: center;
  }
  .footer .factory,
  .footer .social-container,
  .footer .map {
    justify-self: center;
  }
  .footer .map-container {
    height: 250px;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .footer .container {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .footer .logo {
    margin-bottom: 20px;
  }
  .footer .map-container {
    height: 200px;
  }
}

.interactive-card {
  cursor: pointer;
  position: relative;
}

/* Добавляем в CSS */
.big-card {
  border: solid #FFD700;
  border-radius: 5% !important;
  width: 100%;
  aspect-ratio: 2/1;
}

.sale-card .card-label {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  text-align: center;
  color: white;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}

/* Адаптивные стили */
@media (max-width: 1200px) {
  .sale-card .card-label {
    font-size: 20px;
  }
}

@media (max-width: 799px) and (min-width: 100px) {
  .big-card {
    aspect-ratio: 2/1;
  }
  .sale-card .card-label {
    font-size: 18px;
  }
}

@media (max-width: 315px) {
  .big-card {
    aspect-ratio: 1.5/1;
  }
  .sale-card .card-label {
    font-size: 16px;
  }
}

/* Удаляем старый стиль #ad */
#ad {
  display: none;
}
.price-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* Центровка по горизонтали */
  width: 100%;
  text-align: center;
}

.price-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
}

.price-new {
  font-size: 1.6rem;
  font-weight: bold;
  color: #ff4040;
}

.price-old {
  font-size: 1.3rem;
  text-decoration: line-through;
  color: #999;
  font-weight: bold;
  margin-top: 4px;
}

.discount-badge {
  background: #dfbf97;
  color: #222;
  padding: 2px 6px;
  border-radius: 12px;
  font-weight: bold;
  font-size: 0.8rem;
}

.price-regular {
  font-size: 1.6rem;
  font-weight: bold;
  text-align: center;
  display: block;
  width: 100%;
}


@media (max-width: 400px) {
  .categories-grid {
    gap: 8px !important;
    grid-template-columns: repeat(2, 1fr) !important;
  }
  #product-grid .card-label h5 {
    font-size: 11px !important;
  }
}

@media (max-width: 316px) {
  .categories-grid {
    gap: 6px !important;
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 470px) {
    .price-new{
    font-size: 1.2rem;
}

.price-regular{
    font-size: 1.2rem;
}

.price-old {
    font-size: 0.8rem;
}
}








.pwa-modal {
  display: none;       /* изначально скрыто */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.pwa-modal .modal-content {
  background: #222;
  color: white;
  padding: 30px;
  border-radius: 12px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  box-shadow: 0 0 20px rgb(223 191 151 / 0.5);
}

.pwa-modal .close-modal {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  color: #fff;
}

.pwa-modal button {
  margin-top: 20px;
  background: #dfbf97;
  color: #222;
  border: none;
  border-radius: 25px;
  padding: 12px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 8px rgb(223 191 151 / 0.5);
  transition: all 0.3s ease;
}

.pwa-modal button:hover {
  background: #c0a765;
  color: #fff;
  box-shadow: 0 6px 12px rgb(223 191 151 / 0.7);
}




/* ================================
   Обрезка длинных названий товаров
   (multiline ellipsis, адаптивно)
   ================================ */

.sale-card .card-label {
  display: -webkit-box;            /* WebKit-based browsers (Chrome, Safari) */
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;          /* максимум строк на больших экранах */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;             /* позволяем перенос слов внутри box */
  line-height: 1.2;               /* контролирует высоту строки для точного расчёта */
  max-height: calc(1.2em * 3);    /* ограничение по высоте на случай несовместимости */
  padding: 0 12px 12px;           /* немного отступа внутри, чтобы не прилипало */
  box-sizing: border-box;
  /* сохраняем абсолютное позиционирование (как у тебя) */
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  color: #ffffff;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}

/* Мобильные экраны — 2 строки */
@media (max-width: 799px) {
  .sale-card .card-label {
    -webkit-line-clamp: 2;
    max-height: calc(1.2em * 2);
    font-size: 16px;
    padding-bottom: 10px;
  }
}

/* Очень маленькие экраны — чуть поменьше текст */
@media (max-width: 315px) {
  .sale-card .card-label {
    -webkit-line-clamp: 2;
    max-height: calc(1.2em * 2);
    font-size: 14px;
    padding-bottom: 8px;
  }
}

/* Фолбек для браузеров без -webkit-line-clamp:
   делает ограничение по высоте и обрезает текст — без многоточия на нескольких строках,
   но гарантирует, что дизайн не сломается.
*/
.sale-card .card-label {
  /* если браузер не понимает -webkit-line-clamp, сохраняем ключевые свойства */
  overflow: hidden;
  max-height: 3.6em; /* 1.2em * 3 (поддержка старых движков) */
}


/* ============================================================
   УЛУЧШЕНИЯ ДИЗАЙНА (безопасные)
   ============================================================ */

/* Карточки: плавное поднятие при наведении */
.sale-card-wrapper {
  transition: transform 0.22s ease;
}
.sale-card-wrapper:hover {
  transform: translateY(-5px);
}

/* Карточки — скруглённые углы + тень */
.sale-card {
  border-radius: 22px !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
  transition: box-shadow 0.22s ease;
  background: transparent !important;
}
.sale-card-wrapper:hover .sale-card {
  box-shadow: 0 8px 28px rgba(223,191,151,0.2), 0 2px 12px rgba(0,0,0,0.5);
}

/* Изображение */
.card-image {
  transition: transform 0.3s ease !important;
  opacity: 1 !important;
}
.sale-card-wrapper:hover .card-image {
  transform: scale(1.04);
  opacity: 1 !important;
}

/* Out-of-stock */
.out-of-stock .sale-card { opacity: 0.5; }
.out-of-stock .card-label { color: #777 !important; }

/* Product-grid card label: below image, bigger text + ellipsis */
#product-grid .card-label { padding: 0px 6px 0; }
#product-grid .card-label h5 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 4px;
  color: var(--ml-text, #fff);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  white-space: normal;
}
#product-grid .card-label .price-block,
#product-grid .card-label .price-regular { margin-top: 2px; }
#page-home .sale-card,
#page-choose .sale-card {
  background: transparent !important;
  overflow: hidden;
  border-radius: 22px !important;
}
#page-home .sale-card .card-image,
#page-choose .sale-card .card-image {
  border-radius: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
[data-theme="light"] #page-home .sale-card,
[data-theme="light"] #page-choose .sale-card { background: #e8e4de !important; }

/* ── RELATED PRODUCTS SECTION ── */
.related-section {
  padding: 0 0 40px;
}
.related-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--ml-text, #fff);
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}
.related-card-wrapper {
  cursor: pointer;
}
.related-card-wrapper a {
  text-decoration: none !important;
}
.related-label {
  margin-top: 8px;
  padding: 0 4px;
}
.related-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ml-text, #fff);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  margin-bottom: 4px;
  text-align: center;
}
.related-label .price-regular {
  font-size: 14px;
  font-weight: 700;
  color: var(--ml-text, #fff);
}
.related-label .price-new {
  font-size: 14px;
  font-weight: 700;
  color: #ff4040;
}
.related-label .price-old {
  font-size: 12px;
  text-decoration: line-through;
  color: #888;
}
.related-label .discount-badge {
  font-size: 11px;
  padding: 1px 5px;
}
[data-theme="light"] .related-name { color: #1a1a1a; }

@media (max-width: 900px) {
  .related-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
}
@media (max-width: 520px) {
  .related-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .related-title { font-size: 18px; }
}