"use client";

import ReactLenis from "lenis/react";
import BlogCardThree from '@/components/sections/blog/BlogCardThree';
import FooterBaseCard from '@/components/sections/footer/FooterBaseCard';
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarLayoutFloatingInline from '@/components/navbar/NavbarLayoutFloatingInline';
import { useBlogPosts } from "@/hooks/useBlogPosts";

export default function BlogPage() {
    const { posts, isLoading } = useBlogPosts();

    return (
        <ThemeProvider
            defaultButtonVariant="directional-hover"
            defaultTextAnimation="background-highlight"
            borderRadius="rounded"
            contentWidth="mediumLarge"
            sizing="mediumLarge"
            background="circleGradient"
            cardStyle="glass-elevated"
            primaryButtonStyle="diagonal-gradient"
            secondaryButtonStyle="solid"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingInline
                        brandName="ShopHub"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "shop" },
                            { name: "Collections", id: "collections" },
                            { name: "About", id: "about" },
                            { name: "Contact", id: "contact" }
                        ]}
                        button={{ text: "Cart", href: "#" }}
                    />
                </div>

                {isLoading ? (
                    <div className="w-content-width mx-auto py-20 text-center">
                        <p className="text-foreground">Loading posts...</p>
                    </div>
                ) : (
                    <div id="blog" data-section="blog">
                        <BlogCardThree
                            blogs={posts}
                            title="Featured Articles"
                            description="Discover the latest insights and trends in e-commerce"
                            tag="Blog"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            animationType="slide-up"
                            carouselMode="buttons"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterBaseCard
                        logoText="ShopHub"
                        columns={[
                            {
                                title: "Shop",                                items: [
                                    { label: "New Arrivals", href: "#" },
                                    { label: "Best Sellers", href: "#" },
                                    { label: "Sale", href: "#" },
                                    { label: "All Products", href: "#" }
                                ]
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "Contact Us", href: "#" },
                                    { label: "Shipping Info", href: "#" },
                                    { label: "Returns", href: "#" },
                                    { label: "FAQ", href: "#" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "#" },
                                    { label: "Blog", href: "#" },
                                    { label: "Careers", href: "#" },
                                    { label: "Press", href: "#" }
                                ]
                            }
                        ]}
                        copyrightText="© 2025 ShopHub. All rights reserved."
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}