"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarLayoutFloatingOverlay from '@/components/navbar/NavbarLayoutFloatingOverlay/NavbarLayoutFloatingOverlay';
import ProductCatalog from "@/components/ecommerce/productCatalog/ProductCatalog";
import { useProductCatalog } from "@/hooks/useProductCatalog";
import FooterCard from '@/components/sections/footer/FooterCard';
import { Instagram, Facebook, Pinterest } from 'lucide-react';

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

    // NOTE: The cart state (cartOpen, setCartOpen) is not available on this page.
    // A placeholder onClick is used for the Cart button to adhere to the strict
    // prohibition against adding new hooks or state (like useCart).
    const handleCartClick = () => {};

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="slide-background"
                defaultTextAnimation="background-highlight"
                borderRadius="pill"
                contentWidth="compact"
                sizing="mediumLargeSizeLargeTitles"
                background="grid"
                cardStyle="solid"
                primaryButtonStyle="diagonal-gradient"
                secondaryButtonStyle="radial-glow"
                headingFontWeight="medium"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarLayoutFloatingOverlay
                            brandName="Angelina"
                            navItems={[{ name: "Home", id: "/" }, { name: "Shop", id: "/shop" }]}
                            button={{ text: "Cart", onClick: handleCartClick }}
                        />
                    </div>
                    <main className="min-h-screen flex items-center justify-center pt-20">
                        <p className="text-foreground">Loading products...</p>
                    </main>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="slide-background"
            defaultTextAnimation="background-highlight"
            borderRadius="pill"
            contentWidth="compact"
            sizing="mediumLargeSizeLargeTitles"
            background="grid"
            cardStyle="solid"
            primaryButtonStyle="diagonal-gradient"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarLayoutFloatingOverlay
                        brandName="Angelina"
                        navItems={[{ name: "Home", id: "/" }, { name: "Shop", id: "/shop" }]}
                        button={{ text: "Cart", onClick: handleCartClick }}
                    />
                </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">
                    <FooterCard
                        logoText="Angelina"
                        copyrightText="© 2025 Angelina Flowers Studio. All rights reserved."
                        socialLinks={[
                            { icon: Instagram, href: "https://instagram.com/angelinaflowers", ariaLabel: "Instagram" },
                            { icon: Facebook, href: "https://facebook.com/angelinaflowers", ariaLabel: "Facebook" },
                            { icon: Pinterest, href: "https://pinterest.com/angelinaflowers", ariaLabel: "Pinterest" },
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
