/*
 * B02 - Products Grid Styles
 *
 * Lays out N columns; each cell hosts the standardized storefront
 * ProductCard.svelte widget, hydrated by personalizationEnhancer.js from the
 * .saly-ps-product-card-container skeleton (same widget + mechanics as B03).
 *
 * CSS Isolation: every class uses the .saly-ps- prefix. Skeleton + ProductCard
 * overrides mirror B03 so both blocks render the identical card.
 */

.saly-ps-block-products-grid {
    width: 100%;
    margin-bottom: 3rem;
    position: relative;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: 2rem 0;
}

/* Full-width white background via pseudo-element (matches B04 Categories Tiles) */
.saly-ps-block-products-grid::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -100vw;
    right: -100vw;
    background: #ffffff;
    z-index: -1;
}

/* Section title — large centered heading above the grid. */
.saly-ps-block-products-grid .saly-ps-block-title {
    margin: 0 0 20px;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    line-height: 1.2;
    color: #1a202c;
    text-align: center;
}

/* N-column responsive grid (columns from builder; design: desktop=N, tablet 3, mobile 2) */
.saly-ps-products-grid {
    display: grid;
    grid-template-columns: repeat(var(--saly-ps-grid-columns, 4), minmax(0, 1fr));
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

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

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

.saly-ps-grid-item {
    display: flex;
    min-width: 0;
}

.saly-ps-no-products {
    grid-column: 1 / -1;
    text-align: center;
    color: #718096;
    padding: 40px 0;
}

/* ========================================
   SKELETON LOADING (for ProductCard.svelte hydration) — mirrors B03
   ======================================== */

.saly-ps-product-card-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: visible;
    transition: all 0.3s ease;
}

.saly-ps-card-skeleton {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.saly-ps-skeleton-image {
    width: 100%;
    height: 205px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: salyPsGridSkeletonShimmer 1.5s infinite;
    border-radius: 8px 8px 0 0;
}

.saly-ps-skeleton-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    flex: 1;
}

.saly-ps-skeleton-line {
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: salyPsGridSkeletonShimmer 1.5s infinite;
    border-radius: 4px;
}

.saly-ps-skeleton-line--name {
    height: 20px;
    width: 100%;
}

.saly-ps-skeleton-line--name.saly-ps-skeleton-line--short {
    width: 70%;
}

.saly-ps-skeleton-line--code {
    height: 14px;
    width: 50%;
    margin-top: 4px;
}

.saly-ps-skeleton-line--price {
    height: 20px;
    width: 40%;
    margin-top: 8px;
}

.saly-ps-skeleton-button {
    height: 40px;
    width: 100%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: salyPsGridSkeletonShimmer 1.5s infinite;
    border-radius: 4px;
    margin-top: auto;
}

@keyframes salyPsGridSkeletonShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Hide skeleton once ProductCard.svelte is mounted */
[data-ps-enhanced="true"] .saly-ps-card-skeleton {
    display: none;
}

/* Noscript fallback */
.saly-ps-noscript-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.saly-ps-noscript-link img {
    width: 100%;
    height: 205px;
    object-fit: contain;
    background: #f9f9f9;
    border-radius: 8px 8px 0 0;
}

.saly-ps-noscript-link span {
    padding: 16px;
    font-weight: 700;
    font-size: 14px;
    line-height: 24px;
    color: #333333;
}

/* ========================================
   SVELTE PRODUCTCARD OVERRIDES (container provides the border/shape)
   ======================================== */

.saly-ps-product-card-container .product-card {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    height: 100% !important;
    border-radius: 0 !important;
}

.saly-ps-product-card-container .product-card__container {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

.saly-ps-product-card-container .product-card__image-wrapper,
.saly-ps-product-card-container .product-card__photo-container {
    height: 205px !important;
    min-height: 205px !important;
    max-height: 205px !important;
}

.saly-ps-product-card-container .product-card__info {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 16px !important;
}

@media (max-width: 639px) {
    .saly-ps-skeleton-image {
        height: 180px;
    }

    .saly-ps-skeleton-content {
        padding: 12px;
    }

    .saly-ps-product-card-container .product-card__image-wrapper,
    .saly-ps-product-card-container .product-card__photo-container {
        height: 180px !important;
        min-height: 180px !important;
        max-height: 180px !important;
    }
}
