"use client";

import ReactLenis from "lenis/react";
import BlogCardTwo from "@/components/sections/blog/BlogCardTwo";
import FooterSimple from "@/components/sections/footer/FooterSimple";
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="hover-bubble"
            defaultTextAnimation="reveal-blur"
            borderRadius="pill"
            contentWidth="compact"
            sizing="mediumLargeSizeMediumTitles"
            background="floatingGradient"
            cardStyle="solid"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="layered"
            headingFontWeight="semibold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        brandName="BlogHub"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Articles", id: "blog" },
                            { name: "Categories", id: "blog" },
                            { name: "About", id: "about" },
                            { name: "Contact", id: "contact" }
                        ]}
                        button={{ text: "Subscribe", href: "#contact" }}
                    />
                </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 Articles"
                            description="Stay updated with our latest insights and expert content from our team"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            carouselMode="buttons"
                            animationType="slide-up"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterSimple
                        columns={[
                            {
                                title: "Navigation",                                items: [
                                    { label: "Home", href: "#hero" },
                                    { label: "Articles", href: "#blog" },
                                    { label: "Categories", href: "#blog" }
                                ]
                            },
                            {
                                title: "Categories",                                items: [
                                    { label: "Technology", href: "#blog" },
                                    { label: "Design", href: "#blog" },
                                    { label: "Marketing", href: "#blog" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "#about" },
                                    { label: "Contact", href: "#contact" },
                                    { label: "Privacy Policy", href: "#" }
                                ]
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Twitter", href: "https://twitter.com" },
                                    { label: "LinkedIn", href: "https://linkedin.com" },
                                    { label: "Newsletter", href: "#contact" }
                                ]
                            }
                        ]}
                        bottomLeftText="© 2025 BlogHub. All rights reserved."
                        bottomRightText="Made with passion for writers and readers"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}