"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="text-stagger"
            defaultTextAnimation="background-highlight"
            borderRadius="soft"
            contentWidth="compact"
            sizing="largeSmallSizeMediumTitles"
            background="none"
            cardStyle="glass-depth"
            primaryButtonStyle="diagonal-gradient"
            secondaryButtonStyle="solid"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div className="min-h-screen bg-background">
                    <NavbarStyleCentered
                        brandName="Brew Haven"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About", id: "about" },
                            { name: "Products", id: "products" },
                            { name: "Blends", id: "blends" },
                            { name: "Testimonials", id: "testimonials" },
                            { name: "Contact", id: "contact" }
                        ]}
                        button={{ text: "Order Now", href: "contact" }}
                    />

                    {isLoading ? (
                        <div className="w-content-width mx-auto py-20 text-center">
                            <p className="text-foreground">Loading posts...</p>
                        </div>
                    ) : (
                        <BlogCardThree
                            blogs={posts}
                            title="Coffee Chronicles"
                            description="Discover the stories behind our exceptional coffee blends and brewing techniques"
                            tag="Brew Haven Blog"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            carouselMode="buttons"
                            animationType="slide-up"
                        />
                    )}

                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-photo/high-view-cup-coffee-kettle_23-2148337113.jpg"
                        imageAlt="Coffee beans texture footer background"
                        logoText="Brew Haven"
                        copyrightText="© 2025 Brew Haven | Specialty Coffee Roastery. All rights reserved."
                        columns={[
                            {
                                title: "Explore",                                items: [
                                    { label: "Shop Coffee", href: "products" },
                                    { label: "Blends", href: "blends" },
                                    { label: "About Us", href: "about" },
                                    { label: "Contact", href: "contact" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "Our Story", href: "about" },
                                    { label: "Sustainability", href: "#" },
                                    { label: "Careers", href: "#" },
                                    { label: "Press", href: "#" }
                                ]
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Instagram", href: "https://instagram.com" },
                                    { label: "Facebook", href: "https://facebook.com" },
                                    { label: "Newsletter", href: "#" },
                                    { label: "Email", href: "mailto:hello@brewhaven.com" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}