"use client";

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

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

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="elastic-effect"
                defaultTextAnimation="background-highlight"
                borderRadius="soft"
                contentWidth="small"
                sizing="largeSmall"
                background="circleGradient"
                cardStyle="glass-elevated"
                primaryButtonStyle="primary-glow"
                secondaryButtonStyle="glass"
                headingFontWeight="bold"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleFullscreen
                            brandName="InsightFlow"
                            navItems={[
                                { name: "Home", id: "/" },
                                { name: "Features", id: "features" },
                                { name: "Metrics", id: "metrics" },
                                { name: "Pricing", id: "pricing" },
                                { name: "Contact", id: "contact" },
                                { name: "Blog", id: "/blog" }
                            ]}
                            bottomLeftText="AI-Powered Analytics"
                            bottomRightText="hello@insightflow.ai"
                        />
                    </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">
                        <FooterBase
                            logoText="InsightFlow"
                            copyrightText="© 2025 InsightFlow. All rights reserved."
                            columns={[
                                {
                                    title: "Product",                                    items: [
                                        { label: "Features", href: "#features" },
                                        { label: "Pricing", href: "#pricing" },
                                        { label: "Security", href: "#" },
                                        { label: "Roadmap", href: "#" }
                                    ]
                                },
                                {
                                    title: "Company",                                    items: [
                                        { label: "About Us", href: "#" },
                                        { label: "Blog", href: "/blog" },
                                        { label: "Careers", href: "#" },
                                        { label: "Contact", href: "#contact" }
                                    ]
                                },
                                {
                                    title: "Resources",                                    items: [
                                        { label: "Documentation", href: "#" },
                                        { label: "API Reference", href: "#" },
                                        { label: "Community", href: "#" },
                                        { label: "Status", href: "#" }
                                    ]
                                }
                            ]}
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="elastic-effect"
            defaultTextAnimation="background-highlight"
            borderRadius="soft"
            contentWidth="small"
            sizing="largeSmall"
            background="circleGradient"
            cardStyle="glass-elevated"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="glass"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleFullscreen
                        brandName="InsightFlow"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Features", id: "features" },
                            { name: "Metrics", id: "metrics" },
                            { name: "Pricing", id: "pricing" },
                            { name: "Contact", id: "contact" },
                            { name: "Blog", id: "/blog" }
                        ]}
                        bottomLeftText="AI-Powered Analytics"
                        bottomRightText="hello@insightflow.ai"
                    />
                </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">
                    <FooterBase
                        logoText="InsightFlow"
                        copyrightText="© 2025 InsightFlow. All rights reserved."
                        columns={[
                            {
                                title: "Product",                                items: [
                                    { label: "Features", href: "#features" },
                                    { label: "Pricing", href: "#pricing" },
                                    { label: "Security", href: "#" },
                                    { label: "Roadmap", href: "#" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "#" },
                                    { label: "Blog", href: "/blog" },
                                    { label: "Careers", href: "#" },
                                    { label: "Contact", href: "#contact" }
                                ]
                            },
                            {
                                title: "Resources",                                items: [
                                    { label: "Documentation", href: "#" },
                                    { label: "API Reference", href: "#" },
                                    { label: "Community", href: "#" },
                                    { label: "Status", href: "#" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
