"use client";

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

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

    const [cartOpen, setCartOpen] = useState(false);

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="shift-hover"
                defaultTextAnimation="reveal-blur"
                borderRadius="soft"
                contentWidth="compact"
                sizing="mediumLargeSizeMediumTitles"
                background="aurora"
                cardStyle="solid"
                primaryButtonStyle="shadow"
                secondaryButtonStyle="layered"
                headingFontWeight="medium"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                    <NavbarStyleApple
                        brandName="Giina"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Collections", id: "products" },
                            { name: "About", id: "about" },
                            { name: "Why Giina", id: "features" },
                            { name: "Contact", id: "contact" }
                        ]}
                        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">
                    <FooterBaseCard
                        logoText="Giina Flowers"
                        columns={[
                            {
                                title: "Collections",                                items: [
                                    { label: "All Flowers", href: "products" },
                                    { label: "Seasonal", href: "products" },
                                    { label: "Premium", href: "products" },
                                    { label: "Custom Orders", href: "contact" }
                                ]
                            },
                            {
                                title: "About",                                items: [
                                    { label: "Our Story", href: "about" },
                                    { label: "Why Choose Us", href: "features" },
                                    { label: "Testimonials", href: "testimonials" },
                                    { label: "Blog", href: "#" }
                                ]
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "Contact Us", href: "contact" },
                                    { label: "Delivery Info", href: "#" },
                                    { label: "Care Guide", href: "#" },
                                    { label: "FAQ", href: "#" }
                                ]
                            },
                            {
                                title: "Legal",                                items: [
                                    { label: "Privacy Policy", href: "#" },
                                    { label: "Terms of Service", href: "#" },
                                    { label: "Returns", href: "#" },
                                    { label: "Sitemap", href: "#" }
                                ]
                            }
                        ]}
                        copyrightText="© 2025 Giina Flowers. All rights reserved with love."
                    />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="shift-hover"
            defaultTextAnimation="reveal-blur"
            borderRadius="soft"
            contentWidth="compact"
            sizing="mediumLargeSizeMediumTitles"
            background="aurora"
            cardStyle="solid"
            primaryButtonStyle="shadow"
            secondaryButtonStyle="layered"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                <NavbarStyleApple
                    brandName="Giina"
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "Collections", id: "products" },
                        { name: "About", id: "about" },
                        { name: "Why Giina", id: "features" },
                        { name: "Contact", id: "contact" }
                    ]}
                    button={{ text: "Cart", onClick: () => setCartOpen(true) }}
                />
                </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">
                <FooterBaseCard
                    logoText="Giina Flowers"
                    columns={[
                        {
                            title: "Collections",                            items: [
                                { label: "All Flowers", href: "products" },
                                { label: "Seasonal", href: "products" },
                                { label: "Premium", href: "products" },
                                { label: "Custom Orders", href: "contact" }
                            ]
                        },
                        {
                            title: "About",                            items: [
                                { label: "Our Story", href: "about" },
                                { label: "Why Choose Us", href: "features" },
                                { label: "Testimonials", href: "testimonials" },
                                { label: "Blog", href: "#" }
                            ]
                        },
                        {
                            title: "Support",                            items: [
                                { label: "Contact Us", href: "contact" },
                                { label: "Delivery Info", href: "#" },
                                { label: "Care Guide", href: "#" },
                                { label: "FAQ", href: "#" }
                            ]
                        },
                        {
                            title: "Legal",                            items: [
                                { label: "Privacy Policy", href: "#" },
                                { label: "Terms of Service", href: "#" },
                                { label: "Returns", href: "#" },
                                { label: "Sitemap", href: "#" }
                            ]
                        }
                    ]}
                    copyrightText="© 2025 Giina Flowers. All rights reserved with love."
                />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}