"use client";

import ReactLenis from "lenis/react";
import BlogCardTwo from '@/components/sections/blog/BlogCardTwo';
import FooterLogoEmphasis from '@/components/sections/footer/FooterLogoEmphasis';
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="slide-background"
            defaultTextAnimation="background-highlight"
            borderRadius="sharp"
            contentWidth="compact"
            sizing="largeSmallSizeMediumTitles"
            background="circleGradient"
            cardStyle="gradient-bordered"
            primaryButtonStyle="diagonal-gradient"
            secondaryButtonStyle="glass"
            headingFontWeight="light"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        brandName="PropertyHub"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Browse", id: "featured" },
                            { name: "Search", id: "search" },
                            { name: "Map View", id: "map" },
                            { name: "Reviews", id: "testimonials" },
                            { name: "Contact", id: "contact" }
                        ]}
                        button={{ text: "Get Started", href: "#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="Property Insights & News"
                            description="Stay informed with the latest real estate trends, market updates, and expert insights from PropertyHub professionals."
                            tag="Blog"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            carouselMode="buttons"
                            animationType="slide-up"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterLogoEmphasis
                        logoText="PropertyHub"
                        columns={[
                            {
                                items: [
                                    { label: "Browse Properties", href: "#featured" },
                                    { label: "Advanced Search", href: "#search" },
                                    { label: "Map View", href: "#map" }
                                ]
                            },
                            {
                                items: [
                                    { label: "For Sellers", href: "#" },
                                    { label: "List Property", href: "#" },
                                    { label: "Marketing Tools", href: "#" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Resources", href: "#" },
                                    { label: "Market Guide", href: "#" },
                                    { label: "FAQ", href: "#contact" }
                                ]
                            },
                            {
                                items: [
                                    { label: "About Us", href: "#" },
                                    { label: "Contact", href: "#contact" },
                                    { label: "Careers", href: "#" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}