"use client";

import { Suspense } from "react";
import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleFullscreen from '@/components/navbar/NavbarStyleFullscreen/NavbarStyleFullscreen';
import FooterLogoEmphasis from '@/components/sections/footer/FooterLogoEmphasis';
import ProductCatalog from "@/components/ecommerce/productCatalog/ProductCatalog";
import { useProductCatalog } from "@/hooks/useProductCatalog";

function ShopPageContent() {
    const {
        products,
        isLoading,
        search,
        setSearch,
        filters,
    } = useProductCatalog({ basePath: "/shop" });

    return (
        <ThemeProvider
            defaultButtonVariant="shift-hover"
            defaultTextAnimation="entrance-slide"
            borderRadius="pill"
            contentWidth="mediumSmall"
            sizing="mediumLargeSizeLargeTitles"
            background="floatingGradient"
            cardStyle="glass-elevated"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="solid"
            headingFontWeight="light"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleFullscreen
                        navItems={[{ name: "Home", id: "/" }, { name: "Blog", id: "/blog" }, { name: "Shop", id: "/shop" }]}
                        brandName="DigitalEdge"
                        bottomLeftText="Innovation in Digital"
                        bottomRightText="info@digitaledge.com"
                    />
                </div>
                
                {isLoading ? (
                    <div id="loading-section" data-section="loading-section">
                        <main className="min-h-screen flex items-center justify-center pt-20">
                            <p className="text-foreground">Loading products...</p>
                        </main>
                    </div>
                ) : (
                    <div id="product-catalog" data-section="product-catalog">
                        <ProductCatalog
                            layout="page"
                            products={products}
                            searchValue={search}
                            onSearchChange={setSearch}
                            searchPlaceholder="Search products..."
                            filters={filters}
                            emptyMessage="No products found"
                        />
                    </div>
                )}
                
                <div id="footer" data-section="footer">
                    <FooterLogoEmphasis
                        columns={[{ items: [{ label: "Home", href: "/" }, { label: "Services", href: "/#features" }, { label: "About Us", href: "/#about" }] }, { items: [{ label: "Clients", href: "/#social-proof" }, { label: "Testimonials", href: "/#testimonials" }, { label: "Contact", href: "/#contact" }] }]}
                        logoText="DigitalEdge"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}

export default function ShopPage() {
    return (
        <Suspense>
            <ShopPageContent />
        </Suspense>
    );
}
