"use client";

import ReactLenis from "lenis/react";
import BlogCardTwo from "@/components/sections/blog/BlogCardTwo";
import FooterBase from "@/components/sections/footer/FooterBase";
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="bounce-effect"
            defaultTextAnimation="background-highlight"
            borderRadius="sharp"
            contentWidth="mediumSmall"
            sizing="medium"
            background="none"
            cardStyle="layered-gradient"
            primaryButtonStyle="flat"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <div className="min-h-screen bg-background">
                    <NavbarLayoutFloatingOverlay
                        brandName="iPhone"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Products", id: "products" },
                            { name: "Features", id: "features" },
                            { name: "Reviews", id: "reviews" },
                            { name: "Contact", id: "contact" }
                        ]}
                        button={{
                            text: "Shop Now",                            href: "#products"
                        }}
                    />

                    {isLoading ? (
                        <div className="w-content-width mx-auto py-20 text-center">
                            <p className="text-foreground">Loading posts...</p>
                        </div>
                    ) : (
                        <BlogCardTwo
                            blogs={posts}
                            title="Latest iPhone News"
                            description="Stay updated with the latest iPhone features, releases, and technology insights"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            carouselMode="buttons"
                            animationType="slide-up"
                            tag="Blog"
                        />
                    )}

                    <FooterBase
                        logoText="iPhone"
                        copyrightText="© 2025 iPhone. All rights reserved."
                        columns={[
                            {
                                title: "Shop",                                items: [
                                    { label: "iPhone Pro Max", href: "#products" },
                                    { label: "iPhone Pro", href: "#products" },
                                    { label: "iPhone Plus", href: "#products" },
                                    { label: "iPhone", href: "#products" }
                                ]
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "Technical Support", href: "#contact" },
                                    { label: "Warranty Info", href: "#contact" },
                                    { label: "FAQs", href: "#contact" },
                                    { label: "Contact Us", href: "#contact" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About iPhone", href: "#features" },
                                    { label: "Sustainability", href: "#features" },
                                    { label: "Careers", href: "#features" },
                                    { label: "Press", href: "#features" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}