"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="hover-bubble"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="mediumSmall"
            sizing="largeSmallSizeLargeTitles"
            background="blurBottom"
            cardStyle="gradient-mesh"
            primaryButtonStyle="radial-glow"
            secondaryButtonStyle="glass"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        brandName="Precision Pools"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Pool Installation", id: "pool-installation" },
                            { name: "Liner Replacement", id: "liner-replacement" },
                            { name: "Pool Services", id: "pool-services" },
                            { name: "Reviews", id: "reviews" },
                            { name: "Contact", id: "contact" }
                        ]}
                        button={{ text: "Call (716) 563-4603", href: "tel:+17165634603" }}
                    />
                </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="Pool Care Insights"
                            description="Expert tips and guides for maintaining your perfect pool"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            animationType="slide-up"
                            carouselMode="buttons"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterLogoEmphasis
                        logoText="Precision Pools"
                        columns={[
                            {
                                items: [
                                    { label: "Home", href: "#home" },
                                    { label: "Pool Installation", href: "#pool-installation" },
                                    { label: "Liner Replacement", href: "#liner-replacement" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Pool Services", href: "#pool-services" },
                                    { label: "Reviews", href: "#reviews" },
                                    { label: "Contact", href: "#contact" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Tonawanda, NY 14150", href: "#" },
                                    { label: "(716) 563-4603", href: "tel:+17165634603" },
                                    { label: "51 Fillmore Ave", href: "#" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}