"use client";

import ReactLenis from "lenis/react";
import BlogCardThree from '@/components/sections/blog/BlogCardThree';
import FooterSimple from '@/components/sections/footer/FooterSimple';
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleApple from '@/components/navbar/NavbarStyleApple/NavbarStyleApple';
import { useBlogPosts } from "@/hooks/useBlogPosts";

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

    return (
        <ThemeProvider
            defaultButtonVariant="elastic-effect"
            defaultTextAnimation="reveal-blur"
            borderRadius="soft"
            contentWidth="mediumLarge"
            sizing="largeSizeMediumTitles"
            background="floatingGradient"
            cardStyle="glass-elevated"
            primaryButtonStyle="flat"
            secondaryButtonStyle="solid"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleApple
                        brandName="Martinez Roofing"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Metal Roofing", id: "services" },
                            { name: "Construction", id: "construction" },
                            { name: "Projects", id: "projects" },
                            { name: "Reviews", id: "reviews" },
                            { name: "Contact", id: "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">
                        <BlogCardThree
                            blogs={posts}
                            title="Latest Roofing Insights"
                            description="Expert advice and updates from Martinez Metal Roofing & Construction professionals"
                            tag="Blog"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            carouselMode="buttons"
                            animationType="slide-up"
                            tagAnimation="opacity"
                            buttonAnimation="opacity"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterSimple
                        columns={[
                            {
                                title: "Navigate",                                items: [
                                    { label: "Home", href: "/" },
                                    { label: "Metal Roofing", href: "/metal-roofing" },
                                    { label: "Construction", href: "/construction" },
                                    { label: "Projects", href: "/projects" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "/about" },
                                    { label: "Reviews", href: "#testimonials" },
                                    { label: "Contact", href: "/contact" }
                                ]
                            },
                            {
                                title: "Services",                                items: [
                                    { label: "Standing Seam Install", href: "/metal-roofing" },
                                    { label: "Repairs & Replacement", href: "/metal-roofing" },
                                    { label: "Custom Projects", href: "/construction" }
                                ]
                            },
                            {
                                title: "Legal",                                items: [
                                    { label: "Privacy Policy", href: "#" },
                                    { label: "Terms of Service", href: "#" }
                                ]
                            }
                        ]}
                        bottomLeftText="© 2025 Martinez Metal Roofing & Construction. All rights reserved."
                        bottomRightText="Built for quality and precision."
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}