"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 FooterCard from '@/components/sections/footer/FooterCard';
import { useProductCatalog } from "@/hooks/useProductCatalog";
import { useState } from "react";
import { Instagram, Facebook, Twitter, Linkedin } from 'lucide-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="mediumSmall"
                sizing="medium"
                background="floatingGradient"
                cardStyle="gradient-radial"
                primaryButtonStyle="primary-glow"
                secondaryButtonStyle="radial-glow"
                headingFontWeight="normal"
            >
                <ReactLenis root>
                    <div id="nav" data-section="nav">
                    <NavbarStyleFullscreen
                        brandName="Tiger"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        bottomLeftText="Premium Cup Collection"
                        bottomRightText="hello@tigercups.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>
                    <FooterCard
                        logoText="Tiger Cups"
                        copyrightText="© 2025 Tiger Cups. All rights reserved. Crafting excellence, one cup at a time."
                        socialLinks={[
                            { icon: Instagram, href: "https://instagram.com/tigercups", ariaLabel: "Tiger Cups Instagram" },
                            { icon: Facebook, href: "https://facebook.com/tigercups", ariaLabel: "Tiger Cups Facebook" },
                            { icon: Twitter, href: "https://twitter.com/tigercups", ariaLabel: "Tiger Cups Twitter" },
                            { icon: Linkedin, href: "https://linkedin.com/company/tigercups", ariaLabel: "Tiger Cups LinkedIn" }
                        ]}
                    />
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="hover-magnetic"
            defaultTextAnimation="reveal-blur"
            borderRadius="soft"
            contentWidth="mediumSmall"
            sizing="medium"
            background="floatingGradient"
            cardStyle="gradient-radial"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                <NavbarStyleFullscreen
                    brandName="Tiger"
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "Shop", id: "/shop" }
                    ]}
                    bottomLeftText="Premium Cup Collection"
                    bottomRightText="hello@tigercups.com"
                    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>
                <FooterCard
                    logoText="Tiger Cups"
                    copyrightText="© 2025 Tiger Cups. All rights reserved. Crafting excellence, one cup at a time."
                    socialLinks={[
                        { icon: Instagram, href: "https://instagram.com/tigercups", ariaLabel: "Tiger Cups Instagram" },
                        { icon: Facebook, href: "https://facebook.com/tigercups", ariaLabel: "Tiger Cups Facebook" },
                        { icon: Twitter, href: "https://twitter.com/tigercups", ariaLabel: "Tiger Cups Twitter" },
                        { icon: Linkedin, href: "https://linkedin.com/company/tigercups", ariaLabel: "Tiger Cups LinkedIn" }
                    ]}
                />
            </ReactLenis>
        </ThemeProvider>
    );
}
