import { Head } from '@inertiajs/react';
import { useState } from 'react';
import Layout from '@/Components/Layout';
import ProjectCard from '@/Components/ProjectCard';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
    Sparkles,
    Briefcase,
    Filter,
    ArrowRight,
    Award,
    Users,
    Globe,
    Layers,
    Lightbulb,
    Pencil,
    Code2,
    Rocket,
    CheckCircle2,
    TrendingUp,
    Trophy,
    Building2,
    Star
} from 'lucide-react';

interface ProjectCategory {
    id: number;
    name: string;
    slug: string;
}

interface Project {
    id: number;
    slug: string;
    title: string;
    client?: string;
    year?: number;
    cover?: string;
    category?: ProjectCategory;
    featured?: boolean;
}

interface Props {
    projects: Project[];
    categories: ProjectCategory[];
    settings?: any;
}

const processSteps = [
    {
        icon: Lightbulb,
        title: 'Discover',
        description: 'We deep-dive into your business goals, audience, and constraints to define a clear product brief.',
        color: 'from-amber-500 to-orange-500'
    },
    {
        icon: Pencil,
        title: 'Design',
        description: 'UX wireframes and high-fidelity UI mockups iteratively shaped through collaborative reviews.',
        color: 'from-purple-500 to-pink-500'
    },
    {
        icon: Code2,
        title: 'Build',
        description: 'Modern stack engineering with weekly demos, automated tests, and continuous integration.',
        color: 'from-blue-500 to-cyan-500'
    },
    {
        icon: Rocket,
        title: 'Launch',
        description: 'Performance, accessibility, and security checks before a smooth production rollout — then ongoing care.',
        color: 'from-emerald-500 to-green-500'
    }
];

export default function PortfolioIndex({ projects, categories, settings }: Props) {
    const [selectedCategory, setSelectedCategory] = useState<number | null>(null);

    const filteredProjects = selectedCategory
        ? projects.filter(p => p.category?.id === selectedCategory)
        : projects;

    const featuredProjects = filteredProjects.filter(p => p.featured);
    const regularProjects = filteredProjects.filter(p => !p.featured);

    const totalProjects = projects.length;
    const totalCategories = categories.length;
    const totalFeatured = projects.filter(p => p.featured).length;
    const uniqueClients = new Set(projects.map(p => p.client).filter(Boolean)).size;

    return (
        <Layout settings={settings}>
            <Head title="Our Portfolio | Featured Work & Case Studies" />

            {/* 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>Success Stories</span>
                            </div>

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

                            <p className="text-lg md:text-xl text-slate-600 leading-relaxed max-w-xl">
                                Explore a curated collection of projects we've delivered for ambitious brands — websites, apps, custom software, and enterprise platforms that move the needle.
                            </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="#portfolio-grid" className="flex items-center gap-2 text-white">
                                        View Projects
                                        <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="/order" className="text-slate-700">Start a Project</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>{totalProjects}+ Projects</span>
                                </div>
                                <div className="flex items-center gap-2">
                                    <Sparkles className="w-4 h-4 text-amber-500" />
                                    <span>{totalCategories}+ Categories</span>
                                </div>
                                <div className="flex items-center gap-2">
                                    <Sparkles className="w-4 h-4 text-amber-500" />
                                    <span>Global Clients</span>
                                </div>
                            </div>
                        </div>

                        {/* Right: Portfolio Tiles 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 Project Tiles */}
                                <div className="absolute inset-0 p-6">
                                    {/* Tile 1 - Top Left */}
                                    <div className="absolute top-8 left-8 w-32 h-24 rounded-xl bg-gradient-to-br from-blue-500 to-cyan-500 shadow-xl animate-float p-3 overflow-hidden">
                                        <div className="flex items-center gap-2 mb-2">
                                            <div className="w-2 h-2 rounded-full bg-white/80" />
                                            <div className="w-2 h-2 rounded-full bg-white/50" />
                                            <div className="w-2 h-2 rounded-full bg-white/30" />
                                        </div>
                                        <div className="h-1.5 bg-white/40 rounded mb-1.5" />
                                        <div className="h-1.5 bg-white/30 rounded w-2/3 mb-1.5" />
                                        <div className="h-1.5 bg-white/30 rounded w-1/2" />
                                    </div>

                                    {/* Tile 2 - Top Right */}
                                    <div className="absolute top-12 right-8 w-28 h-28 rounded-xl bg-gradient-to-br from-purple-500 to-pink-500 shadow-xl animate-float p-3 overflow-hidden" style={{ animationDelay: '1s' }}>
                                        <div className="flex items-end h-full gap-1.5 pt-2">
                                            <div className="flex-1 bg-white/40 rounded-t" style={{ height: '40%' }} />
                                            <div className="flex-1 bg-white/60 rounded-t" style={{ height: '70%' }} />
                                            <div className="flex-1 bg-white/50 rounded-t" style={{ height: '50%' }} />
                                            <div className="flex-1 bg-white/70 rounded-t" style={{ height: '90%' }} />
                                            <div className="flex-1 bg-white/40 rounded-t" style={{ height: '60%' }} />
                                        </div>
                                    </div>

                                    {/* Tile 3 - Center (Featured) */}
                                    <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-44 h-32 rounded-2xl bg-gradient-to-br from-primary via-blue-600 to-purple-600 shadow-2xl border border-white/20 p-4 z-10">
                                        <div className="flex items-center justify-between mb-3">
                                            <Trophy className="w-5 h-5 text-amber-300" />
                                            <Badge className="bg-white/20 text-white border-0 text-[10px] backdrop-blur-sm">Featured</Badge>
                                        </div>
                                        <div className="space-y-1.5">
                                            <div className="h-2 bg-white/50 rounded" />
                                            <div className="h-2 bg-white/30 rounded w-3/4" />
                                            <div className="h-2 bg-white/30 rounded w-1/2" />
                                        </div>
                                        <div className="absolute bottom-3 right-3 flex items-center gap-1">
                                            <Star className="w-3 h-3 text-amber-300 fill-amber-300" />
                                            <Star className="w-3 h-3 text-amber-300 fill-amber-300" />
                                            <Star className="w-3 h-3 text-amber-300 fill-amber-300" />
                                        </div>
                                    </div>

                                    {/* Tile 4 - Bottom Left */}
                                    <div className="absolute bottom-12 left-6 w-28 h-32 rounded-xl bg-gradient-to-br from-emerald-500 to-teal-500 shadow-xl animate-float p-3 overflow-hidden" style={{ animationDelay: '0.5s' }}>
                                        <div className="w-full aspect-square bg-white/20 rounded-lg mb-2 flex items-center justify-center">
                                            <Globe className="w-8 h-8 text-white/80" />
                                        </div>
                                        <div className="h-1.5 bg-white/40 rounded mb-1" />
                                        <div className="h-1.5 bg-white/30 rounded w-2/3" />
                                    </div>

                                    {/* Tile 5 - Bottom Right */}
                                    <div className="absolute bottom-8 right-6 w-32 h-24 rounded-xl bg-gradient-to-br from-amber-500 to-orange-500 shadow-xl animate-float p-3 overflow-hidden" style={{ animationDelay: '1.5s' }}>
                                        <div className="flex items-center gap-2 mb-2">
                                            <Building2 className="w-4 h-4 text-white" />
                                            <div className="h-1.5 bg-white/50 rounded flex-1" />
                                        </div>
                                        <div className="h-1.5 bg-white/30 rounded mb-1" />
                                        <div className="h-1.5 bg-white/30 rounded w-3/4 mb-1" />
                                        <div className="h-1.5 bg-white/30 rounded w-1/2" />
                                    </div>

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

                                {/* Connection Lines SVG */}
                                <svg className="absolute inset-0 w-full h-full pointer-events-none" viewBox="0 0 500 500" preserveAspectRatio="xMidYMid meet">
                                    <defs>
                                        <linearGradient id="portfolioConn" 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(#portfolioConn)" 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>
                                </svg>

                                {/* Corner Accents */}
                                <svg className="absolute inset-0 w-full h-full pointer-events-none" viewBox="0 0 500 500" preserveAspectRatio="xMidYMid meet">
                                    <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">SHIPPED</span>
                                    </div>
                                    <div className="text-white text-xs font-mono mt-1">
                                        <span className="text-white/60">Projects:</span> <span className="text-cyan-300">{totalProjects}+</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">Featured:</span> {totalFeatured}
                                    </div>
                                    <div className="text-purple-300 text-xs font-mono mt-1">
                                        <span className="text-white/60">Industries:</span> {totalCategories}+
                                    </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-emerald-400 to-teal-500 flex items-center justify-center">
                                        <Trophy className="w-5 h-5 text-white" />
                                    </div>
                                    <div>
                                        <div className="text-slate-900 font-bold text-lg">{totalFeatured}</div>
                                        <div className="text-slate-500 text-xs">Featured</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-amber-400 to-orange-500 flex items-center justify-center">
                                        <Award className="w-5 h-5 text-white" />
                                    </div>
                                    <div>
                                        <div className="text-slate-900 font-bold text-lg">{totalProjects}+</div>
                                        <div className="text-slate-500 text-xs">Delivered</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">
                                <Briefcase 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">
                                {totalProjects}+
                            </div>
                            <div className="text-slate-600 text-sm font-medium">Projects Delivered</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">
                                <Layers 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">
                                {totalCategories}+
                            </div>
                            <div className="text-slate-600 text-sm font-medium">Industries Served</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">
                                <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-emerald-600 to-teal-600 bg-clip-text text-transparent">
                                {uniqueClients || '50'}+
                            </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">
                                <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-amber-600 to-orange-600 bg-clip-text text-transparent">
                                98%
                            </div>
                            <div className="text-slate-600 text-sm font-medium">Client Satisfaction</div>
                        </div>
                    </div>
                </div>
            </div>

            {/* Featured Projects Spotlight */}
            {featuredProjects.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-amber-500/10 text-amber-700 border-amber-200">
                                <Sparkles className="w-3 h-3 mr-1" />
                                Featured Work
                            </Badge>
                            <h2 className="text-4xl md:text-5xl font-bold mb-6">
                                Our{' '}
                                <span className="bg-gradient-to-r from-primary via-purple-500 to-pink-500 bg-clip-text text-transparent">
                                    Spotlight Projects
                                </span>
                            </h2>
                            <p className="text-xl text-slate-600">
                                A curated selection of projects we're particularly proud of — each one a story of partnership and execution.
                            </p>
                        </div>

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

            {/* All Projects Grid with Filter */}
            <div id="portfolio-grid" className="py-20 bg-white">
                <div className="container mx-auto px-4">
                    <div className="text-center max-w-3xl mx-auto mb-12">
                        <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">
                            <Briefcase className="w-4 h-4" />
                            Complete Portfolio
                        </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">
                                Browse All Projects
                            </span>
                        </h2>
                        <p className="text-xl text-slate-600">
                            Filter by category to find work most relevant to your industry or use case.
                        </p>
                    </div>

                    {/* Category Filter Pills */}
                    {categories.length > 0 && (
                        <div className="mb-12">
                            <div className="flex items-center justify-center gap-3 mb-6">
                                <Filter className="w-5 h-5 text-primary" />
                                <h3 className="text-base font-semibold text-slate-700">
                                    Filter by Category
                                </h3>
                            </div>

                            <div className="flex flex-wrap gap-3 justify-center">
                                <Button
                                    variant={selectedCategory === null ? 'default' : 'outline'}
                                    onClick={() => setSelectedCategory(null)}
                                    className="rounded-full"
                                >
                                    All Projects
                                    <Badge variant="secondary" className="ml-2">
                                        {projects.length}
                                    </Badge>
                                </Button>

                                {categories.map(category => {
                                    const count = projects.filter(p => p.category?.id === category.id).length;
                                    return (
                                        <Button
                                            key={category.id}
                                            variant={selectedCategory === category.id ? 'default' : 'outline'}
                                            onClick={() => setSelectedCategory(category.id)}
                                            className="rounded-full"
                                        >
                                            {category.name}
                                            <Badge variant="secondary" className="ml-2">
                                                {count}
                                            </Badge>
                                        </Button>
                                    );
                                })}
                            </div>
                        </div>
                    )}

                    {/* Projects Grid */}
                    {regularProjects.length > 0 ? (
                        <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                            {regularProjects.map(project => (
                                <ProjectCard key={project.id} project={project} />
                            ))}
                        </div>
                    ) : filteredProjects.length === 0 ? (
                        <div className="text-center py-20 bg-slate-50 rounded-2xl border-2 border-dashed border-slate-200 max-w-2xl mx-auto">
                            <Briefcase className="w-16 h-16 mx-auto text-slate-300 mb-4" />
                            <p className="text-slate-500 text-lg mb-2 font-semibold">No projects found</p>
                            <p className="text-slate-400">
                                {selectedCategory ? 'Try selecting a different category' : 'Check back soon for updates'}
                            </p>
                        </div>
                    ) : null}
                </div>
            </div>

            {/* Process Section */}
            <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-purple-500/10 text-purple-700 border-purple-200">
                            <Rocket className="w-3 h-3 mr-1" />
                            How We Work
                        </Badge>
                        <h2 className="text-4xl md:text-5xl font-bold mb-6">
                            From Idea to{' '}
                            <span className="bg-gradient-to-r from-primary via-purple-500 to-pink-500 bg-clip-text text-transparent">
                                Launch
                            </span>
                        </h2>
                        <p className="text-xl text-slate-600">
                            A proven 4-phase delivery process that consistently turns ambitious visions into shipped products.
                        </p>
                    </div>

                    <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 relative">
                        {/* Connection line (desktop only) */}
                        <div className="hidden lg:block absolute top-12 left-[12.5%] right-[12.5%] h-0.5 bg-gradient-to-r from-amber-300 via-purple-300 to-emerald-300 -z-0" />

                        {processSteps.map((step, index) => {
                            const Icon = step.icon;
                            return (
                                <div key={index} className="relative bg-white p-8 rounded-2xl shadow-sm hover:shadow-2xl transition-all border border-slate-100 group">
                                    <div className={`w-16 h-16 mx-auto mb-6 bg-gradient-to-br ${step.color} rounded-2xl flex items-center justify-center shadow-lg group-hover:scale-110 transition-transform relative z-10`}>
                                        <Icon className="w-8 h-8 text-white" />
                                    </div>
                                    <div className="absolute top-6 right-6 text-5xl font-bold text-slate-100 leading-none">
                                        0{index + 1}
                                    </div>
                                    <h3 className="text-xl font-bold mb-3 text-center">{step.title}</h3>
                                    <p className="text-slate-600 text-sm leading-relaxed text-center">
                                        {step.description}
                                    </p>
                                </div>
                            );
                        })}
                    </div>
                </div>
            </div>

            {/* Why Trust Us Section */}
            <div className="py-20 bg-white">
                <div className="container mx-auto px-4">
                    <div className="grid lg:grid-cols-2 gap-12 items-center">
                        <div>
                            <h2 className="text-4xl md:text-5xl font-bold mb-6">
                                Why Brands Trust HomeTech with Their{' '}
                                <span className="bg-gradient-to-r from-primary via-purple-500 to-pink-500 bg-clip-text text-transparent">
                                    Most Important Work
                                </span>
                            </h2>
                            <p className="text-xl text-slate-600 mb-8 leading-relaxed">
                                We don't just deliver projects — we partner with teams to ship products that customers love and businesses depend on.
                            </p>

                            <div className="space-y-4">
                                {[
                                    { title: 'Senior-Only Engineering', desc: 'Every line of code is written by experienced engineers — no junior outsourcing.' },
                                    { title: 'Transparent Communication', desc: 'Weekly demos, async updates, and open Slack/Teams channels — you stay in the loop.' },
                                    { title: 'Production-Grade Quality', desc: 'Automated tests, CI/CD, performance budgets, and security scans on every release.' },
                                    { title: 'Long-Term Partnership', desc: 'We stay involved post-launch — monitoring, iterating, and growing the product with you.' }
                                ].map((item, idx) => (
                                    <div key={idx} className="flex items-start gap-4 p-4 rounded-xl hover:bg-slate-50 transition-colors">
                                        <div className="w-10 h-10 bg-gradient-to-br from-primary to-purple-600 rounded-lg flex items-center justify-center flex-shrink-0">
                                            <CheckCircle2 className="w-5 h-5 text-white" />
                                        </div>
                                        <div>
                                            <h4 className="font-bold text-lg mb-1">{item.title}</h4>
                                            <p className="text-slate-600">{item.desc}</p>
                                        </div>
                                    </div>
                                ))}
                            </div>
                        </div>

                        <div className="relative">
                            <div className="aspect-square bg-gradient-to-br from-blue-100 to-purple-100 rounded-3xl p-8 relative overflow-hidden">
                                <div className="absolute inset-0 flex items-center justify-center">
                                    <div className="relative">
                                        <div className="w-48 h-48 bg-gradient-to-br from-primary to-purple-600 rounded-2xl transform rotate-12 absolute top-0 left-0 opacity-20 blur-xl" />
                                        <div className="relative bg-white rounded-2xl p-8 shadow-2xl">
                                            <div className="flex flex-col items-center gap-4">
                                                <div className="w-20 h-20 bg-gradient-to-br from-primary to-purple-600 rounded-xl flex items-center justify-center">
                                                    <Trophy className="w-10 h-10 text-white" />
                                                </div>
                                                <div className="text-center">
                                                    <div className="text-2xl font-bold mb-2">Built to Win</div>
                                                    <div className="text-sm text-slate-500">Award-quality delivery</div>
                                                </div>
                                                <div className="flex gap-1">
                                                    {[1, 2, 3, 4, 5].map((i) => (
                                                        <Star key={i} className="w-4 h-4 fill-amber-400 text-amber-400" />
                                                    ))}
                                                </div>
                                            </div>
                                        </div>
                                    </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 Build Something Remarkable?
                        </h2>
                        <p className="text-xl text-slate-300 mb-8 leading-relaxed">
                            Whether it's a website, mobile app, custom software, or enterprise platform — let's turn your idea into the next case study on this page.
                        </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="/order" className="flex items-center gap-2 text-white">
                                    Start Your Project
                                    <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="/services" className="text-white hover:text-slate-900">Explore Services</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">{totalProjects}+</div>
                                <div className="text-slate-400 text-sm">Projects Shipped</div>
                            </div>
                            <div>
                                <div className="text-3xl font-bold text-white mb-1">98%</div>
                                <div className="text-slate-400 text-sm">Satisfaction</div>
                            </div>
                            <div>
                                <div className="text-3xl font-bold text-white mb-1">{totalCategories}+</div>
                                <div className="text-slate-400 text-sm">Industries</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>
    );
}
