"use client";

import { useState } from "react";
import {
    FlameKindling,
    Shield,
    Droplets,
    HeartPulse,
    ThermometerSnowflake,
    Dumbbell,
    VolumeX,
    Wrench,
    Feather,
    Anvil,
    Leaf,
    Maximize2,
    Eraser,
    Gem,
    Layout,
    Globe2,
    Sparkles,
    ChevronDown,
    Sun,
    Paintbrush,
    Wind,
    ChevronUp
} from "lucide-react";
import { cn } from "@/lib/utils";
import ImageComparison from "@/components/ImageComparison";

const advantages = [
    { icon: FlameKindling, title: "Fire Retardant", desc: "Non-combustible ASA material for maximum safety." },
            { icon: Droplets, title: "Water Resistant", desc: "100% leak-proof interlocking design." },
{ icon: ThermometerSnowflake, title: "Lower Heat Levels", desc: "Advanced thermal insulation reflects solar radiation." },
    { icon: Feather, title: "Light Weight", desc: "Reduces load on the roof structure significantly." },
    
    { icon: Wrench, title: "Easy to Fix", desc: "Designed for rapid, professional installation." },
    { icon: Layout, title: "Simple Structure", desc: "Minimal framing required due to material strength." },
{ icon: HeartPulse, title: "No Cancer Effect", desc: "100% Asbestos-free and non-carcinogenic material." },
    { icon: Dumbbell, title: "Strong", desc: "High impact resistance and structural integrity." },
    
    
    { icon: VolumeX, title: "Sound Insulation", desc: "Quiet during heavy rain compared to traditional metal." },
        { icon: Sun, title: "UV Protection", desc: "Advanced ASA coating blocks harmful ultraviolet radiation." },
    { icon: Maximize2, title: "Customizable Sizes", desc: "Available in lengths to suit your specific project." },
    { icon: Paintbrush, title: "Zero Maintenance", desc: "Never requires repainting or specialized cleaning." },
        
    { icon: Shield, title: "Durable", desc: "Engineered to last for decades without degradation." },
        { icon: Wind, title: "Wind Resistance", desc: "Secure interlocking design withstands strong winds and harsh weather." },
        { icon: Sparkles, title: "Superior Finish", desc: "Vibrant colors that resist UV fading for years." },
{ icon: Anvil, title: "Anti Corrosion", desc: "Rust-proof material even in coastal environments." },
    
    { icon: Eraser, title: "Scratch Resistant", desc: "Hard-wearing layer protects aesthetic finish." },
    { icon: Globe2, title: "Any Climate Tolerance", desc: "Performs reliably in hot, rainy, coastal, and changing weather conditions." },
    
    { icon: Leaf, title: "Eco Friendly", desc: "Sustainable manufacturing and recyclable materials." },
{ icon: Gem, title: "Does not change the shape", desc: "Maintains form under extreme temperature shifts." },
];

export default function WhyIRoof() {
    const [isExpanded, setIsExpanded] = useState(false);

    const handleToggleExpand = () => {
        setIsExpanded(!isExpanded);
    };

    return (
        <section id="why-iroof-edge" className=" bg-gray-50 pt-12 overflow-hidden relative">
            <div className="max-w-[1400px] mx-auto px-8 md:px-16 lg:px-32 xl:px-40 relative">


                <div className=" overflow-hidden border border-brand-dark/5 bg-white shadow-sm mb-16 pr-16 relative">
                    <div className="grid grid-cols-1 xl:grid-cols-4 bg-brand-dark/5 gap-[1px]">
                        {advantages.map((item, i) => (
                            <div
                                key={i}
                                className={cn(
                                    "group relative bg-white p-6 transition-colors duration-500 hover:bg-zinc-50/80 flex flex-col items-start text-left h-full overflow-hidden",
                                    !isExpanded && i >= 4 && i < 8 ? "hidden xl:flex" : "",
                                    !isExpanded && i >= 12 ? "hidden" : ""
                                )}
                            >
                                <div className="text-brand-accent mb-4 transition-transform duration-500 group-hover:scale-110">
                                    <item.icon size={28} strokeWidth={2} />
                                </div>
                                <h3 className="text-[12px] md:text-[14px] font-black text-brand-dark uppercase tracking-tight mb-2">
                                    {item.title}
                                </h3>
                                <p className="text-[12px] md:text-[14px] text-zinc-500 font-normal leading-relaxed">
                                    {item.desc}
                                </p>
                                <div className="absolute bottom-0 left-0 right-0 h-[4px] bg-brand-accent scale-x-0 group-hover:scale-x-100 transition-transform duration-300 origin-left" />
                            </div>
                        ))}
                    </div>

                    {/* Right-Side Intersecting Toggle Arrow */}
                    <div className="absolute top-1/2 -right-8 -translate-y-1/2 flex items-center z-10 hidden xl:block group/arrow pr-12">
                        <button
                            type="button"
                            onClick={handleToggleExpand}
                            aria-expanded={isExpanded}
                            aria-label={isExpanded ? "Show fewer advantages" : "Show more advantages"}
                            className="w-16 h-16 rounded-full bg-brand-dark text-white border-4 border-white flex items-center justify-center shadow-xl hover:bg-brand-accent transition-all duration-500 hover:scale-110 relative"
                        >

                            {isExpanded ? <ChevronUp className="w-6 h-6" /> : <ChevronDown className="w-6 h-6" />}
                        </button>
                    </div>
                </div>

                <div className="text-right mb-24 reveal-up xl:hidden">
                    <button
                        type="button"
                        onClick={handleToggleExpand}
                        aria-expanded={isExpanded}
                        className="inline-flex items-center gap-4 bg-brand-dark text-white px-8 py-3 rounded-full text-[10px] font-black uppercase tracking-[0.2em] transition-all duration-500 hover:bg-brand-accent shadow-xl"
                    >
                        <span>{isExpanded ? "Show less" : "See more"}</span>
                        {isExpanded ? <ChevronUp className="w-4 h-4" /> : <ChevronDown className="w-4 h-4" />}
                    </button>
                </div>

                {/* Image Comparison Slider Section */}
                <div className="scale-up mt-12 pb-12">
                    
                    <ImageComparison
                        beforeImage="/images/2093-x-1096-web-image-01.webp"
                        afterImage="/images/2093-x-1096-web-image-02.webp"
                        beforeLabel="BENCHMARK"
                        beforeTitle="Standard"
                        beforeDesc="Vulnerable to cracks, fading, and rapid decay in tropical weather."
                        afterLabel="ENGINEERED"
                        afterTitle="i-Roof"
                        afterDesc="Indestructible ASA-Shield technology for lifetime structural integrity."
                    />
                </div>
            </div>
        </section>
    );
}
