"use client";

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

export default function ShopPage() {
    const [cartOpen, setCartOpen] = useState(false);
    const {
        products,
        isLoading,
        search,
        setSearch,
        filters,
    } = useProductCatalog({ basePath: "/shop" });

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="hover-magnetic"
                defaultTextAnimation="reveal-blur"
                borderRadius="soft"
                contentWidth="small"
                sizing="medium"
                background="aurora"
                cardStyle="gradient-bordered"
                primaryButtonStyle="double-inset"
                secondaryButtonStyle="solid"
                headingFontWeight="semibold"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                    <NavbarStyleFullscreen
                        brandName="Baklajan"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About", id: "about" },
                            { name: "Collections", id: "arrangements" },
                            { name: "Services", id: "services" },
                            { name: "Contact", id: "contact" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        bottomLeftText="Premium Floral Studio"
                        bottomRightText="hello@baklajan.com"
                        button={{ text: "Cart", onClick: () => setCartOpen(true) }}
                    />
                    </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: "Navigate",                                items: [
                                    { label: "Home", href: "/" },
                                    { label: "About", href: "about" },
                                    { label: "Collections", href: "arrangements" },
                                    { label: "Services", href: "services" }
                                ]
                            },
                            {
                                title: "Services",                                items: [
                                    { label: "Custom Arrangements", href: "#" },
                                    { label: "Wedding Florals", href: "#" },
                                    { label: "Event Decoration", href: "#" },
                                    { label: "Gift Delivery", href: "#" }
                                ]
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Email", href: "mailto:hello@baklajan.com" },
                                    { label: "Phone", href: "tel:+1234567890" },
                                    { label: "Instagram", href: "https://instagram.com/baklajan" },
                                    { label: "Contact", href: "contact" }
                                ]
                            }
                        ]}
                        bottomLeftText="© 2025 Baklajan Flowers Studio. All rights reserved."
                        bottomRightText="Crafted with Passion & Blooms"
                    />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="hover-magnetic"
            defaultTextAnimation="reveal-blur"
            borderRadius="soft"
            contentWidth="small"
            sizing="medium"
            background="aurora"
            cardStyle="gradient-bordered"
            primaryButtonStyle="double-inset"
            secondaryButtonStyle="solid"
            headingFontWeight="semibold"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                <NavbarStyleFullscreen
                    brandName="Baklajan"
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "About", id: "about" },
                        { name: "Collections", id: "arrangements" },
                        { name: "Services", id: "services" },
                        { name: "Contact", id: "contact" },
                        { name: "Shop", id: "/shop" }
                    ]}
                    bottomLeftText="Premium Floral Studio"
                    bottomRightText="hello@baklajan.com"
                    button={{ text: "Cart", onClick: () => setCartOpen(true) }}
                />
                </div>
                <div id="product-catalog" data-section="product-catalog">
                <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: "Navigate",                            items: [
                                { label: "Home", href: "/" },
                                { label: "About", href: "about" },
                                { label: "Collections", href: "arrangements" },
                                { label: "Services", href: "services" }
                            ]
                        },
                        {
                            title: "Services",                            items: [
                                { label: "Custom Arrangements", href: "#" },
                                { label: "Wedding Florals", href: "#" },
                                { label: "Event Decoration", href: "#" },
                                { label: "Gift Delivery", href: "#" }
                            ]
                        },
                        {
                            title: "Connect",                            items: [
                                { label: "Email", href: "mailto:hello@baklajan.com" },
                                { label: "Phone", href: "tel:+1234567890" },
                                { label: "Instagram", href: "https://instagram.com/baklajan" },
                                { label: "Contact", href: "contact" }
                            ]
                        }
                    ]}
                    bottomLeftText="© 2025 Baklajan Flowers Studio. All rights reserved."
                    bottomRightText="Crafted with Passion & Blooms"
                />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}