/**
 * DigiCommerce Products Grid Block Styles
 */

.wp-block-digicommerce-products-grid {
    margin: 0;
    padding: 0;

    .digicommerce-products-grid__products {
        display: grid;
        gap: 2rem;
        margin-bottom: 3rem;

        /* Column variations */
        &--cols-1 {
            grid-template-columns: 1fr;
        }

        &--cols-2 {
            grid-template-columns: repeat(2, 1fr);
        }

        &--cols-3 {
            grid-template-columns: repeat(3, 1fr);
        }

        &--cols-4 {
            grid-template-columns: repeat(4, 1fr);
        }

        &--cols-5 {
            grid-template-columns: repeat(5, 1fr);
        }

        &--cols-6 {
            grid-template-columns: repeat(6, 1fr);
        }

        /* Responsive grid */
        @media (max-width: 1024px) {
            &--cols-5,
            &--cols-6 {
                grid-template-columns: repeat(3, 1fr);
            }
        }

        @media (max-width: 768px) {
            &--cols-3,
            &--cols-4,
            &--cols-5,
            &--cols-6 {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        @media (max-width: 580px) {
            &--cols-1,
            &--cols-2,
            &--cols-3,
            &--cols-4,
            &--cols-5,
            &--cols-6 {
                grid-template-columns: 1fr;
            }
        }
    }

    /* Product card styles */
    .digicommerce-products-grid__product {
        position: relative;
        display: flex;
        flex-direction: column;
        height: 100%;
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        overflow: hidden;
        transition:
            box-shadow 0.3s ease,
            transform 0.3s ease;

        &:hover {
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
            transform: translateY(-2px);

            .digicommerce-products-grid__product-image img {
                transform: scale(1.05);
            }
        }
    }

    .digicommerce-products-grid__product-inner {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    /* Product image */
    .digicommerce-products-grid__product-image {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        aspect-ratio: 2/3;
        overflow: hidden;
        background: #f9fafb;

        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.3s ease;
        }
    }

    /* Product content */
    .digicommerce-products-grid__product-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        padding: 1.25rem;
    }

    /* Product title */
    .digicommerce-products-grid__product-title {
        margin: 0 0 0.75rem 0;
        font-size: 1.125rem;
        font-weight: 600;
        line-height: 1.4;

        a {
            color: #111827;
            text-decoration: none;
            transition: color 0.2s ease;

            &:hover {
                color: #ccb161;
            }
        }
    }

    /* Product price */
    .digicommerce-products-grid__product-price {
        margin-bottom: 1rem;
        font-size: 1.25rem;
        font-weight: 700;

        .digicommerce-price-from {
            font-size: 0.875rem;
            font-weight: 400;
            color: #6b7280;
            margin-right: 0.25rem;
        }

        .digicommerce-price {
            color: #059669;
        }

        .digicommerce-price-sale {
            color: #059669;
            margin-right: 0.5rem;
        }

        .digicommerce-price-regular {
            color: #9ca3af;
            text-decoration: line-through;
            font-size: 1rem;
            font-weight: 400;
        }

        .price-wrapper {
            display: inline-flex;
            align-items: baseline;
        }

        .price-symbol {
            font-size: 0.875em;
            margin-right: 2px;
        }
    }

    /* Product button */
    .digicommerce-products-grid__product-button {
        margin-top: auto;

        .digicommerce-button {
            display: inline-block;
            width: 100%;
            padding: 0.625rem 1.25rem;
            background: #1f2937;
            color: #ffffff;
            text-align: center;
            text-decoration: none;
            font-size: 0.875rem;
            font-weight: 500;
            border-radius: 0.375rem;
            transition:
                background-color 0.2s ease,
                color 0.2s ease;

            &:hover {
                background: #ccb161;
                color: #1f2937;
            }
        }
    }

    /* Empty state */
    .digicommerce-products-grid__empty {
        padding: 3rem;
        text-align: center;
        color: #6b7280;
        font-size: 1.125rem;
    }

    /* Pagination */
    .digicommerce-products-grid__pagination {
        margin-top: 3rem;
        display: flex;
        justify-content: center;

        ul.page-numbers {
            display: flex;
            gap: 0.5rem;
            list-style: none;
            margin: 0;
            padding: 0;

            li {
                margin: 0;
                padding: 0;
            }

            .page-numbers {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                min-width: 2.5rem;
                padding: 0.5rem 0.75rem;
                background: #ffffff;
                color: #4b5563;
                text-decoration: none;
                border: 1px solid #e5e7eb;
                border-radius: 0.375rem;
                font-size: 0.875rem;
                font-weight: 500;
                transition: all 0.2s ease;

                &:hover {
                    background: #f9fafb;
                    border-color: #9ca3af;
                    color: #1f2937;
                }

                &.current {
                    background: #1f2937;
                    color: #ffffff;
                    border-color: #1f2937;
                    cursor: default;
                }

                &.dots {
                    border: none;
                    background: transparent;
                    cursor: default;

                    &:hover {
                        background: transparent;
                    }
                }

                &.prev,
                &.next {
                    padding: 0.5rem 1rem;
                }
            }
        }
    }
}

/* Editor specific styles */
.wp-block-digicommerce-products-grid[data-type='digicommerce/products-grid'] {
    .digicommerce-products-grid__product-image a {
        pointer-events: none;
    }

    .digicommerce-products-grid__product-title a,
    .digicommerce-products-grid__product-button a {
        pointer-events: none;
        cursor: default;
    }
}
