"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="elastic-effect"
            defaultTextAnimation="background-highlight"
            borderRadius="pill"
            contentWidth="mediumLarge"
            sizing="largeSmallSizeLargeTitles"
            background="none"
            cardStyle="glass-depth"
            primaryButtonStyle="radial-glow"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="light"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleFullscreen
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Features", id: "features" },
                            { name: "Pricing", id: "pricing" },
                            { name: "Testimonials", id: "testimonials" },
                            { name: "Contact", id: "contact" }
                        ]}
                        brandName="SaaSync"
                        bottomLeftText="Made for modern teams"
                        bottomRightText="hello@saasync.io"
                    />
                </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"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            animationType="slide-up"
                            carouselMode="buttons"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterLogoEmphasis
                        logoText="SaaSync"
                        columns={[
                            {
                                items: [
                                    { label: "Product", href: "#features" },
                                    { label: "Pricing", href: "#pricing" },
                                    { label: "Security", href: "https://saasync.io/security" },
                                    { label: "Updates", href: "https://saasync.io/blog" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Company", href: "https://saasync.io/about" },
                                    { label: "Blog", href: "https://saasync.io/blog" },
                                    { label: "Careers", href: "https://saasync.io/careers" },
                                    { label: "Contact", href: "#contact" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Privacy", href: "https://saasync.io/privacy" },
                                    { label: "Terms", href: "https://saasync.io/terms" },
                                    { label: "Cookies", href: "https://saasync.io/cookies" },
                                    { label: "Status", href: "https://status.saasync.io" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}