"use client";

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

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

    const navItems = [
        { name: "Home", id: "/" },
        { name: "About Us", id: "/#about" },
        { name: "Menu", id: "/#products" },
        { name: "Testimonials", id: "/#testimonials" },
        { name: "FAQ", id: "/#faq" },
        { name: "Contact", id: "/#contact" },
    ];

    return (
        <ThemeProvider
            defaultButtonVariant="text-stagger"
            defaultTextAnimation="background-highlight"
            borderRadius="soft"
            contentWidth="compact"
            sizing="mediumSizeLargeTitles"
            background="noise"
            cardStyle="solid"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="solid"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        navItems={navItems}
                        brandName="Смачна Випічка"
                        button={{ text: "Order Now", href: "/#contact" }}
                        buttonClassName="min-w-fit px-4 py-2"
                        buttonTextClassName="font-semibold"
                    />
                </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="Featured Articles"
                                description="Explore our latest insights"
                                animationType="slide-up"
                                textboxLayout="default"
                                useInvertedBackground={false}
                            />
                        </div>
                    )}

                    <div id="footer" data-section="footer">
                        <FooterMedia
                            logoText="Смачна Випічка"
                            copyrightText="© 2024 Смачна Випічка. All rights reserved."
                            imageSrc="https://img.b2bpic.net/free-photo/top-view-fresh-bread-with-milk-eggs-dark-blue-surface_179666-44600.jpg"
                            imageAlt="Traditional Ukrainian baking tools"
                            columns={[
                                {
                                    title: "Menu",                                    items: [
                                        { label: "Babka", href: "/#products" },
                                        { label: "Pampushky", href: "/#products" },
                                        { label: "Varenyky", href: "/#products" },
                                    ],
                                },
                                {
                                    title: "Bakery",                                    items: [
                                        { label: "Our Story", href: "/#about" },
                                        { label: "FAQ", href: "/#faq" },
                                        { label: "Contact", href: "/#contact" },
                                    ],
                                },
                            ]}
                            mediaClassName="h-80"
                            mediaWrapperClassName="h-80"
                            logoTextClassName="text-2xl font-bold"
                            copyrightTextClassName="text-sm text-center"
                            columnTitleClassName="font-semibold"
                            columnItemClassName="text-sm"
                            columnsClassName="grid grid-cols-2 lg:grid-cols-3 gap-8"
                            containerClassName="max-w-full px-8"
                        />
                    </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
