"use client";

import ReactLenis from "lenis/react";
import BlogCardThree from '@/components/sections/blog/BlogCardThree';
import FooterMedia from '@/components/sections/footer/FooterMedia';
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarLayoutFloatingOverlay from '@/components/navbar/NavbarLayoutFloatingOverlay/NavbarLayoutFloatingOverlay';
import { useBlogPosts } from "@/hooks/useBlogPosts";

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

    return (
        <ThemeProvider
            defaultButtonVariant="expand-hover"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="smallMedium"
            sizing="mediumLarge"
            background="aurora"
            cardStyle="layered-gradient"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="solid"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        brandName="Dashboard"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Overview", id: "overview" },
                            { name: "Analytics", id: "analytics" },
                            { name: "Reports", id: "reports" },
                            { name: "Settings", id: "settings" },
                            { name: "Help", id: "help" }
                        ]}
                        button={{
                            text: "Sign Out",                            href: "#"
                        }}
                    />
                </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">
                        <BlogCardThree
                            blogs={posts}
                            title="Dashboard Analytics Blog"
                            description="Stay updated with the latest insights, tips, and trends in dashboard analytics and data visualization"
                            tag="Insights"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            animationType="slide-up"
                            carouselMode="buttons"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-vector/dashboard-user-panel-template_52683-29391.jpg"
                        imageAlt="Dashboard footer background"
                        logoText="Dashboard Pro"
                        copyrightText="© 2025 Dashboard Analytics. All rights reserved."
                        columns={[
                            {
                                title: "Product",                                items: [
                                    { label: "Features", href: "#features" },
                                    { label: "Pricing", href: "#pricing" },
                                    { label: "Security", href: "#security" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About", href: "#about" },
                                    { label: "Blog", href: "#blog" },
                                    { label: "Careers", href: "#careers" }
                                ]
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "Documentation", href: "#docs" },
                                    { label: "Contact", href: "#contact" },
                                    { label: "Status", href: "#status" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}