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

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

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="text-shift"
                defaultTextAnimation="background-highlight"
                borderRadius="sharp"
                contentWidth="medium"
                sizing="mediumLargeSizeLargeTitles"
                background="floatingGradient"
                cardStyle="elevated"
                primaryButtonStyle="diagonal-gradient"
                secondaryButtonStyle="layered"
                headingFontWeight="extrabold"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                    <NavbarStyleFullscreen
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "products" },
                            { name: "About", id: "about" },
                            { name: "Features", id: "features" },
                            { name: "Testimonials", id: "testimonials" },
                            { name: "Contact", id: "contact" }
                        ]}
                        brandName="Stringed Harmony"
                        bottomLeftText="For Musicians, By Musicians"
                        bottomRightText="hello@stringedharmony.com"
                        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: "Shop",                                items: [
                                    { label: "Acoustic Guitars", href: "#" },
                                    { label: "Electric Guitars", href: "#" },
                                    { label: "Bass Guitars", href: "#" },
                                    { label: "Accessories", href: "#" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "#about" },
                                    { label: "Our Story", href: "#" },
                                    { label: "Expert Team", href: "#" },
                                    { label: "Careers", href: "#" }
                                ]
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "Contact", href: "#contact" },
                                    { label: "FAQ", href: "#faq" },
                                    { label: "Setup Guide", href: "#" },
                                    { label: "Warranty", href: "#" }
                                ]
                            },
                            {
                                title: "Legal",                                items: [
                                    { label: "Privacy Policy", href: "#" },
                                    { label: "Terms of Service", href: "#" },
                                    { label: "Return Policy", href: "#" },
                                    { label: "Shipping Info", href: "#" }
                                ]
                            }
                        ]}
                        bottomLeftText="© 2025 Stringed Harmony. All rights reserved."
                        bottomRightText="Crafted for Musicians, By Musicians"
                    />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="text-shift"
            defaultTextAnimation="background-highlight"
            borderRadius="sharp"
            contentWidth="medium"
            sizing="mediumLargeSizeLargeTitles"
            background="floatingGradient"
            cardStyle="elevated"
            primaryButtonStyle="diagonal-gradient"
            secondaryButtonStyle="layered"
            headingFontWeight="extrabold"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                <NavbarStyleFullscreen
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "Shop", id: "products" },
                        { name: "About", id: "about" },
                        { name: "Features", id: "features" },
                        { name: "Testimonials", id: "testimonials" },
                        { name: "Contact", id: "contact" }
                    ]}
                    brandName="Stringed Harmony"
                    bottomLeftText="For Musicians, By Musicians"
                    bottomRightText="hello@stringedharmony.com"
                    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: "Shop",                            items: [
                                { label: "Acoustic Guitars", href: "#" },
                                { label: "Electric Guitars", href: "#" },
                                { label: "Bass Guitars", href: "#" },
                                { label: "Accessories", href: "#" }
                            ]
                        },
                        {
                            title: "Company",                            items: [
                                { label: "About Us", href: "#about" },
                                { label: "Our Story", href: "#" },
                                { label: "Expert Team", href: "#" },
                                { label: "Careers", href: "#" }
                            ]
                        },
                        {
                            title: "Support",                            items: [
                                { label: "Contact", href: "#contact" },
                                { label: "FAQ", href: "#faq" },
                                { label: "Setup Guide", href: "#" },
                                { label: "Warranty", href: "#" }
                            ]
                        },
                        {
                            title: "Legal",                            items: [
                                { label: "Privacy Policy", href: "#" },
                                { label: "Terms of Service", href: "#" },
                                { label: "Return Policy", href: "#" },
                                { label: "Shipping Info", href: "#" }
                            ]
                        }
                    ]}
                    bottomLeftText="© 2025 Stringed Harmony. All rights reserved."
                    bottomRightText="Crafted for Musicians, By Musicians"
                />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}