"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import { useBlogPosts } from "@/hooks/useBlogPosts";

// Navbar import
import NavbarLayoutFloatingOverlay from '@/components/navbar/NavbarLayoutFloatingOverlay/NavbarLayoutFloatingOverlay';

// Blog Section import
import BlogCardOne from '@/components/sections/blog/BlogCardOne';

// Footer import
import FooterMedia from '@/components/sections/footer/FooterMedia';

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

    return (
        <ThemeProvider
            defaultButtonVariant="text-stagger"
            defaultTextAnimation="reveal-blur"
            borderRadius="pill"
            contentWidth="smallMedium"
            sizing="largeSmallSizeMediumTitles"
            background="blurBottom"
            cardStyle="soft-shadow"
            primaryButtonStyle="inset-glow"
            secondaryButtonStyle="solid"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        brandName="Lviv Bakery"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Menu", id: "products" },
                            { name: "About Us", id: "about" },
                            { name: "Reviews", id: "testimonials" },
                            { name: "FAQ", id: "faq" },
                            { name: "Contact", id: "contact" },
                        ]}
                        button={{ text: "Order Now", href: "#contact" }}
                        className="py-4 px-6"
                        buttonClassName="px-5 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">
                        <BlogCardOne
                            blogs={posts}
                            title="Latest Articles"
                            description="Insights and updates from our team"
                            animationType="slide-up"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            carouselMode="buttons"
                            ariaLabel="Our latest blog posts"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-photo/white-cheese-bread-with-eggs_140725-3991.jpg?_wi=3"
                        imageAlt="Ukrainian pastries on display in a bakery"
                        columns={[
                            {
                                title: "Bakery",                                items: [
                                    { label: "Our Story", href: "#about" },
                                    { label: "Products", href: "#products" },
                                    { label: "FAQs", href: "#faq" },
                                ],
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Contact Us", href: "#contact" },
                                    { label: "Instagram", href: "https://www.instagram.com/lvivbakery" },
                                    { label: "Facebook", href: "https://www.facebook.com/lvivbakery" },
                                ],
                            },
                        ]}
                        logoText="Lviv Bakery"
                        copyrightText="© 2024 Lviv Bakery. All rights reserved."
                        ariaLabel="Site footer with navigation and social links"
                        logoTextClassName="text-foreground"
                        copyrightTextClassName="text-foreground/80"
                        columnTitleClassName="text-foreground text-lg font-semibold"
                        columnItemClassName="text-foreground/80 hover:text-primary-cta transition-colors"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
