"use client";

import ReactLenis from "lenis/react";
import BlogCardOne from "@/components/sections/blog/BlogCardOne";
import FooterMedia from '@/components/sections/footer/FooterMedia';
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="text-shift"
            defaultTextAnimation="background-highlight"
            borderRadius="sharp"
            contentWidth="mediumSmall"
            sizing="medium"
            background="none"
            cardStyle="inset"
            primaryButtonStyle="inset-glow"
            secondaryButtonStyle="solid"
            headingFontWeight="light"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        brandName="Midnight Coffee"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Our Story", id: "about" },
                            { name: "Process", id: "process" },
                            { name: "Shop", id: "products" },
                            { name: "Reviews", id: "testimonials" },
                            { name: "Contact", id: "contact" }
                        ]}
                        button={{ text: "Order Now", href: "#products" }}
                    />
                </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="Coffee Stories & Insights"
                            description="Discover the art and science behind every cup, from bean to brew"
                            tag="Blog"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            carouselMode="buttons"
                            animationType="slide-up"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-photo/fragrant-coffee-beans-are-scattered-from-jar-rustic-tabletop-background-closeup-selective-focus-copy-space-banner_166373-2309.jpg"
                        imageAlt="Premium coffee shop aesthetic"
                        logoText="Midnight Coffee"
                        copyrightText="© 2025 Midnight Coffee. All rights reserved."
                        columns={[
                            {
                                title: "Shop",                                items: [
                                    { label: "All Coffees", href: "#products" },
                                    { label: "Subscribe", href: "#contact" },
                                    { label: "Gift Cards", href: "#" },
                                    { label: "Brewing Gear", href: "#" }
                                ]
                            },
                            {
                                title: "About",                                items: [
                                    { label: "Our Story", href: "#about" },
                                    { label: "Sourcing", href: "#process" },
                                    { label: "Roasting Process", href: "#process" },
                                    { label: "Sustainability", href: "#" }
                                ]
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Contact Us", href: "#contact" },
                                    { label: "Instagram", href: "#" },
                                    { label: "Book a Tasting", href: "#contact" },
                                    { label: "Wholesale Inquiry", href: "#" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}