import { Head } from '@inertiajs/react';
import Layout from '@/Components/Layout';
import TestimonialCard from '@/Components/TestimonialCard';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
    Sparkles,
    MessageCircleHeart,
    Star,
    Quote,
    Users,
    ArrowRight,
    Heart,
    ThumbsUp,
    Award,
    Smile,
    TrendingUp,
    CheckCircle2,
    Shield,
    Headphones,
    Trophy
} from 'lucide-react';

interface Testimonial {
    id: number;
    client_name: string;
    designation?: string;
    company?: string;
    photo?: string;
    message: string;
    rating?: number;
    featured?: boolean;
}

interface Props {
    testimonials: Testimonial[];
    settings?: any;
}

const trustReasons = [
    {
        icon: Award,
        title: 'Award-Winning Quality',
        description: 'Every project is held to the same rigorous standards that earn our reputation. No shortcuts, ever.',
        color: 'from-amber-500 to-orange-500'
    },
    {
        icon: Headphones,
        title: 'Always-On Support',
        description: 'Real engineers — not ticket queues. Reach us by Slack, email, or call when you need a hand.',
        color: 'from-purple-500 to-pink-500'
    },
    {
        icon: Shield,
        title: 'Trustworthy Delivery',
        description: 'Clear estimates, honest timelines, no surprise invoices. We say what we will do, then do it.',
        color: 'from-blue-500 to-cyan-500'
    },
    {
        icon: Heart,
        title: 'Genuine Partnership',
        description: 'We invest in your outcome. Long-term relationships matter more than one-off project wins.',
        color: 'from-emerald-500 to-green-500'
    }
];

export default function TestimonialsIndex({ testimonials, settings }: Props) {
    const featuredTestimonials = testimonials.filter(t => t.featured);
    const regularTestimonials = testimonials.filter(t => !t.featured);

    const totalTestimonials = testimonials.length;
    const ratingsSum = testimonials.reduce((sum, t) => sum + (t.rating ?? 5), 0);
    const avgRating = totalTestimonials > 0 ? (ratingsSum / totalTestimonials).toFixed(1) : '5.0';
    const fiveStarCount = testimonials.filter(t => (t.rating ?? 5) >= 5).length;

    return (
        <Layout settings={settings}>
            <Head title="Client Testimonials | What Our Clients Say" />

            {/* Hero Section - Light Modern Style */}
            <section className="relative overflow-hidden bg-gradient-to-br from-slate-50 via-white to-blue-50/40 min-h-[700px] md:min-h-[750px] lg:min-h-[800px] flex items-center">
                {/* Subtle Mesh Gradient Background */}
                <div className="absolute inset-0 overflow-hidden">
                    <div className="absolute -top-40 -left-40 w-[600px] h-[600px] bg-primary/15 rounded-full filter blur-3xl animate-pulse" />
                    <div className="absolute top-20 -right-40 w-[600px] h-[600px] bg-purple-500/15 rounded-full filter blur-3xl animate-pulse" style={{ animationDelay: '2s' }} />
                    <div className="absolute -bottom-40 left-1/4 w-[600px] h-[600px] bg-cyan-500/15 rounded-full filter blur-3xl animate-pulse" style={{ animationDelay: '4s' }} />
                </div>

                {/* Grid Pattern - very subtle */}
                <div className="absolute inset-0 bg-[linear-gradient(to_right,#cbd5e10a_1px,transparent_1px),linear-gradient(to_bottom,#cbd5e10a_1px,transparent_1px)] bg-[size:48px_48px]" />

                <div className="container mx-auto px-4 py-20 relative z-10">
                    <div className="grid lg:grid-cols-2 gap-12 items-center">
                        {/* Left: Text Content */}
                        <div className="space-y-8">
                            <div className="inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white border border-slate-200 shadow-sm text-slate-700 text-sm">
                                <span className="relative flex h-2 w-2">
                                    <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span>
                                    <span className="relative inline-flex rounded-full h-2 w-2 bg-emerald-500"></span>
                                </span>
                                <span>Loved by Clients Worldwide</span>
                            </div>

                            <h1 className="text-5xl md:text-6xl lg:text-7xl font-bold text-slate-900 leading-[1.05] tracking-tight">
                                What Our Clients{' '}
                                <span className="bg-gradient-to-r from-primary via-blue-500 to-purple-500 bg-clip-text text-transparent">
                                    Say About Us
                                </span>
                            </h1>

                            <p className="text-lg md:text-xl text-slate-600 leading-relaxed max-w-xl">
                                Real stories from real partners. Hear how teams across industries describe what it's like to work with HomeTech — in their own words.
                            </p>

                            <div className="flex flex-col sm:flex-row gap-4">
                                <Button
                                    size="lg"
                                    className="bg-gradient-to-r from-primary to-blue-600 hover:from-primary/90 hover:to-blue-500 text-white font-semibold px-8 h-14 text-base group shadow-lg shadow-primary/50"
                                >
                                    <a href="#testimonials-grid" className="flex items-center gap-2 text-white">
                                        Read Testimonials
                                        <ArrowRight className="w-5 h-5 group-hover:translate-x-1 transition-transform" />
                                    </a>
                                </Button>
                                <Button
                                    size="lg"
                                    variant="outline"
                                    className="bg-white border-slate-200 text-slate-700 hover:bg-slate-50 hover:text-slate-900 font-semibold px-8 h-14 text-base"
                                >
                                    <a href="/contact" className="text-slate-700">Become a Client</a>
                                </Button>
                            </div>

                            <div className="flex flex-wrap items-center gap-6 pt-4 text-slate-500 text-sm">
                                <div className="flex items-center gap-2">
                                    <Sparkles className="w-4 h-4 text-amber-500" />
                                    <span>{totalTestimonials}+ Reviews</span>
                                </div>
                                <div className="flex items-center gap-2">
                                    <Sparkles className="w-4 h-4 text-amber-500" />
                                    <span>{avgRating} Avg Rating</span>
                                </div>
                                <div className="flex items-center gap-2">
                                    <Sparkles className="w-4 h-4 text-amber-500" />
                                    <span>98% Recommend</span>
                                </div>
                            </div>
                        </div>

                        {/* Right: Testimonial Showcase Animation */}
                        <div className="relative hidden lg:block max-w-[480px] ml-auto w-full">
                            <div className="absolute inset-0 bg-gradient-to-r from-primary to-purple-500 rounded-3xl blur-3xl opacity-30" />
                            <div className="relative rounded-3xl overflow-hidden border border-white/10 shadow-2xl bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 aspect-square">

                                {/* Background Grid */}
                                <div className="absolute inset-0 bg-[linear-gradient(to_right,#80808015_1px,transparent_1px),linear-gradient(to_bottom,#80808015_1px,transparent_1px)] bg-[size:32px_32px]" />

                                {/* Scanning Line */}
                                <div className="absolute inset-0 overflow-hidden pointer-events-none">
                                    <div className="absolute inset-x-0 h-px bg-gradient-to-r from-transparent via-cyan-400 to-transparent animate-scan-vertical" />
                                </div>

                                {/* Floating Elements */}
                                <div className="absolute inset-0 p-6">
                                    {/* Mini Testimonial Card 1 - Top Left */}
                                    <div className="absolute top-8 left-6 w-36 rounded-xl bg-white/95 backdrop-blur-sm shadow-xl animate-float p-3 overflow-hidden">
                                        <div className="flex items-center gap-2 mb-2">
                                            <div className="w-7 h-7 rounded-full bg-gradient-to-br from-blue-500 to-cyan-500 flex items-center justify-center text-white text-xs font-bold">
                                                A
                                            </div>
                                            <div className="flex-1 min-w-0">
                                                <div className="h-1.5 bg-slate-300 rounded w-3/4 mb-1" />
                                                <div className="h-1 bg-slate-200 rounded w-1/2" />
                                            </div>
                                        </div>
                                        <div className="flex gap-0.5 mb-2">
                                            {[1, 2, 3, 4, 5].map(i => (
                                                <Star key={i} className="w-2.5 h-2.5 fill-amber-400 text-amber-400" />
                                            ))}
                                        </div>
                                        <div className="space-y-1">
                                            <div className="h-1.5 bg-slate-200 rounded" />
                                            <div className="h-1.5 bg-slate-200 rounded w-5/6" />
                                            <div className="h-1.5 bg-slate-200 rounded w-2/3" />
                                        </div>
                                    </div>

                                    {/* Mini Testimonial Card 2 - Top Right */}
                                    <div className="absolute top-12 right-4 w-32 rounded-xl bg-gradient-to-br from-purple-500 to-pink-500 shadow-xl animate-float p-3 overflow-hidden text-white" style={{ animationDelay: '1s' }}>
                                        <Quote className="w-5 h-5 text-white/80 mb-1" />
                                        <div className="space-y-1 mb-2">
                                            <div className="h-1.5 bg-white/40 rounded" />
                                            <div className="h-1.5 bg-white/30 rounded w-3/4" />
                                            <div className="h-1.5 bg-white/30 rounded w-1/2" />
                                        </div>
                                        <div className="flex gap-0.5">
                                            {[1, 2, 3, 4, 5].map(i => (
                                                <Star key={i} className="w-2 h-2 fill-amber-300 text-amber-300" />
                                            ))}
                                        </div>
                                    </div>

                                    {/* Center Featured Card */}
                                    <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-52 rounded-2xl bg-white shadow-2xl border border-slate-100 p-4 z-10">
                                        <div className="flex items-center justify-between mb-3">
                                            <Quote className="w-6 h-6 text-primary" />
                                            <Badge className="bg-gradient-to-r from-violet-500 to-purple-500 text-white border-0 text-[10px]">
                                                <Sparkles className="w-2.5 h-2.5 mr-1" />
                                                Featured
                                            </Badge>
                                        </div>
                                        <div className="space-y-1.5 mb-3">
                                            <div className="h-2 bg-slate-200 rounded" />
                                            <div className="h-2 bg-slate-200 rounded w-5/6" />
                                            <div className="h-2 bg-slate-200 rounded w-3/4" />
                                            <div className="h-2 bg-slate-200 rounded w-1/2" />
                                        </div>
                                        <div className="flex gap-1 mb-3">
                                            {[1, 2, 3, 4, 5].map(i => (
                                                <Star key={i} className="w-3 h-3 fill-amber-400 text-amber-400" />
                                            ))}
                                        </div>
                                        <div className="flex items-center gap-2 pt-3 border-t border-slate-100">
                                            <div className="w-8 h-8 rounded-full bg-gradient-to-br from-primary to-purple-600 flex items-center justify-center text-white text-xs font-bold">
                                                S
                                            </div>
                                            <div className="flex-1">
                                                <div className="h-1.5 bg-slate-300 rounded w-3/4 mb-1" />
                                                <div className="h-1 bg-slate-200 rounded w-1/2" />
                                            </div>
                                        </div>
                                    </div>

                                    {/* Mini Testimonial Card 3 - Bottom Left */}
                                    <div className="absolute bottom-12 left-6 w-32 rounded-xl bg-gradient-to-br from-emerald-500 to-teal-500 shadow-xl animate-float p-3 overflow-hidden text-white" style={{ animationDelay: '0.5s' }}>
                                        <div className="flex items-center gap-2 mb-2">
                                            <ThumbsUp className="w-4 h-4 text-white" />
                                            <div className="h-1.5 bg-white/50 rounded flex-1" />
                                        </div>
                                        <div className="space-y-1 mb-2">
                                            <div className="h-1.5 bg-white/40 rounded" />
                                            <div className="h-1.5 bg-white/30 rounded w-2/3" />
                                        </div>
                                        <div className="flex gap-0.5">
                                            {[1, 2, 3, 4, 5].map(i => (
                                                <Star key={i} className="w-2 h-2 fill-amber-300 text-amber-300" />
                                            ))}
                                        </div>
                                    </div>

                                    {/* Mini Testimonial Card 4 - Bottom Right */}
                                    <div className="absolute bottom-8 right-4 w-36 rounded-xl bg-white/95 backdrop-blur-sm shadow-xl animate-float p-3 overflow-hidden" style={{ animationDelay: '1.5s' }}>
                                        <div className="flex items-center gap-2 mb-2">
                                            <div className="w-7 h-7 rounded-full bg-gradient-to-br from-amber-500 to-orange-500 flex items-center justify-center text-white text-xs font-bold">
                                                M
                                            </div>
                                            <div className="flex-1 min-w-0">
                                                <div className="h-1.5 bg-slate-300 rounded w-3/4 mb-1" />
                                                <div className="h-1 bg-slate-200 rounded w-1/2" />
                                            </div>
                                        </div>
                                        <div className="space-y-1 mb-2">
                                            <div className="h-1.5 bg-slate-200 rounded" />
                                            <div className="h-1.5 bg-slate-200 rounded w-5/6" />
                                        </div>
                                        <div className="flex gap-0.5">
                                            {[1, 2, 3, 4, 5].map(i => (
                                                <Star key={i} className="w-2.5 h-2.5 fill-amber-400 text-amber-400" />
                                            ))}
                                        </div>
                                    </div>

                                    {/* Floating Heart Particles */}
                                    <div className="absolute top-1/4 right-1/3">
                                        <Heart className="w-4 h-4 text-pink-400 fill-pink-400 animate-pulse" />
                                    </div>
                                    <div className="absolute bottom-1/3 left-1/3">
                                        <Sparkles className="w-3 h-3 text-amber-300 animate-pulse" style={{ animationDelay: '1s' }} />
                                    </div>
                                    <div className="absolute top-1/3 left-1/4">
                                        <Star className="w-3 h-3 fill-amber-300 text-amber-300 animate-pulse" style={{ animationDelay: '2s' }} />
                                    </div>
                                </div>

                                {/* Connection Lines */}
                                <svg className="absolute inset-0 w-full h-full pointer-events-none" viewBox="0 0 500 500" preserveAspectRatio="xMidYMid meet">
                                    <defs>
                                        <linearGradient id="testimonialConn" x1="0%" y1="0%" x2="100%" y2="0%">
                                            <stop offset="0%" stopColor="#06b6d4" stopOpacity="0" />
                                            <stop offset="50%" stopColor="#a855f7" stopOpacity="0.6" />
                                            <stop offset="100%" stopColor="#06b6d4" stopOpacity="0" />
                                        </linearGradient>
                                    </defs>
                                    <g opacity="0.4" stroke="url(#testimonialConn)" strokeWidth="1" fill="none" strokeDasharray="4 4">
                                        <line x1="120" y1="100" x2="250" y2="250">
                                            <animate attributeName="opacity" values="0.2;0.8;0.2" dur="3s" repeatCount="indefinite" />
                                        </line>
                                        <line x1="380" y1="120" x2="250" y2="250">
                                            <animate attributeName="opacity" values="0.2;0.8;0.2" dur="2.5s" repeatCount="indefinite" />
                                        </line>
                                        <line x1="100" y1="380" x2="250" y2="250">
                                            <animate attributeName="opacity" values="0.2;0.8;0.2" dur="2.8s" repeatCount="indefinite" />
                                        </line>
                                        <line x1="380" y1="380" x2="250" y2="250">
                                            <animate attributeName="opacity" values="0.2;0.8;0.2" dur="3.2s" repeatCount="indefinite" />
                                        </line>
                                    </g>

                                    {/* Corner Accents */}
                                    <g stroke="#06b6d4" strokeWidth="2" fill="none" opacity="0.5">
                                        <path d="M 20 20 L 50 20 L 50 22" />
                                        <path d="M 480 20 L 450 20 L 450 22" />
                                        <path d="M 20 480 L 50 480 L 50 478" />
                                        <path d="M 480 480 L 450 480 L 450 478" />
                                    </g>
                                </svg>

                                {/* Live Stats - Top Left */}
                                <div className="absolute top-4 left-4 bg-black/40 backdrop-blur-md border border-cyan-500/30 rounded-lg px-3 py-2">
                                    <div className="flex items-center gap-2">
                                        <div className="w-2 h-2 rounded-full bg-emerald-400 animate-pulse" />
                                        <span className="text-cyan-400 text-xs font-mono">5-STAR</span>
                                    </div>
                                    <div className="text-white text-xs font-mono mt-1">
                                        <span className="text-white/60">Avg:</span> <span className="text-cyan-300">{avgRating} / 5</span>
                                    </div>
                                </div>

                                {/* Live Stats - Bottom Right */}
                                <div className="absolute bottom-4 right-4 bg-black/40 backdrop-blur-md border border-purple-500/30 rounded-lg px-3 py-2">
                                    <div className="text-purple-300 text-xs font-mono">
                                        <span className="text-white/60">Reviews:</span> {totalTestimonials}+
                                    </div>
                                    <div className="text-purple-300 text-xs font-mono mt-1">
                                        <span className="text-white/60">Recommend:</span> 98%
                                    </div>
                                </div>
                            </div>

                            {/* Floating Badge - Top Right */}
                            <div className="absolute -top-4 -right-4 bg-white border border-slate-200 rounded-2xl p-4 shadow-xl">
                                <div className="flex items-center gap-3">
                                    <div className="w-10 h-10 rounded-full bg-gradient-to-br from-amber-400 to-orange-500 flex items-center justify-center">
                                        <Star className="w-5 h-5 text-white fill-white" />
                                    </div>
                                    <div>
                                        <div className="text-slate-900 font-bold text-lg">{avgRating}</div>
                                        <div className="text-slate-500 text-xs">Avg Rating</div>
                                    </div>
                                </div>
                            </div>

                            {/* Floating Badge - Bottom Left */}
                            <div className="absolute -bottom-4 -left-4 bg-white border border-slate-200 rounded-2xl p-4 shadow-xl">
                                <div className="flex items-center gap-3">
                                    <div className="w-10 h-10 rounded-full bg-gradient-to-br from-emerald-400 to-teal-500 flex items-center justify-center">
                                        <Smile className="w-5 h-5 text-white" />
                                    </div>
                                    <div>
                                        <div className="text-slate-900 font-bold text-lg">{totalTestimonials}+</div>
                                        <div className="text-slate-500 text-xs">Happy Clients</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>

            {/* Stats Bar */}
            <div className="py-12 bg-white border-b border-slate-100">
                <div className="container mx-auto px-4">
                    <div className="grid grid-cols-2 md:grid-cols-4 gap-8">
                        <div className="text-center">
                            <div className="w-14 h-14 mx-auto mb-3 bg-gradient-to-br from-blue-500 to-cyan-500 rounded-2xl flex items-center justify-center shadow-lg">
                                <Users className="w-7 h-7 text-white" />
                            </div>
                            <div className="text-3xl md:text-4xl font-bold mb-1 bg-gradient-to-r from-blue-600 to-cyan-600 bg-clip-text text-transparent">
                                {totalTestimonials}+
                            </div>
                            <div className="text-slate-600 text-sm font-medium">Happy Clients</div>
                        </div>
                        <div className="text-center">
                            <div className="w-14 h-14 mx-auto mb-3 bg-gradient-to-br from-amber-500 to-orange-500 rounded-2xl flex items-center justify-center shadow-lg">
                                <Star className="w-7 h-7 text-white fill-white" />
                            </div>
                            <div className="text-3xl md:text-4xl font-bold mb-1 bg-gradient-to-r from-amber-600 to-orange-600 bg-clip-text text-transparent">
                                {avgRating}
                            </div>
                            <div className="text-slate-600 text-sm font-medium">Average Rating</div>
                        </div>
                        <div className="text-center">
                            <div className="w-14 h-14 mx-auto mb-3 bg-gradient-to-br from-emerald-500 to-teal-500 rounded-2xl flex items-center justify-center shadow-lg">
                                <ThumbsUp className="w-7 h-7 text-white" />
                            </div>
                            <div className="text-3xl md:text-4xl font-bold mb-1 bg-gradient-to-r from-emerald-600 to-teal-600 bg-clip-text text-transparent">
                                {fiveStarCount}
                            </div>
                            <div className="text-slate-600 text-sm font-medium">5-Star Reviews</div>
                        </div>
                        <div className="text-center">
                            <div className="w-14 h-14 mx-auto mb-3 bg-gradient-to-br from-purple-500 to-pink-500 rounded-2xl flex items-center justify-center shadow-lg">
                                <TrendingUp className="w-7 h-7 text-white" />
                            </div>
                            <div className="text-3xl md:text-4xl font-bold mb-1 bg-gradient-to-r from-purple-600 to-pink-600 bg-clip-text text-transparent">
                                98%
                            </div>
                            <div className="text-slate-600 text-sm font-medium">Recommend Us</div>
                        </div>
                    </div>
                </div>
            </div>

            {/* Featured Testimonials Spotlight */}
            {featuredTestimonials.length > 0 && (
                <div className="py-20 bg-gradient-to-b from-white to-slate-50">
                    <div className="container mx-auto px-4">
                        <div className="text-center max-w-3xl mx-auto mb-16">
                            <Badge className="mb-4 bg-violet-500/10 text-violet-700 border-violet-200">
                                <Sparkles className="w-3 h-3 mr-1" />
                                Featured Voices
                            </Badge>
                            <h2 className="text-4xl md:text-5xl font-bold mb-6">
                                Stories from Our{' '}
                                <span className="bg-gradient-to-r from-primary via-purple-500 to-pink-500 bg-clip-text text-transparent">
                                    Closest Partners
                                </span>
                            </h2>
                            <p className="text-xl text-slate-600">
                                The clients we've worked with longest — and their honest take on the experience.
                            </p>
                        </div>

                        <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                            {featuredTestimonials.map(testimonial => (
                                <TestimonialCard key={testimonial.id} testimonial={testimonial} />
                            ))}
                        </div>
                    </div>
                </div>
            )}

            {/* All Testimonials Grid */}
            <div id="testimonials-grid" className="py-20 bg-white">
                <div className="container mx-auto px-4">
                    <div className="text-center max-w-3xl mx-auto mb-16">
                        <div className="inline-flex items-center gap-2 px-4 py-2 rounded-full bg-primary/10 text-primary text-sm font-medium mb-4">
                            <MessageCircleHeart className="w-4 h-4" />
                            All Reviews
                        </div>
                        <h2 className="text-4xl md:text-5xl font-bold mb-6">
                            <span className="bg-gradient-to-r from-primary via-purple-500 to-pink-500 bg-clip-text text-transparent">
                                Voices from Every Industry
                            </span>
                        </h2>
                        <p className="text-xl text-slate-600">
                            Browse all the kind words from clients we've had the privilege of partnering with.
                        </p>
                    </div>

                    {regularTestimonials.length > 0 ? (
                        <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                            {regularTestimonials.map(testimonial => (
                                <TestimonialCard key={testimonial.id} testimonial={testimonial} />
                            ))}
                        </div>
                    ) : (
                        <div className="text-center py-20 bg-slate-50 rounded-2xl border-2 border-dashed border-slate-200 max-w-2xl mx-auto">
                            <Users className="w-16 h-16 mx-auto text-slate-300 mb-4" />
                            <p className="text-slate-500 text-lg mb-2 font-semibold">No testimonials yet</p>
                            <p className="text-slate-400">Check back soon — fresh stories incoming.</p>
                        </div>
                    )}
                </div>
            </div>

            {/* Why Clients Trust Us */}
            <div className="py-20 bg-slate-50">
                <div className="container mx-auto px-4">
                    <div className="text-center max-w-3xl mx-auto mb-16">
                        <Badge className="mb-4 bg-emerald-500/10 text-emerald-700 border-emerald-200">
                            <Heart className="w-3 h-3 mr-1" />
                            Why Clients Choose Us
                        </Badge>
                        <h2 className="text-4xl md:text-5xl font-bold mb-6">
                            The Reasons Behind the{' '}
                            <span className="bg-gradient-to-r from-primary via-purple-500 to-pink-500 bg-clip-text text-transparent">
                                Glowing Reviews
                            </span>
                        </h2>
                        <p className="text-xl text-slate-600">
                            What our clients consistently praise — and what we keep doubling down on.
                        </p>
                    </div>

                    <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
                        {trustReasons.map((reason, index) => {
                            const Icon = reason.icon;
                            return (
                                <div key={index} className="group bg-white p-8 rounded-2xl shadow-sm hover:shadow-2xl transition-all border border-slate-100">
                                    <div className={`w-16 h-16 mb-6 bg-gradient-to-br ${reason.color} rounded-2xl flex items-center justify-center shadow-lg group-hover:scale-110 transition-transform`}>
                                        <Icon className="w-8 h-8 text-white" />
                                    </div>
                                    <h3 className="text-xl font-bold mb-3">{reason.title}</h3>
                                    <p className="text-slate-600 text-sm leading-relaxed">
                                        {reason.description}
                                    </p>
                                </div>
                            );
                        })}
                    </div>
                </div>
            </div>

            {/* Social Proof Trust Banner */}
            <div className="py-20 bg-white">
                <div className="container mx-auto px-4">
                    <div className="bg-gradient-to-br from-slate-900 via-primary/90 to-purple-900 rounded-3xl p-12 text-white relative overflow-hidden">
                        <div className="absolute inset-0 opacity-10">
                            <div className="absolute top-0 left-1/4 w-96 h-96 bg-white rounded-full filter blur-3xl" />
                            <div className="absolute bottom-0 right-1/4 w-96 h-96 bg-white rounded-full filter blur-3xl" />
                        </div>

                        <div className="relative z-10 grid lg:grid-cols-2 gap-12 items-center">
                            <div>
                                <Badge className="mb-4 bg-white/20 text-white border-white/30 backdrop-blur-sm">
                                    <Trophy className="w-3 h-3 mr-1" />
                                    Trust Score
                                </Badge>
                                <h3 className="text-3xl md:text-4xl font-bold mb-4">
                                    Rated {avgRating}/5 by clients across {totalTestimonials}+ reviews
                                </h3>
                                <p className="text-lg text-white/80 mb-6 leading-relaxed">
                                    Our clients aren't just satisfied — they keep coming back. {fiveStarCount} of {totalTestimonials} reviews are five-star, and 98% would recommend HomeTech to a peer.
                                </p>

                                <div className="flex items-center gap-1 mb-6">
                                    {[1, 2, 3, 4, 5].map((i) => (
                                        <Star key={i} className="w-8 h-8 fill-amber-400 text-amber-400" />
                                    ))}
                                    <span className="ml-3 text-2xl font-bold">{avgRating}</span>
                                </div>

                                <Button size="lg" className="bg-white text-primary hover:bg-white/90 shadow-lg">
                                    <a href="/contact" className="flex items-center gap-2">
                                        Join Our Happy Clients
                                        <ArrowRight className="w-4 h-4" />
                                    </a>
                                </Button>
                            </div>

                            <div className="grid grid-cols-2 gap-4">
                                <div className="bg-white/10 backdrop-blur-sm rounded-2xl p-6 border border-white/20">
                                    <CheckCircle2 className="w-8 h-8 text-emerald-400 mb-3" />
                                    <div className="text-3xl font-bold mb-1">{totalTestimonials}+</div>
                                    <div className="text-white/70 text-sm">Total Reviews</div>
                                </div>
                                <div className="bg-white/10 backdrop-blur-sm rounded-2xl p-6 border border-white/20">
                                    <Star className="w-8 h-8 fill-amber-400 text-amber-400 mb-3" />
                                    <div className="text-3xl font-bold mb-1">{fiveStarCount}</div>
                                    <div className="text-white/70 text-sm">Five-Star Reviews</div>
                                </div>
                                <div className="bg-white/10 backdrop-blur-sm rounded-2xl p-6 border border-white/20">
                                    <Heart className="w-8 h-8 fill-pink-400 text-pink-400 mb-3" />
                                    <div className="text-3xl font-bold mb-1">98%</div>
                                    <div className="text-white/70 text-sm">Would Recommend</div>
                                </div>
                                <div className="bg-white/10 backdrop-blur-sm rounded-2xl p-6 border border-white/20">
                                    <Trophy className="w-8 h-8 text-amber-300 mb-3" />
                                    <div className="text-3xl font-bold mb-1">10+</div>
                                    <div className="text-white/70 text-sm">Industry Awards</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            {/* CTA Section - Dark Elegant */}
            <div className="relative py-20 bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 text-white overflow-hidden">
                <div className="absolute inset-0 opacity-10">
                    <div className="absolute top-0 left-1/4 w-96 h-96 bg-primary rounded-full filter blur-3xl" />
                    <div className="absolute bottom-0 right-1/4 w-96 h-96 bg-purple-500 rounded-full filter blur-3xl" />
                </div>

                <div className="container mx-auto px-4 relative z-10">
                    <div className="max-w-3xl mx-auto text-center">
                        <h2 className="text-4xl md:text-5xl font-bold mb-6">
                            Ready to Be Our Next Success Story?
                        </h2>
                        <p className="text-xl text-slate-300 mb-8 leading-relaxed">
                            Join {totalTestimonials}+ teams who chose HomeTech as their long-term technology partner. Let's start with a no-pressure conversation.
                        </p>

                        <div className="flex flex-wrap gap-4 justify-center">
                            <Button size="lg" className="bg-primary hover:bg-primary/90 text-white shadow-lg shadow-primary/50">
                                <a href="/contact" className="flex items-center gap-2 text-white">
                                    Start a Conversation
                                    <ArrowRight className="w-4 h-4" />
                                </a>
                            </Button>
                            <Button size="lg" variant="outline" className="border-2 border-white bg-transparent hover:bg-white transition-all">
                                <a href="/portfolio" className="text-white hover:text-slate-900">See Our Work</a>
                            </Button>
                        </div>

                        <div className="grid grid-cols-2 md:grid-cols-4 gap-6 mt-12 pt-12 border-t border-white/10">
                            <div>
                                <div className="text-3xl font-bold text-white mb-1">{totalTestimonials}+</div>
                                <div className="text-slate-400 text-sm">Happy Clients</div>
                            </div>
                            <div>
                                <div className="text-3xl font-bold text-white mb-1">{avgRating}</div>
                                <div className="text-slate-400 text-sm">Avg Rating</div>
                            </div>
                            <div>
                                <div className="text-3xl font-bold text-white mb-1">98%</div>
                                <div className="text-slate-400 text-sm">Recommend Us</div>
                            </div>
                            <div>
                                <div className="text-3xl font-bold text-white mb-1">24/7</div>
                                <div className="text-slate-400 text-sm">Support</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </Layout>
    );
}
