"use client";

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

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

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="directional-hover"
                defaultTextAnimation="reveal-blur"
                borderRadius="pill"
                contentWidth="small"
                sizing="mediumLarge"
                background="none"
                cardStyle="solid"
                primaryButtonStyle="inset-glow"
                secondaryButtonStyle="glass"
                headingFontWeight="medium"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                    <NavbarStyleApple
                        brandName="Early Bird Landscaping"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Services", id: "services" },
                            { name: "Before & After", id: "beforeAfter" },
                            { name: "Reviews", id: "reviews" },
                            { name: "About", id: "about" },
                            { 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">
                    <FooterSimple
                        columns={[
                            {
                                title: "Services",                                items: [
                                    { label: "Yard Cleanouts", href: "/services" },
                                    { label: "Weed Removal", href: "/services" },
                                    { label: "Trimming & Pruning", href: "/services" },
                                    { label: "Rental Cleanup", href: "/services" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "/about" },
                                    { label: "Before & After", href: "/before-after" },
                                    { label: "Reviews", href: "/reviews" },
                                    { label: "Get a Quote", href: "#quote" }
                                ]
                            },
                            {
                                title: "Contact",                                items: [
                                    { label: "Call Us", href: "tel:+1-555-0123" },
                                    { label: "Text for Quote", href: "sms:+1-555-0123" },
                                    { label: "Email", href: "mailto:info@earlybird-landscaping.com" },
                                    { label: "Hours", href: "#" }
                                ]
                            },
                            {
                                title: "Legal",                                items: [
                                    { label: "Privacy Policy", href: "#" },
                                    { label: "Terms of Service", href: "#" },
                                    { label: "Service Areas", href: "#" }
                                ]
                            }
                        ]}
                        bottomLeftText="© 2025 Early Bird Landscaping. All rights reserved."
                        bottomRightText="Serving your neighborhood with pride."
                    />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="directional-hover"
            defaultTextAnimation="reveal-blur"
            borderRadius="pill"
            contentWidth="small"
            sizing="mediumLarge"
            background="none"
            cardStyle="solid"
            primaryButtonStyle="inset-glow"
            secondaryButtonStyle="glass"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                <NavbarStyleApple
                    brandName="Early Bird Landscaping"
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "Services", id: "services" },
                        { name: "Before & After", id: "beforeAfter" },
                        { name: "Reviews", id: "reviews" },
                        { name: "About", id: "about" },
                        { 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">
                <FooterSimple
                    columns={[
                        {
                            title: "Services",                            items: [
                                { label: "Yard Cleanouts", href: "/services" },
                                { label: "Weed Removal", href: "/services" },
                                { label: "Trimming & Pruning", href: "/services" },
                                { label: "Rental Cleanup", href: "/services" }
                            ]
                        },
                        {
                            title: "Company",                            items: [
                                { label: "About Us", href: "/about" },
                                { label: "Before & After", href: "/before-after" },
                                { label: "Reviews", href: "/reviews" },
                                { label: "Get a Quote", href: "#quote" }
                            ]
                        },
                        {
                            title: "Contact",                            items: [
                                { label: "Call Us", href: "tel:+1-555-0123" },
                                { label: "Text for Quote", href: "sms:+1-555-0123" },
                                { label: "Email", href: "mailto:info@earlybird-landscaping.com" },
                                { label: "Hours", href: "#" }
                            ]
                        },
                        {
                            title: "Legal",                            items: [
                                { label: "Privacy Policy", href: "#" },
                                { label: "Terms of Service", href: "#" },
                                { label: "Service Areas", href: "#" }
                            ]
                        }
                    ]}
                    bottomLeftText="© 2025 Early Bird Landscaping. All rights reserved."
                    bottomRightText="Serving your neighborhood with pride."
                />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}

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