"use client";

import ReactLenis from "lenis/react";
import BlogCardOne from "@/components/sections/blog/BlogCardOne";
import FooterBase from "@/components/sections/footer/FooterBase";
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="soft"
            contentWidth="small"
            sizing="largeSmall"
            background="circleGradient"
            cardStyle="glass-elevated"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="glass"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleFullscreen
                        brandName="InsightFlow"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Features", id: "features" },
                            { name: "Metrics", id: "metrics" },
                            { name: "Pricing", id: "pricing" },
                            { name: "Contact", id: "contact" },
                            { name: "Blog", id: "/blog" }
                        ]}
                        bottomLeftText="AI-Powered Analytics"
                        bottomRightText="hello@insightflow.ai"
                    />
                </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 Insights"
                            description="Discover the latest analytics insights and industry trends from our expert team"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            animationType="slide-up"
                            carouselMode="buttons"
                            tag="Blog"
                            tagAnimation="slide-up"
                            buttons={[
                                { text: "View All Posts", href: "#" }
                            ]}
                            buttonAnimation="slide-up"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterBase
                        logoText="InsightFlow"
                        copyrightText="© 2025 InsightFlow. All rights reserved."
                        columns={[
                            {
                                title: "Product",                                items: [
                                    { label: "Features", href: "#features" },
                                    { label: "Pricing", href: "#pricing" },
                                    { label: "Security", href: "#" },
                                    { label: "Roadmap", href: "#" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "#" },
                                    { label: "Blog", href: "/blog" },
                                    { label: "Careers", href: "#" },
                                    { label: "Contact", href: "#contact" }
                                ]
                            },
                            {
                                title: "Resources",                                items: [
                                    { label: "Documentation", href: "#" },
                                    { label: "API Reference", href: "#" },
                                    { label: "Community", href: "#" },
                                    { label: "Status", href: "#" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
