"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 { useProductCatalog } from "@/hooks/useProductCatalog";
import FooterCard from '@/components/sections/footer/FooterCard';
import { Instagram, Facebook, Mail } from 'lucide-react';

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

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="hover-magnetic"
                defaultTextAnimation="background-highlight"
                borderRadius="sharp"
                contentWidth="medium"
                sizing="largeSmallSizeLargeTitles"
                background="none"
                cardStyle="layered-gradient"
                primaryButtonStyle="double-inset"
                secondaryButtonStyle="solid"
                headingFontWeight="semibold"
            >
                <ReactLenis root>
                    <NavbarStyleFullscreen
                        brandName="IMPERIA"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        bottomLeftText="Luxury Parfumerie"
                        bottomRightText="hello@imperia.com"
                    />
                    <main className="min-h-screen flex items-center justify-center pt-20">
                        <p className="text-foreground">Loading products...</p>
                    </main>
                    <FooterCard
                        logoText="IMPERIA"
                        copyrightText="© 2025 Imperia Parfumerie. All rights reserved. | Luxury Fragrances Curated with Excellence"
                        socialLinks={[
                            { icon: Instagram, href: "https://instagram.com/imperia", ariaLabel: "Follow us on Instagram" },
                            { icon: Facebook, href: "https://facebook.com/imperia", ariaLabel: "Follow us on Facebook" },
                            { icon: Mail, href: "mailto:hello@imperia.com", ariaLabel: "Send us an email" }
                        ]}
                    />
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="hover-magnetic"
            defaultTextAnimation="background-highlight"
            borderRadius="sharp"
            contentWidth="medium"
            sizing="largeSmallSizeLargeTitles"
            background="none"
            cardStyle="layered-gradient"
            primaryButtonStyle="double-inset"
            secondaryButtonStyle="solid"
            headingFontWeight="semibold"
        >
            <ReactLenis root>
                <NavbarStyleFullscreen
                    brandName="IMPERIA"
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "Shop", id: "/shop" }
                    ]}
                    bottomLeftText="Luxury Parfumerie"
                    bottomRightText="hello@imperia.com"
                />
                <ProductCatalog
                    layout="page"
                    products={products}
                    searchValue={search}
                    onSearchChange={setSearch}
                    searchPlaceholder="Search products..."
                    filters={filters}
                    emptyMessage="No products found"
                />
                <FooterCard
                    logoText="IMPERIA"
                    copyrightText="© 2025 Imperia Parfumerie. All rights reserved. | Luxury Fragrances Curated with Excellence"
                    socialLinks={[
                        { icon: Instagram, href: "https://instagram.com/imperia", ariaLabel: "Follow us on Instagram" },
                        { icon: Facebook, href: "https://facebook.com/imperia", ariaLabel: "Follow us on Facebook" },
                        { icon: Mail, href: "mailto:hello@imperia.com", ariaLabel: "Send us an email" }
                    ]}
                />
            </ReactLenis>
        </ThemeProvider>
    );
}