"use client";

import ReactLenis from "lenis/react";
import BlogCardTwo from '@/components/sections/blog/BlogCardTwo';
import FooterLogoReveal from '@/components/sections/footer/FooterLogoReveal';
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="text-shift"
            defaultTextAnimation="background-highlight"
            borderRadius="soft"
            contentWidth="compact"
            sizing="largeSmallSizeLargeTitles"
            background="noiseDiagonalGradient"
            cardStyle="gradient-bordered"
            primaryButtonStyle="double-inset"
            secondaryButtonStyle="glass"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingInline
                        brandName="Montana Plumbing"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About", id: "about" },
                            { name: "Services", id: "services" },
                            { name: "Work", id: "gallery" },
                            { name: "FAQ", id: "faq" }
                        ]}
                        button={{ text: "Schedule Service", href: "#contact" }}
                        className="bg-opacity-95 backdrop-blur-md"
                        navItemClassName="font-medium text-sm tracking-wide"
                        buttonClassName="font-semibold px-6 py-2.5"
                    />
                </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 Plumbing Insights"
                            description="Expert tips, industry updates, and professional guidance from Montana's trusted plumbing specialists"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            carouselMode="buttons"
                            animationType="slide-up"
                            tag="Blog"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterLogoReveal
                        logoText="Montana Plumbing"
                        leftLink={{ text: "Privacy Policy", href: "#" }}
                        rightLink={{ text: "License #12345", href: "#" }}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}