"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="shift-hover"
            defaultTextAnimation="background-highlight"
            borderRadius="soft"
            contentWidth="compact"
            sizing="medium"
            background="circleGradient"
            cardStyle="outline"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="glass"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About Us", id: "/#about" },
                            { name: "Products", id: "/#products" },
                            { name: "Testimonials", id: "/#testimonials" },
                            { name: "FAQ", id: "/#faq" },
                            { name: "Contact", id: "/#contact" },
                        ]}
                        brandName="Смачна Пекарня"
                        button={{ text: "Order Now", href: "/#contact" }}
                        className="py-4 px-6"
                    />
                </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="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">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-photo/closeup-fresh-pita-bread-sale_181624-58514.jpg?_wi=4"
                        imageAlt="Cozy bakery interior with warm lighting."
                        columns={[
                            {
                                title: "Меню",                                items: [
                                    { label: "Хліб", href: "/#products" },
                                    { label: "Випічка", href: "/#products" },
                                    { label: "Десерти", href: "/#products" },
                                ],
                            },
                            {
                                title: "Про Нас",                                items: [
                                    { label: "Наша Історія", href: "/#about" },
                                    { label: "Відгуки", href: "/#testimonials" },
                                ],
                            },
                            {
                                title: "Допомога",                                items: [
                                    { label: "FAQ", href: "/#faq" },
                                    { label: "Контакти", href: "/#contact" },
                                ],
                            },
                        ]}
                        logoText="Смачна Пекарня"
                        copyrightText="© 2024 Смачна Пекарня. Всі права захищені."
                        ariaLabel="Bakery website footer"
                        logoTextClassName="text-2xl md:text-3xl font-bold"
                        copyrightTextClassName="text-foreground/70"
                        columnTitleClassName="text-lg font-semibold"
                        columnItemClassName="text-foreground/60 hover:text-foreground transition-colors"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
