"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 NavbarLayoutFloatingInline from '@/components/navbar/NavbarLayoutFloatingInline';
import { useBlogPosts } from "@/hooks/useBlogPosts";

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

    return (
        <ThemeProvider
            defaultButtonVariant="hover-magnetic"
            defaultTextAnimation="reveal-blur"
            borderRadius="sharp"
            contentWidth="mediumSmall"
            sizing="largeSizeMediumTitles"
            background="none"
            cardStyle="glass-depth"
            primaryButtonStyle="double-inset"
            secondaryButtonStyle="solid"
            headingFontWeight="light"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingInline
                        brandName="FitFlow"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Workouts", id: "workouts" },
                            { name: "Plans", id: "plans" },
                            { name: "Community", id: "testimonials" },
                            { name: "About", id: "metrics" }
                        ]}
                        button={{ text: "Download App", href: "#download" }}
                        className="fixed top-6 left-1/2 -translate-x-1/2 z-50"
                    />
                </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="FitFlow 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: "/privacy" }}
                        rightLink={{ text: "Terms of Service", href: "/terms" }}
                        className="py-12"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}