/* ── Page ────────────────────────────────────────────────── */
.catalog-page {
  background: #141414;
  padding: 48px 0 80px;
  min-height: 60vh;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.catalog-page * {
  font-family: inherit;
}

.catalog-container {
  width: 1360px;
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 48px;
  box-sizing: border-box;
}

/* ── Block ───────────────────────────────────────────────── */
.catalog-block {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.catalog-block--hidden { display: none; }

/* ── Block header (title + line) ─────────────────────────── */
.catalog-block__header {
  display: flex;
  align-items: center;
  gap: 20px;
}

.catalog-block__title {
  font-weight: 700;
  font-size: 20px;
  color: #ffffff;
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
}

.catalog-block__line {
  flex: 1;
  height: 1px;
  background: #252525;
}

/* ── Uniform chip grid ───────────────────────────────────── */
.catalog-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.catalog-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 12px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #aaaaaa;
  font-size: 12px;
  letter-spacing: 0.4px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  user-select: none;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
}

.catalog-chip:hover {
  border-color: #555;
  color: #ffffff;
}

.catalog-chip--selected {
  background: #bd993c;
  border-color: #bd993c;
  color: #141414;
}

/* ── Brand grid ──────────────────────────────────────────── */
.catalog-brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.catalog-brand-card {
  display: flex;
  flex-direction: column;
  background: #1a1a1a;
  border: 1px solid #252525;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
  overflow: hidden;
}

.catalog-brand-card:hover  { border-color: #444; background: #1f1f1f; }
.catalog-brand-card--selected {
  border-color: #bd993c;
  background: rgba(189, 153, 60, 0.08);
}

/* Photo fills top – square aspect ratio */
.catalog-brand-card__photo {
  aspect-ratio: 1 / 1;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  width: 100%;
}

.catalog-brand-card__photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.catalog-brand-card__photo svg { flex-shrink: 0; }

.catalog-brand-card__name {
  padding: 10px 12px;
  font-size: 11px;
  color: #cccccc;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  text-align: center;
  background: #141414;
  border-top: 1px solid #252525;
}

.catalog-brand-card--selected .catalog-brand-card__name { color: #bd993c; }

/* ── Generation chips – same grid as categories ──────────── */
/* (reuses .catalog-chip-grid + .catalog-chip) */

/* ── Products section header ─────────────────────────────── */
.catalog-products-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.catalog-products-count {
  font-size: 14px;
  color: #666;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Products LIST ───────────────────────────────────────── */
.catalog-product-list {
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  gap: 0;
}

/* Sub-category header inside product list */
.catalog-subcat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 12px;
  background: #1e1e1e;
  border: 1px solid #2e2e2e;
  margin-top: 24px;
}
.catalog-subcat-header:first-child { margin-top: 0; }

.catalog-subcat-header__name {
  font-size: 13px;
  font-weight: 700;
  color: #f0f0f0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.catalog-subcat-header__count {
  font-size: 12px;
  color: #666;
  margin-left: auto;
}

/* Product rows inside a group share the same border */
.catalog-subcat-header + .catalog-product-item,
.catalog-product-item + .catalog-product-item {
  border-top: none;
}

.catalog-product-item {
  display: grid;
  grid-template-columns: 72px minmax(120px, 1fr) minmax(80px, 1fr) minmax(65px, 1fr) minmax(65px, 1fr) minmax(65px, 1fr) minmax(70px, 1fr) minmax(85px, 1fr) minmax(75px, 1fr) 52px;
  align-items: center;
  justify-items: start;
  gap: 0 20px;
  background: #191919;
  border: 1px solid #252525;
  border-top: none;
  transition: filter 0.12s;
  min-height: 80px;
  padding: 12px 16px 12px 0;
}

.catalog-product-item--alt {
  background: #333333;
}

.catalog-product-item:last-child { border-bottom: none; }
.catalog-product-item:hover { filter: brightness(1.08); }

/* Thumbnail — square, contained */
.catalog-product-item__thumb {
  width: 64px;
  height: 64px;
  background: #111;
  border: 1px solid #333;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 12px;
}

.catalog-product-item__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Name + Article block */
.catalog-product-item__name-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.catalog-product-item__name {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalog-product-item__sku {
  font-size: 11px;
  color: #666;
  white-space: nowrap;
}

/* Category + Наименование block */
.catalog-product-item__cat-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.catalog-product-item__cat {
  font-size: 13px;
  color: #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalog-product-item__label {
  font-size: 10px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Generic cell (stock, supply, manufacturer) */
.catalog-product-item__cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  min-width: 0;
}

.catalog-product-item__value {
  font-size: 13px;
  font-weight: 600;
  color: #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.catalog-product-item__cell-label {
  font-size: 10px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.catalog-product-item__price-cell .catalog-product-item__price {
  font-size: 15px;
  color: #ffffff;
  white-space: nowrap;
}


/* Cart button */
.catalog-product-item__cart {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  background: #bd993c;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.catalog-product-item__cart:hover { background: #cfa84a; }

.catalog-product-item__cart img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
}

/* ── Empty / loading ─────────────────────────────────────── */
.catalog-loading {
  color: #555;
  font-size: 14px;
  margin: 0;
  padding: 6px 0;
}

.catalog-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  border: 1px dashed #2a2a2a;
  color: #444;
  gap: 14px;
  text-align: center;
  font-size: 15px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1400px) {
  .catalog-container { padding: 0 24px; }
  .catalog-product-item {
    grid-template-columns: 64px minmax(100px, 1fr) minmax(70px, 1fr) minmax(55px, 1fr) minmax(55px, 1fr) minmax(55px, 1fr) minmax(60px, 1fr) minmax(75px, 1fr) minmax(65px, 1fr) 48px;
    gap: 0 16px;
  }
}

@media (max-width: 768px) {
  .catalog-page {
    padding: 20px 0 48px;
    overflow-x: hidden;
  }

  .catalog-container {
    padding: 0 16px;
    gap: 28px;
    overflow-x: hidden;
  }

  .catalog-block { gap: 12px; }
  .catalog-block__header { gap: 10px; }
  .catalog-block__title {
    font-size: 16px;
    white-space: normal;
    flex-shrink: 1;
    min-width: 0;
  }

  .catalog-chip-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .catalog-chip {
    min-height: 42px;
    padding: 10px 12px;
    font-size: 11px;
  }

  .catalog-brand-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .catalog-brand-card__name {
    padding: 8px;
    font-size: 10px;
    letter-spacing: 0.3px;
  }

  .catalog-products-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .catalog-products-count { font-size: 13px; }

  .catalog-product-item__mobile-hide { display: none !important; }

  .catalog-product-item {
    grid-template-columns: 44px minmax(0, 1fr) minmax(60px, 1fr) minmax(70px, 1fr) 40px;
    grid-template-areas: "thumb name stock price cart";
    gap: 0 14px;
    min-height: 68px;
    padding: 10px 10px 10px 0;
    align-items: center;
    justify-items: start;
  }

  .catalog-product-item__thumb {
    grid-area: thumb;
    width: 40px;
    height: 40px;
    margin-left: 4px;
  }
  .catalog-product-item__thumb img { width: 100%; height: 100%; object-fit: contain; }

  .catalog-product-item__name-block {
    grid-area: name;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .catalog-product-item__name {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
  }
  .catalog-product-item__sku {
    font-size: 11px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .catalog-product-item__stock { grid-area: stock; margin-left: 6px; }
  .catalog-product-item__price-cell { grid-area: price; }
  .catalog-product-item__cart { grid-area: cart; }

  .catalog-product-item__cell {
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }
  .catalog-product-item__value {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .catalog-product-item__cell-label {
    font-size: 10px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .catalog-product-item__price-cell .catalog-product-item__price {
    font-size: 13px;
    color: #bd993c;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .catalog-product-item__price-cell .catalog-product-item__cell-label {
    font-size: 10px;
    white-space: nowrap;
  }

  .catalog-product-item__cart {
    width: 40px;
    height: 40px;
    justify-self: end;
    flex-shrink: 0;
  }
  .catalog-product-item__cart img { width: 20px; height: 20px; }

  .catalog-empty { padding: 40px 16px; font-size: 14px; }
  .catalog-loading { font-size: 13px; }
}

/* ── Lightbox ────────────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.lightbox--open { display: flex; }

.lightbox__img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
}

.lightbox__close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}

.lightbox__close:hover { opacity: 0.7; }

@media (max-width: 480px) {
  .catalog-page { padding: 16px 0 36px; }
  .catalog-container { gap: 22px; }
  .catalog-block__title { font-size: 14px; }

  .catalog-chip-grid { gap: 6px; }
  .catalog-chip {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 10px;
  }

  .catalog-brand-grid { gap: 6px; }
  .catalog-brand-card__name { padding: 6px; font-size: 9px; }

  .catalog-product-item {
    grid-template-columns: 40px minmax(0, 1fr) minmax(52px, 1fr) minmax(62px, 1fr) 36px;
    gap: 0 12px;
    min-height: 64px;
    padding: 8px 8px 8px 0;
  }
  .catalog-product-item__stock { margin-left: 20px; }
  .catalog-product-item__thumb { width: 36px; height: 36px; margin-left: 4px; }
  .catalog-product-item__name { font-size: 12px; line-height: 1.3; }
  .catalog-product-item__sku { font-size: 10px; }
  .catalog-product-item__value { font-size: 11px; }
  .catalog-product-item__cell-label { font-size: 9px; }
  .catalog-product-item__price-cell .catalog-product-item__price { font-size: 12px; }
  .catalog-product-item__price-cell .catalog-product-item__cell-label { font-size: 9px; }
  .catalog-product-item__cart { width: 36px; height: 36px; }
  .catalog-product-item__cart img { width: 18px; height: 18px; }

  .catalog-empty { padding: 28px 12px; font-size: 13px; gap: 10px; }
}
