import React from 'react';
import { Link } from '@inertiajs/react';
import { PublicHeader } from '@/Components/PublicHeader';
import { PublicFooter } from '@/Components/PublicFooter';
import { SEOHead } from '@/Components/SEOHead';
import { ParticleHero } from '@/Components/ParticleHero';
import { ServiceCard } from '@/Components/ServiceCard';
import { ProjectCard } from '@/Components/ProjectCard';
import { TestimonialSlider } from '@/Components/TestimonialSlider';
import { BlogCard } from '@/Components/BlogCard';
import { ArrowRight, CheckCircle2, Zap, Heart, ShieldCheck, Users, Code, Award, Sparkles } from 'lucide-react';
import { motion } from 'framer-motion';

interface HomeProps {
    page: any;
    featuredServices: any[];
    featuredProjects: any[];
    testimonials: any[];
    latestPosts: any[];
}

export default function Home({ page, featuredServices, featuredProjects, testimonials, latestPosts }: HomeProps) {
    const heroSection = page?.sections?.find((s: any) => s.type === 'hero')?.content || {};
    const statsSection = page?.sections?.find((s: any) => s.type === 'statistics')?.content || {};

    return (
        <div className="min-h-screen bg-[#060B18] text-slate-100 flex flex-col font-sans selection:bg-[#00F2FE] selection:text-[#060B18]">
            <SEOHead
                title={page?.meta_title || 'Tech in Soul | Leading IT Solutions Company in Bangladesh'}
                description={page?.meta_description || 'Tech in Soul provides custom web development, mobile app development, SEO, and cloud DevOps solutions worldwide.'}
            />

            <PublicHeader />

            <main className="flex-grow pt-24">
                {/* HERO SECTION */}
                <section className="relative overflow-hidden py-20 lg:py-32 border-b border-slate-800/80">
                    <ParticleHero />

                    <div className="max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12 relative z-10">
                        <div className="text-center max-w-4xl mx-auto space-y-6">
                            <motion.div
                                initial={{ opacity: 0, y: 20 }}
                                animate={{ opacity: 1, y: 0 }}
                                transition={{ duration: 0.5 }}
                                className="inline-flex items-center gap-2 px-4 py-2 rounded-full bg-[#00F2FE]/10 border border-[#00F2FE]/30 text-[#00F2FE] text-xs font-semibold uppercase tracking-wider shadow-lg shadow-cyan-500/10"
                            >
                                <Sparkles className="w-4 h-4 animate-pulse" />
                                {heroSection.eyebrow || '⚡ LEADING IT SOLUTIONS & SOFTWARE ENGINEERING'}
                            </motion.div>

                            <motion.h1
                                initial={{ opacity: 0, y: 20 }}
                                animate={{ opacity: 1, y: 0 }}
                                transition={{ duration: 0.5, delay: 0.1 }}
                                className="text-4xl sm:text-6xl lg:text-7xl font-extrabold text-white tracking-tight leading-none"
                            >
                                We Engineer Digital Products That <span className="text-gradient-aqua">Inspire & Scale</span>
                            </motion.h1>

                            <motion.p
                                initial={{ opacity: 0, y: 20 }}
                                animate={{ opacity: 1, y: 0 }}
                                transition={{ duration: 0.5, delay: 0.2 }}
                                className="text-lg sm:text-xl text-slate-300 max-w-3xl mx-auto leading-relaxed font-light"
                            >
                                {heroSection.subheading || 'Tech in Soul empowers innovative startups and global enterprises with bespoke web applications, mobile platforms, and high-concurrency cloud infrastructure.'}
                            </motion.p>

                            <motion.div
                                initial={{ opacity: 0, y: 20 }}
                                animate={{ opacity: 1, y: 0 }}
                                transition={{ duration: 0.5, delay: 0.3 }}
                                className="pt-4 flex flex-col sm:flex-row items-center justify-center gap-4"
                            >
                                <Link
                                    href="/contact"
                                    className="btn-aqua px-8 py-4 rounded-xl text-base font-bold flex items-center gap-2 w-full sm:w-auto justify-center"
                                >
                                    Start Your Project
                                    <ArrowRight className="w-5 h-5" />
                                </Link>
                                <Link
                                    href="/projects"
                                    className="px-8 py-4 rounded-xl text-base font-semibold text-slate-300 hover:text-white bg-[#0B132B] border border-slate-700 hover:border-[#00F2FE]/40 transition-all w-full sm:w-auto text-center"
                                >
                                    Explore Case Studies
                                </Link>
                            </motion.div>
                        </div>
                    </div>
                </section>

                {/* STATISTICS SECTION */}
                <section className="py-12 bg-[#0B132B]/60 border-b border-slate-800">
                    <div className="max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12">
                        <div className="grid grid-cols-2 lg:grid-cols-4 gap-8 text-center">
                            {(statsSection.stats || [
                                { label: 'Projects Delivered', value: '80+', suffix: 'Global Successes' },
                                { label: 'Active Clients', value: '35+', suffix: '10+ Countries' },
                                { label: 'Years of Excellence', value: '8+', suffix: 'Established 2018' },
                                { label: 'Team Engineers', value: '25+', suffix: 'Specialized Talent' },
                            ]).map((stat: any, idx: number) => (
                                <div key={idx} className="space-y-1">
                                    <div className="text-3xl sm:text-4xl font-extrabold text-[#00F2FE] tracking-tight">
                                        {stat.value}
                                    </div>
                                    <div className="text-sm font-semibold text-white">{stat.label}</div>
                                    <div className="text-xs text-slate-400">{stat.suffix}</div>
                                </div>
                            ))}
                        </div>
                    </div>
                </section>

                {/* SERVICES SECTION */}
                <section className="py-20 max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12">
                    <div className="text-center max-w-3xl mx-auto mb-16 space-y-3">
                        <span className="text-xs font-bold text-[#00F2FE] uppercase tracking-widest">
                            WHAT WE EXCEL AT
                        </span>
                        <h2 className="text-3xl sm:text-5xl font-bold text-white tracking-tight">
                            Comprehensive Digital Services
                        </h2>
                        <p className="text-slate-400 text-base">
                            End-to-end software engineering and design capabilities to accelerate your product growth.
                        </p>
                    </div>

                    <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
                        {featuredServices.map((service) => (
                            <ServiceCard key={service.id} service={service} />
                        ))}
                    </div>

                    <div className="text-center pt-12">
                        <Link
                            href="/services"
                            className="inline-flex items-center gap-2 text-sm font-semibold text-[#00F2FE] hover:text-white transition-colors"
                        >
                            View All Specialized Services <ArrowRight className="w-4 h-4" />
                        </Link>
                    </div>
                </section>

                {/* PORTFOLIO PROJECTS */}
                <section className="py-20 bg-[#060B18] border-t border-slate-800/80">
                    <div className="max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12">
                        <div className="flex flex-col md:flex-row md:items-end justify-between mb-12 gap-4">
                            <div>
                                <span className="text-xs font-bold text-[#00F2FE] uppercase tracking-widest">
                                    FEATURED CASE STUDIES
                                </span>
                                <h2 className="text-3xl sm:text-4xl font-bold text-white tracking-tight mt-1">
                                    Proven Technical Impact
                                </h2>
                            </div>
                            <Link
                                href="/projects"
                                className="text-sm font-semibold text-[#00F2FE] hover:text-white inline-flex items-center gap-1"
                            >
                                View All Case Studies <ArrowRight className="w-4 h-4" />
                            </Link>
                        </div>

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

                {/* COMPANY VALUES */}
                <section className="py-20 bg-[#0B132B]/40 border-y border-slate-800">
                    <div className="max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12">
                        <div className="text-center max-w-2xl mx-auto mb-16 space-y-3">
                            <span className="text-xs font-bold text-[#00F2FE] uppercase tracking-widest">
                                THE TECH IN SOUL WAY
                            </span>
                            <h2 className="text-3xl sm:text-4xl font-bold text-white tracking-tight">
                                Driven by Integrity & Innovation
                            </h2>
                        </div>

                        <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
                            <div className="glass-card rounded-2xl p-6 space-y-3">
                                <div className="w-10 h-10 rounded-xl bg-[#00F2FE]/10 border border-[#00F2FE]/20 flex items-center justify-center text-[#00F2FE]">
                                    <Heart className="w-5 h-5" />
                                </div>
                                <h3 className="text-lg font-bold text-white">Customers First</h3>
                                <p className="text-xs text-slate-400 leading-relaxed">
                                    Your long-term success is our primary measure of technical excellence.
                                </p>
                            </div>

                            <div className="glass-card rounded-2xl p-6 space-y-3">
                                <div className="w-10 h-10 rounded-xl bg-[#00F2FE]/10 border border-[#00F2FE]/20 flex items-center justify-center text-[#00F2FE]">
                                    <Zap className="w-5 h-5" />
                                </div>
                                <h3 className="text-lg font-bold text-white">Think Big</h3>
                                <p className="text-xs text-slate-400 leading-relaxed">
                                    We design scalable software architectures built for hyper-growth and high concurrency.
                                </p>
                            </div>

                            <div className="glass-card rounded-2xl p-6 space-y-3">
                                <div className="w-10 h-10 rounded-xl bg-[#00F2FE]/10 border border-[#00F2FE]/20 flex items-center justify-center text-[#00F2FE]">
                                    <ShieldCheck className="w-5 h-5" />
                                </div>
                                <h3 className="text-lg font-bold text-white">Act With Integrity</h3>
                                <p className="text-xs text-slate-400 leading-relaxed">
                                    Transparent communication, bulletproof contracts, and zero hidden costs.
                                </p>
                            </div>

                            <div className="glass-card rounded-2xl p-6 space-y-3">
                                <div className="w-10 h-10 rounded-xl bg-[#00F2FE]/10 border border-[#00F2FE]/20 flex items-center justify-center text-[#00F2FE]">
                                    <Users className="w-5 h-5" />
                                </div>
                                <h3 className="text-lg font-bold text-white">Stronger United</h3>
                                <p className="text-xs text-slate-400 leading-relaxed">
                                    Seamless collaboration between backend engineering, design, and product leadership.
                                </p>
                            </div>
                        </div>
                    </div>
                </section>

                {/* TESTIMONIALS */}
                <section className="py-20 max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12">
                    <div className="text-center max-w-2xl mx-auto mb-16 space-y-3">
                        <span className="text-xs font-bold text-[#00F2FE] uppercase tracking-widest">
                            TRUSTED BY INDUSTRY LEADERS
                        </span>
                        <h2 className="text-3xl sm:text-4xl font-bold text-white tracking-tight">
                            Client Testimonials
                        </h2>
                    </div>

                    <TestimonialSlider testimonials={testimonials} />
                </section>

                {/* LATEST BLOG POSTS */}
                <section className="py-20 bg-[#0B132B]/30 border-t border-slate-800">
                    <div className="max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12">
                        <div className="flex flex-col md:flex-row md:items-end justify-between mb-12 gap-4">
                            <div>
                                <span className="text-xs font-bold text-[#00F2FE] uppercase tracking-widest">
                                    ENGINEERING INSIGHTS
                                </span>
                                <h2 className="text-3xl sm:text-4xl font-bold text-white tracking-tight mt-1">
                                    Latest Articles & Guides
                                </h2>
                            </div>
                            <Link
                                href="/blog"
                                className="text-sm font-semibold text-[#00F2FE] hover:text-white inline-flex items-center gap-1"
                            >
                                Read Blog <ArrowRight className="w-4 h-4" />
                            </Link>
                        </div>

                        <div className="grid grid-cols-1 md:grid-cols-3 gap-8">
                            {latestPosts.map((post) => (
                                <BlogCard key={post.id} post={post} />
                            ))}
                        </div>
                    </div>
                </section>

                {/* MARKETING CTA BANNER */}
                <section className="py-20 max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12">
                    <div className="glass-card rounded-3xl p-10 lg:p-16 text-center relative overflow-hidden border border-[#00F2FE]/30 shadow-2xl shadow-cyan-950/40">
                        <div className="relative z-10 max-w-3xl mx-auto space-y-6">
                            <h2 className="text-3xl sm:text-5xl font-extrabold text-white tracking-tight">
                                Ready to Turn Your Vision Into Reality?
                            </h2>
                            <p className="text-slate-300 text-base sm:text-lg">
                                Partner with Tech in Soul for end-to-end software engineering, mobile development, and cloud architecture tailored to your business goals.
                            </p>
                            <div className="pt-4">
                                <Link
                                    href="/contact"
                                    className="btn-aqua px-8 py-4 rounded-xl text-base font-bold inline-flex items-center gap-2"
                                >
                                    Schedule a Free Discovery Call
                                    <ArrowRight className="w-5 h-5" />
                                </Link>
                            </div>
                        </div>
                    </div>
                </section>
            </main>

            <PublicFooter />
        </div>
    );
}
