* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-dark: #0a0a0a;
  --bg-card: #222222;
  --accent-red: #bd234a;
  --accent-hover: #d82b57;
  --text-white: #ffffff;
  --text-gray: #a0a0a0;
  --text-dark: #1a1a1a;
  --font-title: 'Cormorant Garamond', serif;
  --font-body: 'Montserrat', sans-serif;
}

html {
  height: 100%;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-white);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  margin: 0 auto;
  padding: 0 20px;
}

/* --- СЕТКА КАТАЛОГА (SIDEBAR + PRODUCTS) --- */
.catalog-page {
  display: flex;
  gap: 40px;
  padding-top: 20px;
  padding-bottom: 20px;
  box-sizing: border-box;
  height: auto !important;
  position: relative;
  align-items: flex-start;
}

/* --- SIDEBAR --- */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  position: sticky;
  top: 130px;
  align-self: flex-start;
  height: fit-content;
  overflow-y: auto;
  max-height: calc(100vh - 140px);
  scrollbar-width: thin;
  scrollbar-color: var(--accent-red) rgba(255, 255, 255, 0.05);
  padding-right: 20px;
}

/* Ошибку в селекторе исправлено с sidebar на .sidebar */
.sidebar::-webkit-scrollbar {
  width: 5px;
}

.sidebar::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background-color: var(--accent-red);
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background-color: var(--accent-hover);
}

.catalog-title {
  font-size: 32px;
  font-family: serif;
  font-weight: normal;
  line-height: 1.15; /* заголовок в 2 строки ("Каталог Аксессуаров") без большого зазора */
  margin-bottom: 10px;
}

.catalog-subtitle {
  font-size: 14px;
  color: var(--text-gray);
  line-height: 1.45;
  margin-bottom: 30px;
}

/* Группы фильтров */
.filter-group {
  margin-bottom: 25px;
}

.filter-title {
  font-size: 16px;
  font-weight: 600;
  text-transform: uppercase; /* в разметке бывает "Материал" — на экране всегда капсом */
  color: var(--accent-red);
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border-color, #2a2a2a);
  margin-bottom: 5px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  line-height: 1.3;
  color: #ddd;
  margin-bottom: 6px;
  cursor: pointer;
}

/* Длинная опция переносится на 2 строки — квадратик галочки не сжимается */
.checkbox-label input { flex-shrink: 0; }

/* --- СЛАЙДЕР ЦЕНЫ --- */
.filter-title-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.filter-title-text {
  font-size: 16px;
  text-transform: uppercase;
  color: var(--accent-red);
  letter-spacing: 1px;
  font-weight: 600;
  white-space: nowrap;
}

.filter-title-line {
  flex-grow: 1;
  height: 1px;
  background-color: #2a2a2a;
}

.price-slider-wrapper {
  padding: 0 4px;
}

.price-range-container {
  position: relative;
  height: 3px;
  margin-bottom: 12px;
}

.range-track-bg {
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: #2a2a2a;
  border-radius: 2px;
}

.range-track {
  position: absolute;
  height: 100%;
  left: 0%;
  right: 0%;
  background-color: var(--accent-red);
  border-radius: 2px;
  z-index: 1;
}

.price-range-container input[type="range"] {
  position: absolute;
  width: 100%;
  height: 3px;
  top: 0;
  left: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  margin: 0;
  z-index: 2;
}

.price-range-container input[type="range"]::-webkit-slider-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: #ffffff;
  pointer-events: auto;
  -webkit-appearance: none;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.price-range-container input[type="range"]::-moz-range-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: #ffffff;
  pointer-events: auto;
  -moz-appearance: none;
  border: none;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.price-values {
  display: flex;
  justify-content: space-between;
  font-size: 14.5px;
  color: var(--text-white);
  font-weight: 500;
}

/* --- КАРТОЧКИ ТОВАРОВ --- */
.catalog-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.products-grid {
  display: grid;
  max-width: 1400px;
  padding-left: 20px;
  grid-template-columns: repeat(4, 1fr);
  gap: 30px;
  margin-bottom: 40px;
}

.product-card {
  background-color: var(--bg-card);
  border-radius: 12px;
  text-align: center;
  display: flex;
  width: 100%;
  flex-direction: column;
  overflow: hidden;
}

.product-image-container {
  position: relative;
  background-color: #2c2c2e;
  height: 230px;
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slider-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  cursor: pointer;
  padding: 5px;
}

.slider-arrow:hover {
  color: var(--accent-red);
  transform: translateY(-50%);
  font-size: 25px;
}

.slider-arrow.left { left: 5px; }
.slider-arrow.right { right: 5px; }

/* Блок информации одинаковой высоты у всех карточек, сколько бы ни было
   текста: под название всегда 2 строки, каждая строка описания — ровно одна
   строка, цена сразу под ними. Так в ряду нечему растягиваться и пустот нет */
.product-info {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  justify-content: center;
  background-color: #2C2C2C;
}

.product-name {
  /* Место ровно под 2 строки; короткое название — по центру этого места */
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6em;
  margin-bottom: 4px;
  font-size: 17px;
  font-weight: bold;
  line-height: 1.3;
}
.product-name__text {
  /* Длинное название — не больше 2 строк, остальное многоточием */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-meta, .product-desc, .product-year {
  min-height: 1.4em;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--text-gray);
  /* Всегда одна строка, даже если пусто или текст длинный */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* "Высокое качество · 2026 год" в каталоге чая — на 0.5px меньше, чтобы год помещался */
.product-meta { font-size: 14px; }

.product-price {
  margin-top: 8px;
  font-size: 19px;
  color: #B71F43;
  font-weight: 800;
}

.product-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
}

.add-to-cart-btn {
  width: 100%;
  padding: 12px 0;
  background-color: var(--accent-red);
  color: var(--text-white);
  border: none;
  border-radius: 0 0 12px 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.add-to-cart-btn:hover {
  background-color: var(--accent-hover);
}

.add-to-cart-btn:active {
  transform: scale(0.98);
}

.add-to-cart-btn i {
  font-size: 15px;
}

/* --- ПАГИНАЦИЯ --- */
.pagination {
  margin-top: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  padding-top: 20px;
}

.page-number, .page-arrow {
  color: white;
  text-decoration: none;
  font-size: 14px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.page-number.active {
  background-color: var(--accent-red);
}

.page-dots {
  color: var(--text-gray);
}


/* ==========================================
   АДАПТИВНЫЕ СТИЛИ (MEDIA QUERIES)
   ========================================== */

/* Большие ноутбуки / Планшеты альбомом (До 1200px) */
@media (max-width: 1200px) {
  .products-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
}

/* Планшеты вертикально (До 992px) */
@media (max-width: 992px) {
  .catalog-page {
    gap: 20px;
  }

  .sidebar {
    width: 220px;
    padding-right: 10px;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    padding-left: 0;
  }

}

/* Мобильные устройства (До 768px) */
@media (max-width: 768px) {
  /* Перестраиваем каталог из горизонтального в вертикальный */
  .catalog-page {
    flex-direction: column;
    gap: 0;
    padding-top: 10px;
  }

  .sidebar {
    width: 100%;
    position: static; /* Отключаем sticky на мобильных */
    max-height: none;
    overflow: visible;
    padding-right: 0;
    margin-bottom: 20px;
  }

  .catalog-subtitle { margin-bottom: 18px; }

  /* Фильтры: варианты в строку с переносом, а не столбиком —
     иначе до товаров нужно листать несколько экранов */
  .filter-group {
    display: flex;
    flex-wrap: wrap;
    column-gap: 16px;
    margin-bottom: 16px;
  }
  .filter-title,
  .filter-title-wrapper,
  .price-slider-wrapper { flex-basis: 100%; }
  .filter-title { margin-bottom: 8px; }
  .checkbox-label { margin-bottom: 8px; }

  .catalog-content { width: 100%; }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding-left: 0;
  }

  .product-image-container {
    height: 180px;
  }
}

/* Маленькие смартфоны (До 480px) — по-прежнему 2 карточки в ряд, но компактнее */
@media (max-width: 480px) {
  .products-grid {
    gap: 10px;
  }

  .product-image-container { height: 150px; }
  .slider-arrow { display: none; } /* На узкой карточке стрелки закрывают фото */
  .product-info { padding: 10px 8px; }
  .product-name { font-size: 15px; }
  .product-meta, .product-desc, .product-year { font-size: 13px; }
  .product-price { font-size: 17px; }
  .add-to-cart-btn { font-size: 13.5px; padding: 10px 0; }

  .catalog-title {
    font-size: 24px;
  }
}
