"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="directional-hover"
                defaultTextAnimation="entrance-slide"
                borderRadius="soft"
                contentWidth="compact"
                sizing="mediumLarge"
                background="floatingGradient"
                cardStyle="inset"
                primaryButtonStyle="radial-glow"
                secondaryButtonStyle="layered"
                headingFontWeight="normal"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleCentered
                            navItems={[
                                { "name": "Home", "id": "/" },
                                { "name": "About", "id": "about" },
                                { "name": "Products", "id": "products" },
                                { "name": "Benefits", "id": "features" },
                                { "name": "Testimonials", "id": "testimonials" },
                                { "name": "Contact", "id": "contact" },
                                { "name": "Shop", "id": "/shop" }
                            ]}
                            brandName="Luxe Botanics"
                            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": "Shop", "items": [{ "label": "All Products", "href": "products" }, { "label": "Serums", "href": "#" }, { "label": "Moisturizers", "href": "#" }, { "label": "Masks & Treatments", "href": "#" }] },
                                { "title": "Company", "items": [{ "label": "About Us", "href": "about" }, { "label": "Our Story", "href": "#" }, { "label": "Sustainability", "href": "#" }, { "label": "Careers", "href": "#" }] },
                                { "title": "Support", "items": [{ "label": "Contact Us", "href": "#" }, { "label": "FAQ", "href": "faq" }, { "label": "Shipping & Returns", "href": "#" }, { "label": "Privacy Policy", "href": "#" }] }
                            ]
                            copyrightText="© 2025 Luxe Botanics. All rights reserved. Crafted with purpose, delivered with luxury."
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="directional-hover"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="compact"
            sizing="mediumLarge"
            background="floatingGradient"
            cardStyle="inset"
            primaryButtonStyle="radial-glow"
            secondaryButtonStyle="layered"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleCentered
                        navItems={[
                            { "name": "Home", "id": "/" },
                            { "name": "About", "id": "about" },
                            { "name": "Products", "id": "products" },
                            { "name": "Benefits", "id": "features" },
                            { "name": "Testimonials", "id": "testimonials" },
                            { "name": "Contact", "id": "contact" },
                            { "name": "Shop", "id": "/shop" }
                        ]}
                        brandName="Luxe Botanics"
                        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": "Shop", "items": [{ "label": "All Products", "href": "products" }, { "label": "Serums", "href": "#" }, { "label": "Moisturizers", "href": "#" }, { "label": "Masks & Treatments", "href": "#" }] },
                            { "title": "Company", "items": [{ "label": "About Us", "href": "about" }, { "label": "Our Story", "href": "#" }, { "label": "Sustainability", "href": "#" }, { "label": "Careers", "href": "#" }] },
                            { "title": "Support", "items": [{ "label": "Contact Us", "href": "#" }, { "label": "FAQ", "href": "faq" }, { "label": "Shipping & Returns", "href": "#" }, { "label": "Privacy Policy", "href": "#" }] }
                        ]
                        copyrightText="© 2025 Luxe Botanics. All rights reserved. Crafted with purpose, delivered with luxury."
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}

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