"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="text-stagger"
            defaultTextAnimation="entrance-slide"
            borderRadius="pill"
            contentWidth="small"
            sizing="mediumLargeSizeLargeTitles"
            background="circleGradient"
            cardStyle="gradient-bordered"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Services", id: "/#services" },
                            { name: "About Us", id: "/#about" },
                            { name: "Testimonials", id: "/#testimonials" },
                            { name: "Contact", id: "/#contact" },
                        ]}
                        brandName="Josiah & Sons"
                        button={{ text: "Call Us Now", href: "tel:+1-713-555-1234" }}
                        className="py-4 px-6 md:px-8"
                        buttonClassName="font-medium"
                        buttonTextClassName="text-lg"
                    />
                </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="Insights and updates from our team"
                            animationType="slide-up"
                            textboxLayout="default"
                            useInvertedBackground={false}
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterLogoEmphasis
                        columns={[
                            { items: [{ label: "Home", href: "/#hero" }, { label: "Services", href: "/#services" }, { label: "About Us", href: "/#about" }] },
                            { items: [{ label: "Testimonials", href: "/#testimonials" }, { label: "Contact", href: "/#contact" }, { label: "Privacy Policy", href: "/privacy" }, { label: "Terms of Service", href: "/terms" }] }
                        ]}
                        logoText="Josiah & Sons Plumbers"
                        ariaLabel="Site footer with navigation and company information."
                        className="bg-background-accent text-foreground py-12 md:py-16"
                        containerClassName="max-w-screen-xl mx-auto px-4 sm:px-6 lg:px-8"
                        logoClassName="text-4xl font-extrabold mb-8 text-foreground"
                        itemClassName="text-foreground hover:text-primary-cta transition-colors duration-200"
                        iconClassName="text-primary-cta h-5 w-5"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
