"use client";

import ReactLenis from "lenis/react";
import BlogCardOne from "@/components/sections/blog/BlogCardOne";
import FooterBaseReveal from '@/components/sections/footer/FooterBaseReveal';
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="hover-bubble"
            defaultTextAnimation="entrance-slide"
            borderRadius="pill"
            contentWidth="medium"
            sizing="medium"
            background="none"
            cardStyle="gradient-bordered"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="layered"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingInline
                        brandName="Webild"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Work", id: "features" },
                            { name: "Services", id: "services" },
                            { name: "Pricing", id: "pricing" },
                            { name: "About", id: "testimonials" }
                        ]}
                        button={{ text: "Get Started", href: "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 Insights"
                            description="Discover our latest thoughts, tutorials, and industry insights to help you build better digital experiences"
                            tag="Blog"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            carouselMode="buttons"
                            animationType="slide-up"
                            buttons={[
                                { text: "View All Posts", href: "/blog" },
                                { text: "Subscribe", href: "/subscribe" }
                            ]}
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterBaseReveal
                        columns={[
                            {
                                title: "Product",                                items: [
                                    { label: "Services", href: "services" },
                                    { label: "Pricing", href: "pricing" },
                                    { label: "Portfolio", href: "features" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "testimonials" },
                                    { label: "Contact", href: "contact" },
                                    { label: "Blog", href: "https://blog.example.com" }
                                ]
                            },
                            {
                                title: "Legal",                                items: [
                                    { label: "Privacy Policy", href: "#" },
                                    { label: "Terms of Service", href: "#" },
                                    { label: "Cookie Policy", href: "#" }
                                ]
                            }
                        ]}
                        copyrightText="© 2025 Webild. All rights reserved."
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}