"use client";

import ReactLenis from "lenis/react";
import BlogCardOne from '@/components/sections/blog/BlogCardOne';
import FooterBaseCard from '@/components/sections/footer/FooterBaseCard';
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleApple from '@/components/navbar/NavbarStyleApple/NavbarStyleApple';
import { useBlogPosts } from "@/hooks/useBlogPosts";

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

    return (
        <ThemeProvider
            defaultButtonVariant="elastic-effect"
            defaultTextAnimation="background-highlight"
            borderRadius="sharp"
            contentWidth="medium"
            sizing="largeSmall"
            background="aurora"
            cardStyle="elevated"
            primaryButtonStyle="shadow"
            secondaryButtonStyle="glass"
            headingFontWeight="extrabold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleApple
                        brandName="BlogHub"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Articles", id: "blog" },
                            { name: "Categories", id: "blog" },
                            { name: "Subscribe", id: "contact" }
                        ]}
                    />
                </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">
                        <BlogCardOne
                            blogs={posts}
                            title="Latest Articles"
                            description="Discover insights, trends, and expert perspectives from our editorial team"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            carouselMode="buttons"
                            animationType="slide-up"
                            tag="Blog"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterBaseCard
                        logoText="BlogHub"
                        columns={[
                            {
                                title: "Content",                                items: [
                                    { label: "Latest Articles", href: "#blog" },
                                    { label: "Categories", href: "#blog" },
                                    { label: "Archives", href: "#blog" },
                                    { label: "Search", href: "#blog" }
                                ]
                            },
                            {
                                title: "Community",                                items: [
                                    { label: "Newsletter", href: "#contact" },
                                    { label: "Contact Us", href: "#contact" },
                                    { label: "Contribute", href: "#blog" },
                                    { label: "Feedback", href: "#contact" }
                                ]
                            },
                            {
                                title: "About",                                items: [
                                    { label: "About BlogHub", href: "#hero" },
                                    { label: "Our Mission", href: "#hero" },
                                    { label: "Team", href: "#hero" }
                                ]
                            },
                            {
                                title: "Legal",                                items: [
                                    { label: "Privacy Policy", href: "/privacy" },
                                    { label: "Terms of Service", href: "/terms" },
                                    { label: "Cookie Policy", href: "/cookies" }
                                ]
                            }
                        ]}
                        copyrightText="© 2025 BlogHub. All rights reserved."
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}