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

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

    return (
        <ThemeProvider
            defaultButtonVariant="slide-background"
            defaultTextAnimation="background-highlight"
            borderRadius="pill"
            contentWidth="mediumSmall"
            sizing="medium"
            background="floatingGradient"
            cardStyle="gradient-radial"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="glass"
            headingFontWeight="extrabold"
        >
            <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="© 2025 BlogHub"
                        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 our latest insights, tutorials, and stories from the world of technology and design"
                                textboxLayout="default"
                                useInvertedBackground="noInvert"
                                carouselMode="buttons"
                                animationType="slide-up"
                                tag="Blog"
                            />
                        </div>
                    )}

                    <div id="footer" data-section="footer">
                        <FooterSimple
                            columns={[
                                {
                                    title: "Navigate",                                    items: [
                                        { label: "Home", href: "#home" },
                                        { label: "Articles", href: "#blog" },
                                        { label: "Categories", href: "#categories" }
                                    ]
                                },
                                {
                                    title: "Resources",                                    items: [
                                        { label: "Blog Archive", href: "#" },
                                        { label: "Guest Writers", href: "#" },
                                        { label: "Contribute", href: "#" }
                                    ]
                                },
                                {
                                    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: "Email", href: "mailto:hello@bloghub.com" }
                                    ]
                                }
                            ]}
                            bottomLeftText="© 2025 BlogHub. All rights reserved."
                            bottomRightText="Made with passion and coffee"
                        />
                    </div>
            </ReactLenis>
        </ThemeProvider>
    );
}