"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="directional-hover"
            defaultTextAnimation="background-highlight"
            borderRadius="rounded"
            contentWidth="mediumSmall"
            sizing="medium"
            background="noise"
            cardStyle="subtle-shadow"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="layered"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleApple
                        brandName="Star Wars Fan Club"
                        navItems={[
                            { name: 'Home', id: '/' },
                            { name: 'About', id: '/#about' },
                            { name: 'Features', id: '/#features' },
                            { name: 'Showcase', id: '/#product' },
                            { name: 'News', id: '/blog' },
                            { name: 'Shop', id: '/shop' },
                            { name: 'Team', id: '/#team' },
                            { name: 'Contact', id: '/#contact' }
                        ]}
                    />
                </div>

                {isLoading ? (
                    <div className="w-content-width mx-auto py-20 text-center">
                        <p className="text-foreground">Loading posts...</p>
                    </div>
                ) : (
                    <BlogCardThree
                        blogs={posts}
                        title="Latest Articles"
                        description="Insights and updates from our team"
                        animationType="slide-up"
                        textboxLayout="default"
                        useInvertedBackground={false}
                        carouselMode="buttons"
                    />
                )}
                <div id="footer" data-section="footer">
                    <FooterLogoEmphasis
                        columns={[
                            { items: [{ label: 'About Us', href: '#about' }, { label: 'Features', href: '#features' }, { label: 'News', href: '/blog' }] },
                            { items: [{ label: 'Community', href: '#product' }, { label: 'Team', href: '#team' }, { label: 'FAQ', href: '#faq' }] },
                            { items: [{ label: 'Contact', href: '#contact' }, { label: 'Privacy Policy', href: '#' }, { label: 'Terms of Service', href: '#' }] }
                        ]}
                        logoText="Star Wars Fan Club"
                        containerClassName="bg-background-accent text-foreground"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
