"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 NavbarLayoutFloatingInline from '@/components/navbar/NavbarLayoutFloatingInline';
import { useBlogPosts } from "@/hooks/useBlogPosts";

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

    return (
        <ThemeProvider
            defaultButtonVariant="icon-arrow"
            defaultTextAnimation="reveal-blur"
            borderRadius="sharp"
            contentWidth="mediumSmall"
            sizing="mediumLarge"
            background="floatingGradient"
            cardStyle="inset"
            primaryButtonStyle="flat"
            secondaryButtonStyle="glass"
            headingFontWeight="extrabold"
        >
            <ReactLenis root>
                <div className="min-h-screen bg-background">
                    <NavbarLayoutFloatingInline
                        brandName="Apple iPhone Store"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Models", id: "product" },
                            { name: "Features", id: "features" },
                            { name: "Pricing", id: "pricing" },
                            { name: "Support", id: "faq" }
                        ]}
                        button={{ text: "Shop Now", href: "#product" }}
                    />

                    {isLoading ? (
                        <div className="w-content-width mx-auto py-20 text-center">
                            <p className="text-foreground">Loading posts...</p>
                        </div>
                    ) : (
                        <BlogCardThree
                            blogs={posts}
                            title="Featured iPhone Articles"
                            description="Discover the latest insights, reviews, and tips for your iPhone experience"
                            tag="Blog"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            animationType="slide-up"
                            carouselMode="buttons"
                            uniformGridCustomHeightClasses="min-h-[600px]"
                        />
                    )}

                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-vector/abstract-technology-wire-wave-blue-background_1035-17376.jpg"
                        imageAlt="Technology background"
                        logoText="Apple iPhone Store"
                        copyrightText="© 2025 Apple iPhone Store. All rights reserved."
                        columns={[
                            {
                                title: "Products",                                items: [
                                    { label: "iPhone 16 Pro Max", href: "#product" },
                                    { label: "iPhone 16 Pro", href: "#product" },
                                    { label: "iPhone 16", href: "#product" },
                                    { label: "Compare Models", href: "#pricing" }
                                ]
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "Help & FAQ", href: "#faq" },
                                    { label: "Warranty Information", href: "#faq" },
                                    { label: "Trade-In Program", href: "#contact" },
                                    { label: "Contact Us", href: "#contact" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "#" },
                                    { label: "Blog", href: "#" },
                                    { label: "Careers", href: "#" },
                                    { label: "Privacy Policy", href: "#" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}