/* Widok kafelkowy listy produktów – karta produktu.
   Wszystko zakresowane pod .view-tiles, żeby nie ruszać widoku listy ani reszty sklepu. */

.view-tiles-wrap {
    width: 100%;
    min-width: 0;
}

/* Siatka od krawędzi do krawędzi obszaru treści: liczba kolumn dobiera się sama
   z szerokości (min. 270 px na kafel), a kafle rozciągają się, żeby wypełnić rząd.
   min(270px, 100%) chroni przed poziomym scrollem w bardzo wąskim miejscu. */
.view-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr));
    gap: 24px;
    justify-content: stretch;
    align-items: stretch;
    width: 100%;
    max-width: none;
    margin: 0;
    font-family: 'Poppins', sans-serif;
}

.view-tiles *,
.view-tiles *::before,
.view-tiles *::after {
    box-sizing: border-box;
}

.view-tiles .product-card {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #000;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    padding: 15px;
    border: 1px solid #c3c3c3;
    margin: 0;
    min-width: 0;
    max-width: none;
    width: 100%;
    /* nadpisanie globalnego .product-card z base.html */
    background: #fff;
    border-radius: 0;
    overflow: visible;
    transform: none;
    transition: box-shadow .2s ease, border-color .2s ease;
}
.view-tiles .product-card:hover {
    transform: none;
    border-color: #8a8a8a;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.view-tiles .product-card.selected {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px var(--accent-color);
}

/* ── Zdjęcie ── */
.view-tiles .tile-img-link {
    display: block;
    position: relative; /* punkt odniesienia dla ewentualnej nakładki na zdjęciu */
    text-align: center;
    margin-bottom: 10px;
}
.view-tiles .tile-img {
    display: block;
    width: 100%;
    height: 220px;
    margin: 0 auto;
    object-fit: contain;
}
.view-tiles .tile-img-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: #adb5bd;
}

/* ── Nazwa ── */
.view-tiles .tile-name {
    margin: 0;
    padding: 0 0 12px;
    font-family: 'Poppins', sans-serif;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.4;
    text-align: center;
    border-bottom: 1px solid #ddd;
    min-height: calc(3 * 1.4em + 12px);
}
.view-tiles .tile-name a {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #444;
    text-decoration: none;
}
.view-tiles .tile-name a:hover {
    color: #000;
}

/* ── Kod ── */
.view-tiles .tile-sku {
    margin: 12px 0 6px;
    font-size: 14px;
    color: #000;
}

/* ── Cena ── */
.view-tiles .tile-price {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 14px;
    min-height: 42px; /* miejsce na przekreśloną starą cenę – cena stoi na tej samej wysokości w rzędzie */
}
.view-tiles .tile-price-label {
    white-space: nowrap;
}
.view-tiles .tile-price-box {
    text-align: right;
}
.view-tiles .tile-price-old {
    display: block;
    font-size: 12px;
    color: #888;
    text-decoration: line-through;
}
.view-tiles .tile-price-value {
    font-size: 15px;
    font-weight: 700;
}
.view-tiles .tile-price-value .decimal {
    font-size: inherit;
    font-weight: 700;
}
.view-tiles .tile-price-unit {
    font-size: 14px;
    font-weight: 400;
    color: inherit;
    white-space: nowrap;
}

/* ── Rząd zakupu ── */
.view-tiles .tile-buy {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    min-height: 48px; /* stała wysokość także gdy produktu nie da się zamówić (pusty rząd) */
}
.view-tiles .tile-qty {
    display: flex;
    flex: 0 0 auto;
    width: 134px;
    height: 40px;
    border: 1px solid #ccc;
    background: #fff;
}
.view-tiles .tile-qty button {
    flex: 0 0 40px;
    width: 40px;
    padding: 0;
    border: 0;
    background: #fff;
    font-family: inherit;
    font-size: 18px;
    line-height: 1;
    color: #888;
    cursor: pointer;
}
.view-tiles .tile-qty button:hover {
    background: #f2f2f2;
}
.view-tiles .tile-qty input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield;
}
.view-tiles .tile-qty input::-webkit-outer-spin-button,
.view-tiles .tile-qty input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.view-tiles .tile-cart {
    position: relative;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #e8e8e8;
    color: #333;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s ease;
}
.view-tiles .tile-cart:hover {
    background: #d0d0d0;
}

/* ── Stan magazynu ── */
.view-tiles .tile-stock {
    margin-bottom: 12px;
    font-size: 13px;
    min-height: 78px; /* tekst + pasek + do 2 linii „Zewn.” – dolna sekcja zaczyna się równo w każdej karcie */
}
.view-tiles .tile-stock-text {
    margin-bottom: 5px;
}
.view-tiles .tile-stock-bar {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e5e5e5;
    overflow: hidden;
}
.view-tiles .tile-stock-fill {
    display: block;
    height: 100%;
    border-radius: 4px;
}
.view-tiles .stock-ok .tile-stock-fill {
    background: #4caf50;
}
.view-tiles .stock-low .tile-stock-fill,
.view-tiles .stock-none .tile-stock-fill {
    background: #e31800;
}
.view-tiles .stock-none .tile-stock-text {
    color: #e31800;
}
.view-tiles .tile-ext {
    margin-top: 4px;
    font-size: 12px;
    color: #0091D4;
}

/* ── Dół karty ── */
.view-tiles .tile-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    min-height: 24px;
}
.view-tiles .tile-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    cursor: pointer;
}
.view-tiles .tile-check input {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent-color);
}

/* ── Responsywność ──
   Liczbę kolumn wylicza sama siatka (auto-fill, min. 270 px na kafel), więc osobne progi
   nie są potrzebne. Ostatni, niepełny rząd zostaje wyrównany do lewej. */
@media (max-width: 991.98px) {
    /* iOS przybliża stronę przy polach < 16 px */
    .view-tiles .tile-qty input {
        font-size: 16px;
    }
}
