"use client";

import ReactLenis from "lenis/react";
import BlogCardTwo from '@/components/sections/blog/BlogCardTwo';
import FooterBaseReveal from '@/components/sections/footer/FooterBaseReveal';
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="hover-magnetic"
            defaultTextAnimation="background-highlight"
            borderRadius="pill"
            contentWidth="mediumLarge"
            sizing="mediumLargeSizeMediumTitles"
            background="none"
            cardStyle="gradient-mesh"
            primaryButtonStyle="double-inset"
            secondaryButtonStyle="solid"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleFullscreen
                        brandName="BlogHub"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Articles", id: "blog" },
                            { name: "Categories", id: "features" },
                            { name: "Subscribe", id: "contact" },
                            { name: "About", id: "about" }
                        ]}
                        bottomLeftText="Insights & 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">
                        <BlogCardTwo
                            blogs={posts}
                            title="Latest Articles"
                            description="Discover insights, stories, and expert perspectives from our community of writers and thought leaders."
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            animationType="slide-up"
                            carouselMode="buttons"
                            tag="Blog"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterBaseReveal
                        columns={[
                            {
                                title: "Content",                                items: [
                                    { label: "All Articles", href: "blog" },
                                    { label: "Categories", href: "features" },
                                    { label: "Archives", href: "blog" },
                                    { label: "Subscribe", href: "contact" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "about" },
                                    { label: "Contact", href: "contact" },
                                    { label: "Privacy Policy", href: "#" },
                                    { label: "Terms of Service", href: "#" }
                                ]
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Twitter", href: "https://twitter.com" },
                                    { label: "LinkedIn", href: "https://linkedin.com" },
                                    { label: "Instagram", href: "https://instagram.com" },
                                    { label: "Email", href: "mailto:hello@bloghub.com" }
                                ]
                            }
                        ]}
                        copyrightText="© 2025 BlogHub. All rights reserved."
                        onPrivacyClick={null}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}