"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 ProductCatalog from "@/components/ecommerce/productCatalog/ProductCatalog";
import FooterMedia from '@/components/sections/footer/FooterMedia';
import { useProductCatalog } from "@/hooks/useProductCatalog";

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

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="hover-magnetic"
                defaultTextAnimation="reveal-blur"
                borderRadius="soft"
                contentWidth="medium"
                sizing="mediumSizeLargeTitles"
                background="aurora"
                cardStyle="glass-depth"
                primaryButtonStyle="primary-glow"
                secondaryButtonStyle="radial-glow"
                headingFontWeight="medium"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                    <NavbarStyleFullscreen
                        brandName="Roof Repair LLC"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Services", id: "services" },
                            { name: "Areas We Serve", id: "areas" },
                            { name: "Reviews", id: "testimonials" },
                            { name: "FAQ", id: "faq" },
                            { name: "Contact", id: "contact" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        bottomLeftText="Licensed & Insured"
                        bottomRightText="1-800-ROOF-FIX"
                        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">
                    <FooterMedia
                        imageSrc="http://img.b2bpic.net/free-photo/worker-with-level-building-roof-house_23-2148748855.jpg"
                        imageAlt="Professional roofing work"
                        logoText="Roof Repair LLC"
                        copyrightText="© 2025 Roof Repair LLC. Licensed & Insured. All rights reserved."
                        columns={[
                            {
                                title: "Services",                                items: [
                                    { label: "Leak Repair", href: "#services" },
                                    { label: "Storm Damage", href: "#services" },
                                    { label: "Shingle Replacement", href: "#services" },
                                    { label: "Emergency Roofing", href: "#services" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "#why-choose-us" },
                                    { label: "Our Process", href: "#process" },
                                    { label: "Reviews", href: "#testimonials" },
                                    { label: "Contact", href: "#contact" }
                                ]
                            },
                            {
                                title: "Contact",                                items: [
                                    { label: "1-800-ROOF-FIX", href: "tel:1-800-7663-3499" },
                                    { label: "Emergency: 24/7", href: "tel:1-800-7663-3499" },
                                    { label: "Privacy Policy", href: "#" },
                                    { label: "License & Insurance", href: "#" }
                                ]
                            }
                        ]}
                    />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="hover-magnetic"
            defaultTextAnimation="reveal-blur"
            borderRadius="soft"
            contentWidth="medium"
            sizing="mediumSizeLargeTitles"
            background="aurora"
            cardStyle="glass-depth"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                <NavbarStyleFullscreen
                    brandName="Roof Repair LLC"
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "Services", id: "services" },
                        { name: "Areas We Serve", id: "areas" },
                        { name: "Reviews", id: "testimonials" },
                        { name: "FAQ", id: "faq" },
                        { name: "Contact", id: "contact" },
                        { name: "Shop", id: "/shop" }
                    ]}
                    bottomLeftText="Licensed & Insured"
                    bottomRightText="1-800-ROOF-FIX"
                    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">
                <FooterMedia
                    imageSrc="http://img.b2bpic.net/free-photo/worker-with-level-building-roof-house_23-2148748855.jpg"
                    imageAlt="Professional roofing work"
                    logoText="Roof Repair LLC"
                    copyrightText="© 2025 Roof Repair LLC. Licensed & Insured. All rights reserved."
                    columns={[
                        {
                            title: "Services",                            items: [
                                { label: "Leak Repair", href: "#services" },
                                { label: "Storm Damage", href: "#services" },
                                { label: "Shingle Replacement", href: "#services" },
                                { label: "Emergency Roofing", href: "#services" }
                            ]
                        },
                        {
                            title: "Company",                            items: [
                                { label: "About Us", href: "#why-choose-us" },
                                { label: "Our Process", href: "#process" },
                                { label: "Reviews", href: "#testimonials" },
                                { label: "Contact", href: "#contact" }
                            ]
                        },
                        {
                            title: "Contact",                            items: [
                                { label: "1-800-ROOF-FIX", href: "tel:1-800-7663-3499" },
                                { label: "Emergency: 24/7", href: "tel:1-800-7663-3499" },
                                { label: "Privacy Policy", href: "#" },
                                { label: "License & Insurance", href: "#" }
                            ]
                        }
                    ]}
                />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}

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