"use client";

import ReactLenis from "lenis/react";
import BlogCardThree from "@/components/sections/blog/BlogCardThree";
import FooterBase from "@/components/sections/footer/FooterBase";
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="icon-arrow"
            defaultTextAnimation="background-highlight"
            borderRadius="pill"
            contentWidth="mediumLarge"
            sizing="largeSmall"
            background="none"
            cardStyle="soft-shadow"
            primaryButtonStyle="radial-glow"
            secondaryButtonStyle="layered"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingInline
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Menu", id: "features" },
                            { name: "About", id: "about" },
                            { name: "Locations", id: "contact" },
                            { name: "Blog", id: "/blog" }
                        ]}
                        brandName="Brew Haven"
                        button={{ text: "Order Now", href: "#product" }}
                    />
                </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="Our Latest Blog Posts"
                            description="Discover insights, tips, and stories from Brew Haven"
                            tag="Blog"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            carouselMode="buttons"
                            animationType="slide-up"
                            ariaLabel="Blog section"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterBase
                        logoText="Brew Haven"
                        copyrightText="© 2025 | Brew Haven Coffee Co."
                        columns={[
                            {
                                title: "Menu",                                items: [
                                    { label: "Coffee", href: "#features" },
                                    { label: "Pastries", href: "#features" },
                                    { label: "Shop Beans", href: "#product" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "#about" },
                                    { label: "Locations", href: "#contact" },
                                    { label: "Careers", href: "#" }
                                ]
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Instagram", href: "https://instagram.com" },
                                    { label: "Contact", href: "#contact" },
                                    { label: "Newsletter", href: "#" }
                                ]
                            }
                        ]}
                        ariaLabel="Site footer"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
