"use client";

import ReactLenis from "lenis/react";
import BlogCardTwo from '@/components/sections/blog/BlogCardTwo';
import FooterBaseReveal from '@/components/sections/footer/FooterBaseReveal';
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="directional-hover"
            defaultTextAnimation="background-highlight"
            borderRadius="soft"
            contentWidth="smallMedium"
            sizing="mediumLargeSizeLargeTitles"
            background="floatingGradient"
            cardStyle="subtle-shadow"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="light"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleFullscreen
                        brandName="Stories"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Articles", id: "articles" },
                            { name: "Categories", id: "categories" },
                            { name: "Newsletter", id: "newsletter" },
                            { name: "Contact", id: "contact" }
                        ]}
                        bottomLeftText="Content Hub"
                        bottomRightText="hello@stories.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 Stories"
                            description="Discover compelling articles and insights from our community of writers"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            animationType="slide-up"
                            carouselMode="buttons"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterBaseReveal
                        columns={[
                            {
                                title: "Content",                                items: [
                                    { label: "All Articles", href: "#articles" },
                                    { label: "Categories", href: "#categories" },
                                    { label: "Archives", href: "#archives" },
                                    { label: "Trending", href: "#trending" }
                                ]
                            },
                            {
                                title: "Community",                                items: [
                                    { label: "Newsletter", href: "#newsletter" },
                                    { label: "Submit Article", href: "#submit" },
                                    { label: "Guest Writers", href: "#writers" },
                                    { label: "Feedback", href: "#feedback" }
                                ]
                            },
                            {
                                title: "Resources",                                items: [
                                    { label: "About Us", href: "#about" },
                                    { label: "Contact", href: "#contact" },
                                    { label: "Privacy Policy", href: "#privacy" },
                                    { label: "Terms of Service", href: "#terms" }
                                ]
                            }
                        ]}
                        copyrightText="© 2025 Stories. All rights reserved. Crafted with passion for storytellers."
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}