"use client";

import ReactLenis from "lenis/react";
import BlogCardTwo from '@/components/sections/blog/BlogCardTwo';
import FooterBase from '@/components/sections/footer/FooterBase';
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import type { FooterColumn } from "@/components/shared/FooterColumns";
import NavbarStyleApple from '@/components/navbar/NavbarStyleApple/NavbarStyleApple';
import { useBlogPosts } from "@/hooks/useBlogPosts";

const footerColumns: FooterColumn[] = [
    {
        title: "Product",        items: [
            { label: "Features", href: "features" },
            { label: "Pricing", href: "pricing" },
            { label: "Security", href: "https://example.com/security" },
            { label: "Roadmap", href: "https://example.com/roadmap" },
        ],
    },
    {
        title: "Company",        items: [
            { label: "About", href: "https://example.com/about" },
            { label: "Blog", href: "https://example.com/blog" },
            { label: "Careers", href: "https://example.com/careers" },
            { label: "Contact", href: "contact" },
        ],
    },
    {
        title: "Resources",        items: [
            { label: "Documentation", href: "https://docs.example.com" },
            { label: "API Reference", href: "https://api.example.com" },
            { label: "Integrations", href: "https://example.com/integrations" },
            { label: "Support", href: "https://support.example.com" },
        ],
    },
];

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

    return (
        <ThemeProvider
            defaultButtonVariant="icon-arrow"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="mediumSmall"
            sizing="mediumLargeSizeMediumTitles"
            background="floatingGradient"
            cardStyle="solid"
            primaryButtonStyle="radial-glow"
            secondaryButtonStyle="solid"
            headingFontWeight="light"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleApple
                        brandName="SaaS Pro"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Features", id: "features" },
                            { name: "Pricing", id: "pricing" },
                            { name: "Testimonials", id: "testimonials" },
                            { name: "FAQ", id: "faq" },
                            { name: "Contact", id: "contact" },
                        ]}
                    />
                </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="Stay updated with our latest insights and industry expertise"
                                textboxLayout="default"
                                useInvertedBackground="noInvert"
                                carouselMode="buttons"
                                animationType="slide-up"
                                tag="Blog"
                            />
                        </div>
                    )}

                    <div id="footer" data-section="footer">
                        <FooterBase
                            logoText="SaaS Pro"
                            copyrightText="© 2025 SaaS Pro. All rights reserved."
                            columns={footerColumns}
                        />
                    </div>
            </ReactLenis>
        </ThemeProvider>
    );
}