"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="text-stagger"
            defaultTextAnimation="reveal-blur"
            borderRadius="pill"
            contentWidth="smallMedium"
            sizing="largeSizeMediumTitles"
            background="circleGradient"
            cardStyle="gradient-bordered"
            primaryButtonStyle="inset-glow"
            secondaryButtonStyle="solid"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleFullscreen
                        brandName="BlogHub"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Articles", id: "blog" },
                            { name: "Categories", id: "categories" },
                            { name: "About", id: "about" },
                            { name: "Contact", id: "contact" }
                        ]}
                        bottomLeftText="Global Stories"
                        bottomRightText="hello@bloghub.com"
                    />
                </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 our most impactful stories and insights from our talented writers"
                            tag="Blog"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            animationType="slide-up"
                            carouselMode="buttons"
                            buttons={[
                                { text: "View All Articles", href: "/articles" },
                                { text: "Subscribe", href: "/subscribe" }
                            ]}
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterLogoEmphasis
                        logoText="BlogHub"
                        columns={[
                            {
                                items: [
                                    { label: "Home", href: "/" },
                                    { label: "Articles", href: "#blog" },
                                    { label: "Categories", href: "#categories" }
                                ]
                            },
                            {
                                items: [
                                    { label: "About Us", href: "#about" },
                                    { label: "Writers", href: "#writers" },
                                    { label: "Subscribe", href: "#newsletter" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Contact", href: "#contact" },
                                    { label: "Privacy Policy", href: "/privacy" },
                                    { label: "Terms of Service", href: "/terms" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Twitter", href: "https://twitter.com/bloghub" },
                                    { label: "LinkedIn", href: "https://linkedin.com/company/bloghub" },
                                    { label: "Instagram", href: "https://instagram.com/bloghub" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}