"use client";

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

// Navbar import from NAVBAR_INFO
import NavbarStyleApple from '@/components/navbar/NavbarStyleApple/NavbarStyleApple';

// BlogSection import from BLOG_SECTION_REGISTRY
import BlogCardOne from '@/components/sections/blog/BlogCardOne';

// Footer import from FOOTER_INFO
import FooterBase from '@/components/sections/footer/FooterBase';

export default function BlogPage() {
    // Preserved posts fetching logic
    const { posts, isLoading } = useBlogPosts();

    const navItems = [
        { name: "Home", id: "/" },
        { name: "About", id: "/#about" },
        { name: "Shop", id: "/shop" },
        { name: "Blog", id: "/blog" },
        { name: "Testimonials", id: "/#testimonials" },
        { name: "Contact", id: "/#contact" },
    ];

    return (
        <ThemeProvider
            defaultButtonVariant="expand-hover"
            defaultTextAnimation="entrance-slide"
            borderRadius="pill"
            contentWidth="medium"
            sizing="mediumLarge"
            background="floatingGradient"
            cardStyle="solid"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="layered"
            headingFontWeight="light"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleApple
                        brandName="Olla"
                        navItems={navItems}
                    />
                </div>

                {/* Preserved loading state and posts logic */}
                {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">
                        {/* BlogSection with generated props, preserving posts */}
                        <BlogCardOne
                            blogs={posts}
                            title="Latest Articles"
                            description="Insights and updates from our team"
                            animationType="slide-up"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            carouselMode="buttons"
                        />
                    </div>
                )}

                {/* Footer from FOOTER_INFO */}
                <div id="footer" data-section="footer">
                    <FooterBase
                        columns={[
                            {
                                title: "Shop",                                items: [
                                    { label: "Bouquets", href: "/shop#bouquets" },
                                    { label: "Plants", href: "/shop#plants" },
                                    { label: "Occasions", href: "/shop#occasions" },
                                ],
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "/about" },
                                    { label: "Services", href: "/services" },
                                    { label: "FAQ", href: "/faq" },
                                ],
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Contact", href: "/contact" },
                                    { label: "Instagram", href: "https://www.instagram.com/ollastudio" },
                                ],
                            },
                        ]}
                        logoText="Olla"
                        copyrightText="© 2024 Olla Flowers Studio. All rights reserved."
                        ariaLabel="Site footer"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
