.products-grid {
    margin-top: 10px;
}

.products-grid.grid-net {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    width: 100%;
    overflow: hidden;
    flex-wrap: wrap;
}

.products-grid.grid-net .col {
    padding: 0 !important;
    margin: 0 !important;
    background: none !important;
}


.products-grid.grid-shelves {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.products-grid.grid-shelves .col {
    width: 94%;
}

/* Горизонтальна (списком) картка: [фото | назва/відгуки/наявність | ціна+кнопки].
   Розкладка лише на CSS (grid-area на самих елементах) — не залежить від JS,
   тому однаково працює і в каталозі, і на сторінці пошуку. */
.products-grid.grid-shelves .product-card {
    display: grid;
    /* фіксована колонка футера → ціна завжди в одній вертикалі, незалежно
       від ширини блоку кнопок (in-stock vs "немає в наявності") */
    grid-template-columns: 160px minmax(0, 1fr) 260px;
    grid-template-areas:
        "image title   footer"
        "image reviews footer"
        "image stock   footer";
    grid-template-rows: auto auto 1fr;
    align-items: start;
    column-gap: 18px;
    row-gap: 6px;
    padding: 14px 18px;
}

.products-grid.grid-shelves .product-image {
    grid-area: image;
    align-self: center;
    margin: 0;
    padding: 0;
}
.products-grid.grid-shelves .product-image img {
    max-height: 150px;
}

.products-grid.grid-shelves .product-title {
    grid-area: title;
    font-size: 18px;
    margin: 0;
}
.products-grid.grid-shelves .product-reviews {
    grid-area: reviews;
    margin: 0;
    height: auto;
}
.products-grid.grid-shelves .product-in-stock {
    grid-area: stock;
    align-self: start;
    margin: 0;
}
/* порожній службовий блок у горизонтальній сітці не потрібен */
.products-grid.grid-shelves .products-card-shelves-grid {
    display: none;
}

/* ціна + кнопки — праворуч, прижаті до низу картки */
.products-grid.grid-shelves .product-footer {
    grid-area: footer;
    align-self: end;
    margin: 0;
    padding: 0;
}
.products-grid.grid-shelves .product-price-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: auto;
}
/* фіксований слот ціни → і ціна, і кнопки в одній вертикалі для всіх рядків */
.products-grid.grid-shelves .product-price {
    flex: 0 0 auto;
    min-width: 80px;
}
/* сердечко + "купити" — в один ряд */
.products-grid.grid-shelves .product-basket-price-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

/* grid-net: ціна і кнопки завжди в одному рядку */
.products-grid.grid-net .product-price-wrap {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 6px;
}

.products-grid.grid-net .product-price {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 17px; /* менша ціна — щоб звільнити місце під текст кнопки */
}

.products-grid.grid-net .product-basket-price-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex: 0 1 auto;
    min-width: 0; /* дозволяємо групі кнопок стискатись, а не вилазити */
}


.products-card-shelves-grid .product-reviews {
    margin-bottom: 0;
}

.products-grid.grid-shelves > .col:first-child .product-card {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.products-grid.grid-shelves > .col:last-child .product-card {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}


.product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-align: center;
    background: white;
    border: 1px solid #ddd;
    /* Якорь для .stretched-link заголовка — клик по всей карточке ведёт на товар */
    position: relative;
}

/* Кнопки/формы держим над оверлеем растянутой ссылки, чтобы они работали */
.product-card #add_to_wishlist_form,
.product-card .product-cart-form,
.product-card .product-unavailable {
    position: relative;
    z-index: 2;
}


.product-image {
    margin: 10px 0 0 0;
}

.product-image img {
    max-height: 160px;
    width: auto;
    max-width: 100%;
    margin: auto;
    border-radius: 8px;
    object-fit: contain;
}

.product-reviews {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    margin-top: auto;
}

.star-rating {
    display: flex;
    padding: 0;
    margin: 5px !important;
    align-items: center;
    font-size: 14px;
    line-height: 1;
}

.star-rating i {
    display: inline-block;
    font-size: inherit;
    line-height: inherit;
}

.reviews-count {
    display: flex;

    font-size: 14px;
    color: #555;
}


.product-title {
    font-size: 16px;
    font-weight: bold;
    margin: 4px 8px;
    text-align: left;

}

.product-title a {
    text-decoration: none;
    color: black;
}


.product-footer {
    padding: 5px 10px;
    margin: left;
}

.product-price-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-price {
    font-weight: bold;
    font-size: 18px;
    color: #000;
}

.product-cart-form {
    flex: 0 1 auto;
    min-width: 0;
    margin: 0;
}

/* приховані поля (кількість/csrf) не повинні займати місце в рядку */
.product-cart-form p {
    margin: 0;
}

.product-cart-button {
    width: auto;
    max-width: 100%;
    min-width: 0;
    height: 34px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: var(--color-primary-seconday);
    /* рамка того ж кольору, що й фон — щоб зливалась із заливкою */
    border: 1px solid var(--color-primary-seconday);
    border-radius: 6px;
    padding: 0 8px;
    cursor: pointer;
    color: #fff !important;
    font-weight: 600;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    transition: filter .15s ease;
}

.product-cart-button:hover {
    filter: brightness(0.93);
}

/* біла svg-корзина (і обводка, і заливка лінії) */
.product-cart-button svg,
.product-cart-button svg path {
    width: 18px;
    height: 18px;
    stroke: #fff !important;
}

.product-cart-button svg {
    flex: 0 0 auto;
}

.product-cart-button-text {
    color: #fff !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* немає в наявності — біла іконка кошика в сірому квадраті */
.product-unavailable {
    width: 34px;
    height: 34px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #9e9e9e;
    border: 1px solid #9e9e9e;
    border-radius: 6px;
}

.strikethrough-img {
    width: 18px;
    height: 18px;
    stroke: #fff !important;
}


/* Сердечко-бокс — ТІЛЬКИ в картці каталогу (.product-card), щоб не ламати
   кнопку списку бажань на сторінці товару, де той самий id */
.product-card #add_to_wishlist_form {
    flex: 0 0 auto;
    margin-left: 0;
}

.product-card #add_to_wishlist_form svg {
    width: 20px;
    height: 20px;
    margin-right: 0;
    transition: transform 0.3s ease;
    /* біле сердечко на червоному фоні */
    stroke: #fff !important;
}

/* заповнене сердечко (товар у списку бажань) теж біле */
.product-card #add_to_wishlist_form svg[fill="red"],
.product-card #add_to_wishlist_form svg[fill="red"] path {
    fill: #fff !important;
}

.product-card #add_to_wishlist_form svg:active {
    transform: scale(0.9);
}

/* сердечко — кнопка-бокс: біла іконка, червоний фон і червона обводка */
.product-card #add_to_wishlist_form button {
    width: 34px;
    height: 34px;
    box-sizing: border-box;
    background: #e11d1d;
    border: 1px solid #e11d1d;
    border-radius: 6px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter .15s ease;
}

.product-card #add_to_wishlist_form button:hover {
    filter: brightness(0.93);
}



.product-in-stock{
    display: flex;
    flex-direction: row;
}
.product-in-stock p{
    margin: 0 0 0 7px;
}

/* ===== Мобілки: футер картки каталогу (ціна + сердечко + "купити") =====
   Ціна окремим рядком, нижче — кнопки [♥][купити] ЗАВЖДИ зліва, звичайного
   розміру (не на всю ширину). Однаково для "в наявності" та "немає". */
@media (max-width: 820px) {
    /* один ряд: ціна + [♥][купити], усе прижате ЗЛІВА (без space-between) */
    .products-grid.grid-net .product-price-wrap {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
    }

    .products-grid.grid-net .product-price {
        font-size: 16px;
    }

    .products-grid.grid-net .product-basket-price-wrapper {
        flex-direction: row;
        justify-content: flex-start;
        flex: 0 0 auto;
        width: auto;
        gap: 8px;
    }

    .products-grid.grid-net .product-cart-form {
        flex: 0 0 auto;
    }

    .products-grid.grid-net .product-cart-button {
        width: auto;
        height: 40px;
        font-size: 13px;
        gap: 6px;
        padding: 0 14px;
    }

    .products-grid.grid-net .product-cart-button svg,
    .products-grid.grid-net .product-cart-button svg path {
        width: 20px;
        height: 20px;
    }

    /* сердечко такої ж висоти, як кнопка */
    .products-grid.grid-net .product-card #add_to_wishlist_form button {
        width: 40px;
        height: 40px;
    }

    .products-grid.grid-net .product-card #add_to_wishlist_form svg {
        width: 22px;
        height: 22px;
    }

    /* недоступний товар — квадрат тієї ж висоти */
    .products-grid.grid-net .product-unavailable {
        width: 40px;
        height: 40px;
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* кожна картка однаково заокруглена + вертикальний відступ між ними
       (nth-child-правила кутів для багатоколонкової сітки на мобілці промахуються) */
    .products-grid.grid-net {
        row-gap: 10px;
    }
    .products-grid.grid-net .product-card {
        border-radius: 12px !important;
    }
}


/* ===== На мобілці горизонтальна сітка (grid-shelves) стає звичайною
   вертикальною карткою, як у grid-net. 3 фіксовані колонки не влазять у
   вузький екран і ламали сторінку пошуку (яка завжди grid-shelves) та
   горизонтальний вигляд каталогу. Скидаємо grid-розкладку до flex-стовпчика. */
@media (max-width: 820px) {
    /* контейнер: на планшетах 2 колонки, на телефонах 1 — щоб картка була
       достатньо широкою для рядка ціна + кнопки (інакше «Купити» обрізається) */
    .products-grid.grid-shelves {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        align-items: stretch;
        column-gap: 12px;
        row-gap: 12px;
    }
    .products-grid.grid-shelves .col {
        width: 100%;
    }

    /* картка — вертикальна (як базова .product-card) */
    .products-grid.grid-shelves .product-card {
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
        grid-template-areas: none;
        grid-template-rows: none;
        column-gap: 0;
        row-gap: 0;
        padding: 10px;
        border-radius: 12px !important;
    }

    /* скидаємо grid-area у дочірніх блоків, щоб вони йшли природним порядком */
    .products-grid.grid-shelves .product-image,
    .products-grid.grid-shelves .product-title,
    .products-grid.grid-shelves .product-reviews,
    .products-grid.grid-shelves .product-in-stock,
    .products-grid.grid-shelves .product-footer {
        grid-area: auto;
        align-self: auto;
    }

    .products-grid.grid-shelves .product-image {
        text-align: center;
    }
    .products-grid.grid-shelves .product-image img {
        max-height: none;
    }
    .products-grid.grid-shelves .product-title {
        font-size: 16px;
    }

    /* ціна + кнопки в один ряд знизу (як у grid-net): футер на всю ширину,
       без бокових паддингів — інакше space-between не розтягується */
    .products-grid.grid-shelves .product-footer {
        margin-top: auto;
        width: 100%;
        box-sizing: border-box;
        padding: 5px 0;
    }
    .products-grid.grid-shelves .product-price-wrap {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
        width: 100%;
        gap: 10px;
    }
    .products-grid.grid-shelves .product-cart-button {
        width: auto;
        height: 40px;
        font-size: 13px;
        gap: 6px;
        padding: 0 14px;
    }
    .products-grid.grid-shelves .product-cart-button svg,
    .products-grid.grid-shelves .product-cart-button svg path {
        width: 20px;
        height: 20px;
    }
    .products-grid.grid-shelves .product-card #add_to_wishlist_form button {
        width: 40px;
        height: 40px;
    }
    .products-grid.grid-shelves .product-card #add_to_wishlist_form svg {
        width: 22px;
        height: 22px;
    }
    .products-grid.grid-shelves .product-unavailable {
        width: 40px;
        height: 40px;
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}





