"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="icon-arrow"
            defaultTextAnimation="reveal-blur"
            borderRadius="soft"
            contentWidth="mediumLarge"
            sizing="mediumSizeLargeTitles"
            background="noise"
            cardStyle="gradient-mesh"
            primaryButtonStyle="radial-glow"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        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" },
                        ]}
                        brandName="Смачна Випічка"
                        button={{ text: "Order Now", href: "/#products" }}
                        className="py-2 lg:py-4"
                        buttonClassName="px-4 py-2 lg:px-6 lg:py-3 text-sm lg:text-base 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">
                        <BlogCardTwo
                            blogs={posts}
                            title="Latest Articles"
                            description="Insights and updates from our team"
                            animationType="slide-up"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            carouselMode="buttons"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterLogoEmphasis
                        columns={[
                            { items: [{ label: "Home", href: "/#hero" }, { label: "Menu", href: "/#products" }, { label: "About Us", href: "/#about" }] },
                            { items: [{ label: "FAQ", href: "/#faq" }, { label: "Contact", href: "/#contact" }, { label: "Privacy Policy", href: "/privacy" }] },
                            { items: [
                                { label: "Follow Us", href: "https://facebook.com/smachnavypichka", onClick: () => window.open('https://facebook.com/smachnavypichka', '_blank') },
                                { label: "Instagram", href: "https://instagram.com/smachnavypichka", onClick: () => window.open('https://instagram.com/smachnavypichka', '_blank') }
                            ]}
                        ]}
                        logoText="Смачна Випічка"
                        className="bg-card text-foreground/90 py-8 lg:py-12 text-center"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
