"use client";

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

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

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="text-shift"
                defaultTextAnimation="entrance-slide"
                borderRadius="pill"
                contentWidth="mediumLarge"
                sizing="medium"
                background="noiseDiagonalGradient"
                cardStyle="soft-shadow"
                primaryButtonStyle="diagonal-gradient"
                secondaryButtonStyle="glass"
                headingFontWeight="medium"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                    <NavbarStyleCentered
                        brandName="Stellar"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Services", id: "services" },
                            { name: "Work", id: "work" },
                            { name: "About", id: "about" },
                            { name: "Insights", id: "insights" },
                            { name: "Contact", id: "contact" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        button={{ text: "Cart", onClick: () => console.log("cart") }}
                    />
                    </div>
                    <main className="min-h-screen flex items-center justify-center pt-20">
                        <p className="text-foreground">Loading products...</p>
                    </main>
                    <div id="footer" data-section="footer">
                    <FooterBaseReveal
                        columns={[
                            {
                                title: "Services",                                items: [
                                    { label: "Brand Strategy", href: "#services" },
                                    { label: "Digital Marketing", href: "#services" },
                                    { label: "Creative Design", href: "#services" },
                                    { label: "Analytics", href: "#services" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About", href: "#about" },
                                    { label: "Work", href: "#work" },
                                    { label: "Blog", href: "#" },
                                    { label: "Careers", href: "#" }
                                ]
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Contact", href: "#contact" },
                                    { label: "LinkedIn", href: "https://linkedin.com" },
                                    { label: "Twitter", href: "https://twitter.com" },
                                    { label: "Email", href: "#" }
                                ]
                            }
                        ]}
                        copyrightText="© 2025 Stellar Marketing. All rights reserved."
                    />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="text-shift"
            defaultTextAnimation="entrance-slide"
            borderRadius="pill"
            contentWidth="mediumLarge"
            sizing="medium"
            background="noiseDiagonalGradient"
            cardStyle="soft-shadow"
            primaryButtonStyle="diagonal-gradient"
            secondaryButtonStyle="glass"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                <NavbarStyleCentered
                    brandName="Stellar"
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "Services", id: "services" },
                        { name: "Work", id: "work" },
                        { name: "About", id: "about" },
                        { name: "Insights", id: "insights" },
                        { name: "Contact", id: "contact" },
                        { name: "Shop", id: "/shop" }
                    ]}
                    button={{ text: "Cart", onClick: () => console.log("cart") }}
                />
                </div>
                <div id="productCatalog" data-section="productCatalog">
                <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">
                <FooterBaseReveal
                    columns={[
                        {
                            title: "Services",                            items: [
                                { label: "Brand Strategy", href: "#services" },
                                { label: "Digital Marketing", href: "#services" },
                                { label: "Creative Design", href: "#services" },
                                { label: "Analytics", href: "#services" }
                            ]
                        },
                        {
                            title: "Company",                            items: [
                                { label: "About", href: "#about" },
                                { label: "Work", href: "#work" },
                                { label: "Blog", href: "#" },
                                { label: "Careers", href: "#" }
                            ]
                        },
                        {
                            title: "Connect",                            items: [
                                { label: "Contact", href: "#contact" },
                                { label: "LinkedIn", href: "https://linkedin.com" },
                                { label: "Twitter", href: "https://twitter.com" },
                                { label: "Email", href: "#" }
                            ]
                        }
                    ]}
                    copyrightText="© 2025 Stellar Marketing. All rights reserved."
                />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}

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