"use client";

import ReactLenis from "lenis/react";
import BlogCardTwo from "@/components/sections/blog/BlogCardTwo";
import FooterMedia from "@/components/sections/footer/FooterMedia";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarLayoutFloatingOverlay from "@/components/navbar/NavbarLayoutFloatingOverlay/NavbarLayoutFloatingOverlay";
import { useBlogPosts } from "@/hooks/useBlogPosts";

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

    return (
        <ThemeProvider
            defaultButtonVariant="bounce-effect"
            defaultTextAnimation="reveal-blur"
            borderRadius="sharp"
            contentWidth="small"
            sizing="mediumSizeLargeTitles"
            background="aurora"
            cardStyle="gradient-mesh"
            primaryButtonStyle="diagonal-gradient"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="light"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        brandName="ShopHub"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "products" },
                            { name: "Categories", id: "categories" },
                            { name: "Reviews", id: "testimonials" },
                            { name: "About", id: "about" },
                            { name: "Contact", id: "contact" }
                        ]}
                        button={{ text: "View Cart", href: "/cart" }}
                    />
                </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">
                        <BlogCardTwo
                            blogs={posts}
                            title="Latest Shopping Insights"
                            description="Discover trends, tips, and updates from the world of online shopping"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            carouselMode="buttons"
                            animationType="slide-up"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-photo/woman-studio-lamp-photo-art-concept_23-2148565571.jpg"
                        imageAlt="ShopHub footer showcase"
                        logoText="ShopHub"
                        copyrightText="© 2025 ShopHub. All rights reserved."
                        columns={[
                            {
                                title: "Shop",                                items: [
                                    { label: "Products", href: "#products" },
                                    { label: "Categories", href: "#categories" },
                                    { label: "New Arrivals", href: "#new" },
                                    { label: "Best Sellers", href: "#bestsellers" }
                                ]
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "Contact Us", href: "#contact" },
                                    { label: "Shipping Info", href: "#shipping" },
                                    { label: "Returns", href: "#returns" },
                                    { label: "FAQ", href: "#faq" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "#about" },
                                    { label: "Privacy Policy", href: "#privacy" },
                                    { label: "Terms of Service", href: "#terms" },
                                    { label: "Careers", href: "#careers" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}