/* ===== base ===== */
body {
  color: var(--text);
  font-family: var(--font-primary);
}

.products-page {
  max-width: 1579px;
  padding: 0 12px 32px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  flex-direction: column;
  align-content: center;
}

.page-title {
  margin: 12px 0 16px;
  font-size: clamp(20px, 2.4vw, 32px);
  text-align: left; /* <-- всегда по центру */
}

.products-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

/* ===== filters (desktop/tablet defaults) ===== */
.filters-box { min-width: 220px; }
.filters-box form { display: block; }

.filters-box ul,
.filters-box ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: block;
}

.filters-box li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px 0;
}

.filters-box label {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.filters-box input[type="checkbox"] { margin: 0; vertical-align: middle; }
.filters-box .btn,
.filters-box button,
.filters-box input[type="submit"] { flex: 0 0 auto; }

/* ===== grid ===== */
.product-list {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(260px, 1fr));
  gap: 16px;
  padding: 12px 0;
}

/* ===== card ===== */
.product-card {
  width: 100%;
  max-width: 272px;
  min-height: 436px;
  background: #fff;
  color: #000;
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.1);
  padding: 14px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  transition: transform .2s ease;
  font-family: var(--font-primary);
}

.product-card:hover { transform: translateY(-5px); }

.product-card img.product-img {
  width: 9rem;
  height: 9rem;
  object-fit: contain;
  margin: 0 0 18px;
}

.product-title {
  font-size: 1rem;
  font-weight: 400;
  color: #333;
  margin: 0 0 8px;
  width: 100%;
  min-height: 2.6em;
  display: block;
  word-wrap: break-word;
}

.product-price {
  font-size: 1.15em;
  font-weight: 700;
  color: #111;
  margin: 0 0 10px;
  width: 100%;
}

.product-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  align-items: center;
}

/* ===== buttons ===== */
.buy-btn,
.buy-btn:link,
.buy-btn:visited {
  font-family: var(--font-primary);
  color:#fff;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width: 220px;
  height: 56px;
  margin: 0 auto;
  border:0;
  background-image:url('/static/media/greenbutton.svg');
  background-repeat:no-repeat;
  background-position:center;
  background-size:contain;
  font-size: 1em;
  font-weight: 700;
  cursor:pointer;
  transition: filter .15s ease, transform .15s ease;
  flex-shrink: 0;
}
.buy-btn:hover { filter: brightness(.95); transform: scale(1.02); }
.buy-btn:active { transform: scale(.98); }

.more-btn,
.more-btn:link,
.more-btn:visited {
  font-family: var(--font-primary);
  color:#fff;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width: 220px;
  height: 56px;
  margin: 0 auto;
  border:0;
  background-image:url('/static/media/bluebutton.svg');
  background-repeat:no-repeat;
  background-position:center;
  background-size:contain;
  font-size: 1em;
  font-weight: 700;
  cursor:pointer;
  transition: filter .15s ease, transform .15s ease;
  flex-shrink: 0;
}
.more-btn:hover { filter: brightness(.95); transform: scale(1.02); }
.more-btn:active { transform: scale(.98); }

.load-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 220px;
  height: 56px;
  margin: 24px auto 0;
  padding: 0;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  background-image: url('/static/media/morebutton.svg');
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  cursor: pointer;
  transition: filter .15s ease, transform .15s ease;
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.load-more:hover  { filter: brightness(.95); transform: scale(1.02); }
.load-more:active { transform: scale(.98); }

/* ===== breakpoints ===== */
@media (max-width: 1200px) {
  .product-list { grid-template-columns: repeat(3, minmax(220px,1fr)); }
}

@media (max-width: 1000px) {
  .products-layout { flex-direction: column; gap: 16px; }

  .filters-box {
    min-width: initial;
    width: 100%;
    order: -1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 2px;
  }
  .filters-box ul,
  .filters-box ol { display: flex; flex-wrap: nowrap; gap: 12px; }
  .filters-box li { flex: 0 0 auto; margin: 0; }

  .product-list {
    grid-template-columns: repeat(2, minmax(160px,1fr));
    gap: 12px;
  }

  .product-card { max-width: none; min-height: 400px; padding: 12px; }
  .product-card img.product-img { width: 6.5rem; height: 6.5rem; margin-bottom: 12px; }

  .buy-btn, .more-btn { width: 180px; height: 48px; font-size: 0.9em; }
  .load-more { width: 200px; height: 52px; }
}

@media (max-width: 768px) {
  .products-page { padding: 0 8px 24px; }

  .product-list { grid-template-columns: repeat(2, minmax(140px, 1fr)); gap: 10px; }
  .product-card { min-height: 380px; padding: 10px; }
  .product-card img.product-img { width: 5.5rem; height: 5.5rem; margin-bottom: 10px; }
  .product-title { font-size: 0.9rem; margin: 0 0 6px; }
  .product-price { font-size: 1em; margin: 0 0 8px; }

  .product-actions { gap: 8px; width: 100%; }
  .buy-btn, .more-btn { width: 100%; max-width: 160px; height: 44px; font-size: 0.85em; margin: 0 auto; }
  .load-more { width: 180px; height: 48px; font-size: 0.9rem; }
}

@media (max-width: 480px) {
  .product-list { grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 8px; }
  .product-card { min-height: 360px; padding: 8px; }
  .product-card img.product-img { width: 5rem; height: 5rem; margin-bottom: 8px; }
  .product-title { font-size: 0.85rem; min-height: 2.8em; }
  .product-price { font-size: 0.95em; }
  .product-actions { gap: 6px; }
  .buy-btn, .more-btn { max-width: 140px; height: 40px; font-size: 0.8em; }
  .load-more { width: 160px; height: 44px; font-size: 0.85rem; }
}

@media (max-width: 360px) {
  .product-list { grid-template-columns: 1fr; gap: 10px; }
  .product-card { min-height: 340px; max-width: 280px; margin: 0 auto; }
  .buy-btn, .more-btn { max-width: 150px; height: 42px; }
  .load-more { width: 150px; height: 42px; }
}

@media (max-width: 320px) {
  .products-page { padding: 0 6px 20px; }
  .product-list { grid-template-columns: 1fr; }
  .product-card { min-height: 330px; padding: 6px; }
  .buy-btn, .more-btn { max-width: 130px; height: 38px; font-size: 0.75em; }
  .load-more { width: 140px; height: 40px; font-size: 0.8rem; }
}

/* ===== Pixel 7a (≤430px): правки + логика фильтров ===== */
@media (max-width: 430px){
  .products-page,
  .products-layout,
  .product-list,
  .filters-box { min-width: 0 !important; overflow-x: hidden !important; }

  .page-title {  text-align: center; margin: 10px 0 8px !important; font-size: 20px !important; }

  .products-layout { flex-direction: column !important; gap: 10px !important; align-items: stretch !important; }

  /* По умолчанию на мобиле делаем вертикальный стек... */
  .filters-box{
    width: 100% !important;
    order: -1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 4px !important;
  }
  .filters-box ul,
  .filters-box ol{
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 0 !important;
  }
  .filters-box li{ width: auto !important; margin: 0 !important; }
  .filters-box label{ white-space: normal !important; justify-content: center !important; }

  /* ...НО, если это фильтр БРЕНДОВ (компрессоры) — кладём в СТРОКУ с прокруткой */
  .filters-box .brand-filter,
  .brand-filter{
    width: 100% !important;
  }
  .filters-box .brand-filter ul,
  .brand-filter ul{
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 2px !important;
  }
  .filters-box .brand-filter li,
  .brand-filter li{
    flex: 0 0 auto !important;
    margin: 0 !important;
  }
  .filters-box .brand-filter label,
  .brand-filter label{
    white-space: nowrap !important;
    justify-content: flex-start !important;
  }

  /* Если это фильтр ТИПОВ/ЗАПЧАСТЕЙ — оставляем столбик (уточняем селектор) */
  .filters-box .type-filter ul,
  .type-filter ul{
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
    overflow: visible !important;
  }

  /* Сетка карточек: 2 колонки, ничего не выпирает */
  .product-list{
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    padding: 6px 0 !important;
  }

  .product-card{
    width: auto !important;
    max-width: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    padding: 10px !important;
    border-radius: 10px !important;
    box-shadow: 0 1px 6px rgba(0,0,0,.08) !important;
    gap: 8px !important;
  }

  .product-card img.product-img{
    width: 84px !important; height: 84px !important; margin: 0 0 8px !important; object-fit: contain !important;
  }

  .product-title{
    font-size: .92rem !important; line-height: 1.25 !important; margin: 0 0 6px !important;
    min-height: 2.4em !important; word-break: break-word !important; overflow-wrap: anywhere !important;
  }

  .product-price{ font-size: 1rem !important; margin: 0 0 6px !important; }
  .product-actions{ width: 100% !important; gap: 8px !important; }

  .buy-btn, .more-btn{
    width: 100% !important; max-width: none !important; height: 44px !important; font-size: .88em !important;
    margin: 0 auto !important; background-size: 100% 100% !important; background-position: center !important;
  }

  .load-more{
    width: 180px !important; height: 46px !important; margin: 18px auto 0 !important;
    font-size: .95rem !important; background-size: 100% 100% !important;
  }

  .product-card a, .product-card button{ -webkit-tap-highlight-color: transparent; }
}

/* Экстремально узкие (≤360px): одна колонка */
@media (max-width: 360px){
  .product-list{ grid-template-columns: 1fr !important; }
  .buy-btn, .more-btn{ max-width: 200px !important; }
}
