"use client";

import ReactLenis from "lenis/react";
import BlogCardTwo from '@/components/sections/blog/BlogCardTwo';
import FooterLogoEmphasis from '@/components/sections/footer/FooterLogoEmphasis';
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="directional-hover"
            defaultTextAnimation="background-highlight"
            borderRadius="rounded"
            contentWidth="mediumSmall"
            sizing="largeSizeMediumTitles"
            background="circleGradient"
            cardStyle="glass-elevated"
            primaryButtonStyle="double-inset"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingInline
                        brandName="SocialHub"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Stories", id: "stories" },
                            { name: "Posts", id: "posts" },
                            { name: "Profile", id: "profile" }
                        ]}
                        button={{ text: "Follow", href: "#contact" }}
                        className="backdrop-blur-md bg-white/80"
                        navItemClassName="text-foreground font-medium"
                        buttonClassName="bg-primary-cta hover:bg-primary-cta/90"
                        buttonTextClassName="text-white font-semibold"
                    />
                </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 trending stories and insights from our vibrant community"
                            tag="Blog"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            animationType="slide-up"
                            carouselMode="buttons"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterLogoEmphasis
                        logoText="SocialHub"
                        columns={[
                            {
                                items: [
                                    { label: "Home", href: "/" },
                                    { label: "Explore", href: "explore" },
                                    { label: "Trending", href: "trending" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Profile", href: "profile" },
                                    { label: "Settings", href: "settings" },
                                    { label: "Saved", href: "saved" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Help Center", href: "#" },
                                    { label: "Privacy Policy", href: "#" },
                                    { label: "Terms of Service", href: "#" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Twitter", href: "https://twitter.com" },
                                    { label: "Instagram", href: "https://instagram.com" },
                                    { label: "TikTok", href: "https://tiktok.com" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}