/* ---------- Базовые стили ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', Arial, sans-serif;
  background: #fff;
  color: #000;
  line-height: 1.4;
}

.hidden { display: none !important; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- Баннер скидки ---------- */
.discount-banner {
  position: sticky;
  top: 0;
  z-index: 100;                    /* выше шапки, но ниже модалки админки */
  background: #0000FF;
  color: #fff;
  text-align: center;
  font-weight: 600;
  padding: 10px 16px;
  font-size: 15px;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .08); /* лёгкая тень, чтобы «оторвать» от контента */
}

/* ---------- Шапка ---------- */
.header {
  position: sticky;
  top: 41px;
  z-index: 90;
  padding: 12px 0;
  margin-bottom: 24px;
  background: linear-gradient(to bottom, #ffffff 0%, rgba(255, 255, 255, 0) 100%);
}
.discount-banner.hidden ~ .header {
  top: 0;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
  position: relative;
  min-height: 72px;
}
.logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.logo-img {
  display: block;
  height: 52px;
  width: auto;
}

.search-form {
  display: flex;
  align-items: center;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  padding: 0 12px;
  height: 40px;
  transition: border-color .2s;
  max-width: 320px; /* Ширина на ПК */
}
.search-form:hover, .search-form:focus-within { border-color: #000; }
.search {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  padding: 8px 0;
}
.search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  margin-left: 8px;
}

@media (max-width: 900px) {
  .header-inner {
    flex-direction: column;
    justify-content: center;
    gap: 12px;
  }
  .logo {
    position: static;
    transform: none;
    order: -1;
  }
  .search-form {
    width: 100%;
    max-width: 100%;
  }

  .container {
    padding: 0 12px; /* Было 16px */
  }
}

/* =========================================
   ФИЛЬТРЫ (ДЕСКТОП)
   ========================================= */
.filters { margin-bottom: 24px; }

.mobile-filters-btn {
  display: none; /* Скрыта на десктопе, появляется только на мобильных */
}

.filters-desktop {
  width: 100%;
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.dropdown {
  position: relative;
}

.dropdown-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 0;
  font-size: 15px;
  font-weight: 500;
  color: #000;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s;
}
.dropdown-btn:hover { color: #0000FF; }
.dropdown-btn:focus { outline: none; }
.dropdown-btn:active { color: #000; }
.dropdown-btn svg { transition: transform 0.2s; }
.dropdown.active .dropdown-btn svg { transform: rotate(180deg); }

/* Выпадающее меню */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: #fff;
  border: 1px solid #eee;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  padding: 8px 0;
  min-width: 180px;
  z-index: 100;
  display: none;
}
.dropdown.active .dropdown-menu { display: block; }

/* Пункты внутри меню */
.dropdown-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
  white-space: nowrap;
}
.dropdown-menu label:hover { background: #f5f5f5; }
.dropdown-menu input[type="checkbox"],
.dropdown-menu input[type="radio"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: #000;
}

/* Дропдаун цены */
.price-dropdown {
  padding: 12px;
  display: none;
  flex-direction: column;
  gap: 12px;
  min-width: 240px;
}
.dropdown.active .price-dropdown { display: flex; }

.price-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}
.price-inputs input {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
}
.price-inputs input:focus { border-color: #000; }

.checkbox-list {
  max-height: 250px;
  overflow-y: auto;
}

/* Активные фильтры (чипсы) */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f2f2f2;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
}
.chip button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chip button svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}
.chip button:hover { color: #000; }

.found-count {
  margin-top: 12px;
  font-size: 13px;
  color: #888;
}

/* =========================================
   МОБИЛЬНЫЕ ФИЛЬТРЫ (до 900px)
   ========================================= */
@media (max-width: 900px) {
  /* Скрываем десктопную версию */
  .filters-desktop { display: none; }

  /* Кнопка открытия фильтров на мобильном */
  .mobile-filters-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 0;
    font-size: 15px;
    font-weight: 500;
    color: #000;
    cursor: pointer;
    font-family: inherit;
    margin-bottom: 16px;
    transition: color 0.15s;
  }
  .mobile-filters-btn:hover { color: #0000FF; }

  /* Оверлей на весь экран */
  .mobile-filters-overlay {
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 1000;
    display: flex;
    flex-direction: column;
  }

  .mobile-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #eee;
  }
  .mobile-filters-header h2 { margin: 0; font-size: 18px; }
  
  .close-mobile-filters {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
  }

  .mobile-filters-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
  }

  /* Внутри мобильного меню дропдауны превращаются в списки */
  .mobile-filters-content .filters-row {
    flex-direction: column;
    align-items: stretch;
    gap: 24px;
  }

  .mobile-filters-content .dropdown { width: 100%; }

  /* Заголовок категории в мобильном меню (не кнопка) */
  .mobile-filters-content .dropdown-btn {
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    justify-content: flex-start;
    padding-bottom: 8px;
    display: flex;
    color: #000;
    cursor: default;
  }

  /* Убираем синий цвет при тапе на мобильных */
  .mobile-filters-content .dropdown-btn:hover,
  .mobile-filters-content .dropdown-btn:active,
  .mobile-filters-content .dropdown-btn:focus {
    color: #000;
  }

  /* Скрываем стрелочку в мобильном меню */
  .mobile-filters-content .dropdown-btn svg { display: none; }

  /* Принудительно показываем списки в мобильном меню */
  .mobile-filters-content .dropdown-menu {
    position: static !important;
    display: block !important;
    box-shadow: none;
    border: none;
    padding: 12px 0 0;
    margin-top: 0;
    background: transparent;
  }

  /* Футер с кнопкой "Показать товары" */
  .mobile-filters-footer {
    padding: 16px;
    border-top: 1px solid #eee;
    background: #fff;
  }
  .btn-apply-mobile {
    width: 100%;
    background: #000;
    color: #fff;
    border: 1px solid #000;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    border-radius: 0;
    transition: opacity 0.2s;
  }
  .btn-apply-mobile:hover {
    background-color: #0000FF; 
    border-color: #0000FF;
  }
}

/* =========================================
   СЕТКА ТОВАРОВ
   ========================================= */
.products-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 40px;
}
@media (max-width: 900px) {
  .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

/* =========================================
   КАРТОЧКА ТОВАРА
   ========================================= */
.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

.card-image {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #f5f5f5;
}
.card-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
}
.card-image img.second { opacity: 0; }
.card-image.has-second:hover img.first { opacity: 0; }
.card-image.has-second:hover img.second { opacity: 1; }
.card-image .placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 13px;
}

.card-title-link {
  display: block;
  text-decoration: none;
  color: inherit;
  width: 100%;
  min-width: 0;
}

.card-body {
  text-align: center;
  padding: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.card-title {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  font-size: 14px;
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-price {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}
.price-old {
  color: #888;
  text-decoration: line-through;
  font-weight: 400;
  font-size: 14px;
}
.price-new { color: #000; }

.card .btn-order {
  margin-top: 4px;
  background: #000;
  color: #fff;
  border: 1px solid #000;
  padding: 10px 16px;
  border-radius: 0px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}
.card .btn-order:hover {
  opacity: 1;
  background-color: #0000FF; 
  border-color: #0000FF;
}

/* ---------- Пустое состояние ---------- */
.empty-state {
  text-align: center;
  padding: 60px 16px;
  color: #888;
  font-size: 15px;
}

/* ---------- Страница товара ---------- */
.product-page {
  display: grid;
  grid-template-columns: 1fr 1fr;   /* две равные части */
  gap: 40px;
  margin: 24px auto 60px;
  align-items: start;
}
@media (max-width: 900px) {
  .product-page {
    grid-template-columns: 1fr;     /* на мобиле — одна колонка */
    gap: 24px;
  }
}

/* Левая колонка: галерея */
.product-gallery { min-width: 0; }

.main-image {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;              /* та же пропорция, что и в карточках */
  background: #f5f5f5;
  overflow: hidden;
  border-radius: 0;                  /* без скруглений, как ты просил для карточек */
}
.main-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.main-image .placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 14px;
}

/* Миниатюры под большой картинкой — 5 в ряд */
.thumbs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  background: #f0f0f0;
  cursor: pointer;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color .15s, opacity .15s;
}
.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb:hover { opacity: .85; }
.thumb.active { border-color: #000; }

/* Правая колонка: информация */
.product-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.back-link {
  font-size: 14px;
  color: #888;
  text-decoration: none;
  transition: color .15s;
}
.back-link:hover { color: #000; }

.product-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0;
  line-height: 1.25;
}

.product-price {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 22px;
  font-weight: 700;
}
.product-price .price-old {
  color: #888;
  text-decoration: line-through;
  font-weight: 400;
  font-size: 18px;
}
.product-price .price-new { color: #000; }

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.meta-badge {
  display: inline-block;
  padding: 6px 10px;
  background: #f2f2f2;
  border-radius: 999px;
  font-size: 13px;
  color: #444;
}

.product-description {
  font-size: 15px;
  line-height: 1.55;
  color: #333;
  white-space: pre-wrap;              /* сохраняем переносы строк из описания */
}
.product-description:empty { display: none; }

/* Кнопка "Заказать" на странице товара */
.btn-order-large {
  margin-top: auto;                    /* прижимаем к низу правой колонки */
  display: inline-block;
  background: #000;
  color: #fff;
  border: 1px solid #000;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}
.btn-order-large:hover { 
  opacity: 1; 
  background-color: #0000FF; 
  border-color: #0000FF;
}
.social-links {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-right: auto; 
}
.social-img {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
}
@media (max-width: 900px) {
  .social-links { 
    display: none;
  }
}

.product-details p { margin: 0 0 8px; font-size: 15px; color: #333; line-height: 1.5; }
.product-details strong { color: #000; font-weight: 600; }

/* ---------- Попап выбора мессенджера ---------- */
.order-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.order-popup-overlay.active {
  opacity: 1;
  visibility: visible;
}
.order-popup {
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  transform: translateY(20px);
  transition: transform 0.3s;
}
.order-popup-overlay.active .order-popup {
  transform: translateY(0);
}
.order-popup h3 {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 600;
}
.order-popup-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
}
.order-popup-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #f5f5f5;
  transition: background 0.2s, transform 0.2s;
}
.order-popup-btn:hover {
  background: #e0e0e0;
  transform: scale(1.05);
}
.order-popup-btn img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}