/* ============================================================
   iStore — catalog-grid.css  (глобально)
   Общая раскладка списка товаров: сетка grid/list, переключатель
   вида, сортировка, пустое состояние, прелоадер. Используется на
   странице каталога (categoryFilterPage) и поиска (searchResult).
   Сами карточки — в product-card.css. Зависит от theme.css.
   ============================================================ */

/* ---------- переключатель grid / list ---------- */
.cf-views { display: flex; gap: 6px; }
.cf-view {
    width: 34px; height: 34px; border-radius: 8px; border: 0; cursor: pointer;
    background: var(--surface-alt); color: var(--muted);
    display: grid; place-items: center;
}
.cf-view.is-active { background: var(--accent); color: var(--accent-text); }

/* ---------- сортировка ---------- */
.cf-sort { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.cf-select {
    height: 34px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font-size: 13px; padding: 0 10px; cursor: pointer;
}

/* ---------- сетка товаров: grid / list ---------- */
.cf-products { position: relative; }
.cf-products--grid {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px;
    align-items: stretch;                 /* ячейки ряда одной высоты */
}
.cf-cell { display: flex; min-width: 0; }             /* карточка тянется на всю высоту ячейки */
.cf-cell .card { flex: 1 1 auto; width: 100%; }

/* list view — карточка-строка через grid (фото | название+код | цена+кнопка) */
.cf-products--list { display: flex; flex-direction: column; gap: 14px; }
.cf-products--list .cf-cell { display: block; }
.cf-products--list .card {
    display: grid;
    grid-template-columns: 120px 1fr auto;
    grid-template-areas:
    "media name foot"
    "media code foot";
    align-items: center;
    column-gap: 24px; row-gap: 2px;
    width: 100%;
}
.cf-products--list .card__media { grid-area: media; }
.cf-products--list .card__name  { grid-area: name; align-self: end; }
.cf-products--list .card__code  { grid-area: code; align-self: start; }
.cf-products--list .card__foot  {
    grid-area: foot; margin-top: 0;
    flex-direction: row; align-items: center; gap: 24px;
}
.cf-products--list .card__prices { align-items: flex-end; }
.cf-products--list .card__buy   { width: auto; padding: 12px 28px; white-space: nowrap; }
.cf-products--list .card__fav   { display: none; }   /* в строке сердце убираем, тесно */

/* preloader */
.cf-products .preloader {
    position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 60%, transparent);
    display: grid; place-items: center; z-index: 2;
}
.cf-products .preloader::after {
    content: ""; width: 34px; height: 34px; border-radius: 50%;
    border: 3px solid var(--border); border-top-color: var(--accent);
    animation: cf-spin .7s linear infinite;
}
@keyframes cf-spin { to { transform: rotate(360deg); } }

/* empty (когда фильтр/AJAX вернул пусто внутри сетки) */
.cat-empty {
    grid-column: 1 / -1; padding: 64px 20px; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--muted);
}
.cat-empty__icon { width: 80px; height: 80px; border-radius: 50%; background: var(--surface-alt); display: grid; place-items: center; }

/* ---------- responsive: число колонок сетки ---------- */
@media (max-width: 1000px) {
    .cf-products--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .cf-products--list .card {
        grid-template-columns: 84px 1fr;
        grid-template-areas:
      "media name"
      "media code"
      "media foot";
        column-gap: 14px;
    }
    .cf-products--list .card__foot { flex-wrap: wrap; gap: 10px; }
    .cf-products--list .card__buy  { padding: 10px 18px; }
}
@media (max-width: 560px) {
    .cf-products--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}