"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="elastic-effect"
            defaultTextAnimation="reveal-blur"
            borderRadius="rounded"
            contentWidth="mediumLarge"
            sizing="large"
            background="floatingGradient"
            cardStyle="subtle-shadow"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="solid"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleCentered
                        brandName="FitFlow"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Workouts", id: "workouts" },
                            { name: "Plans", id: "plans" },
                            { name: "Testimonials", id: "testimonials" },
                            { name: "FAQ", id: "faq" },
                            { name: "Download", id: "download" }
                        ]}
                        button={{ text: "Get Started", href: "download" }}
                    />
                </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="Explore our latest fitness insights and training tips"
                            tag="Blog"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            animationType="slide-up"
                            carouselMode="buttons"
                            uniformGridCustomHeightClasses="min-h-[600px]"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterLogoReveal
                        logoText="FitFlow"
                        leftLink={{ text: "Privacy Policy", href: "https://example.com/privacy" }}
                        rightLink={{ text: "Terms of Service", href: "https://example.com/terms" }}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}