.products-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 20px;
    align-items: stretch;
}

.product-card {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease;
    height: 100%;
    position: relative;
}

.product-card:hover {
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.product-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 16px;
    border: 2px solid transparent;
    pointer-events: none;
    transition: border-color 0.2s ease;
}

.product-card.in-cart::after {
    border-color: #1f8f39;
}

.product-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: rgba(31, 143, 57, 0);
    pointer-events: none;
    opacity: 0;
}

.product-card.flash::before {
    animation: flash-green 0.35s ease;
}

@keyframes flash-green {
    0% {
        opacity: 0;
        background: rgba(31, 143, 57, 0);
    }

    35% {
        opacity: 1;
        background: rgba(31, 143, 57, 0.18);
    }

    100% {
        opacity: 0;
        background: rgba(31, 143, 57, 0);
    }
}

.product-card img {
    width: 100%;
    aspect-ratio: 6 / 5;
    object-fit: cover;
    display: block;
    background: #eee;
    border-radius: 16px 16px 0 0;
}

.product-info {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.product-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product-description {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.product-title {
    font-size: 16px;
    line-height: 1.35;
    font-weight: 700;
    color: #222;
    overflow-wrap: anywhere;
    word-break: break-word;
    width: 100%;
}

.product-text {
    font-size: 14px;
    line-height: 1.4;
    color: #555;
    overflow-wrap: anywhere;
    word-break: break-word;
    width: 100%;
    margin: 0;
}

.add-to-cart {
    margin-top: 6px;
    width: 100%;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: #1f8f39;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.add-to-cart:hover {
    opacity: 0.94;
}

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

/* =========================
   TUB CONFIGURATOR
========================= */

.tub-configurator {
    --tub-config-height: 300px;

    max-width: 980px;
    margin: 0 auto 28px;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
    gap: 24px;
    align-items: stretch;
}

.tub-preview,
.tub-config-form {
    height: var(--tub-config-height);
}

.tub-preview {
    position: relative;
    display: grid;
    min-height: 0;
    overflow: hidden;
    border: 3px solid #111;
    border-radius: 34px 34px 42px 42px;
    background: #fff;
    box-shadow:
        inset 0 -18px 0 rgba(0, 0, 0, 0.06),
        0 10px 24px rgba(0, 0, 0, 0.10);
}

.tub-preview-grid {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: grid;
}

.tub-empty-state {
    display: flex;
    flex-direction: column;
    gap: 14px;

    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 24px;

    align-items: center;
    justify-content: center;

    color: #777;
    font-weight: 700;
    text-align: center;

    background: linear-gradient(135deg, #fafafa, #ececec);
}

.tub-flavor-slot {
    position: relative;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.55);
    background: #eee;
    cursor: pointer;
    overflow: hidden;
}

.tub-flavor-slot:last-child {
    border-right: 0;
}

.tub-flavor-slot img {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: block;
    object-fit: cover;
    object-position: center;
    transition: transform 0.22s ease;
}

.tub-flavor-slot:hover img {
    transform: scale(1.04);
}

.tub-flavor-slot span {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.68);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.remove-tub-flavor {
    position: absolute;

    top: 45%;
    left: 50%;

    transform: translate(-50%, -50%);

    width: 48px;
    height: 48px;

    border: 2px solid rgba(255, 255, 255, 0.95);
    border-radius: 999px;

    background: rgba(0, 0, 0, 0.72);
    color: #fff;

    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 18px;

    cursor: pointer;

    transition:
        transform 0.2s ease,
        background 0.2s ease;

    z-index: 5;
}

.remove-tub-flavor:hover {
    background: #d90000;
    transform: translate(-50%, -50%) scale(1.08);
}

/* =========================
   FORM CONFIGURATOR
========================= */

.tub-config-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;

    padding: 20px;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

/* elementi full width */
.tub-config-label,
.tub-helper,
.tub-add-to-cart {
    width: 100%;
}

/* select formato */
.tub-price-select {
    flex: 1;
    min-width: 0;
}

/* quantità */
.quantity-selector {
    width: 140px;
    flex-shrink: 0;
}

.tub-add-to-cart:disabled,
.add-flavor-to-tub:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.tub-helper {
    color: #666;
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
}

.tub-config-label {
    font-size: 14px;
    font-weight: 700;
    color: #444;
    text-align: left;
}

.flavor-form {
    margin-top: auto;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1400px) {
    .products-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (max-width: 1180px) {
    .products-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 920px) {
    .products-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .tub-configurator {
        --tub-config-height: 280px;

        grid-template-columns: 1fr;
    }

    .tub-preview,
    .tub-config-form {
        height: auto;
    }

    .tub-preview {
        height: var(--tub-config-height);
    }
}

@media (max-width: 680px) {
    .products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 460px) {

    .products-grid {
        grid-template-columns: 1fr;
    }

    .tub-configurator {
        --tub-config-height: 240px;
    }

    .tub-price-select,
    .quantity-selector {
        width: 100%;
        flex: 0 0 100%;
    }
}