import React, { useState } from 'react';
import { PublicHeader } from '@/Components/PublicHeader';
import { PublicFooter } from '@/Components/PublicFooter';
import { SEOHead } from '@/Components/SEOHead';
import { TeamCard } from '@/Components/TeamCard';
import { Link } from '@inertiajs/react';
import { Users, Code, Award, Sparkles, Heart, ArrowRight } from 'lucide-react';

interface TeamIndexProps {
    team: any[];
}

export default function Index({ team }: TeamIndexProps) {
    const [selectedDepartment, setSelectedDepartment] = useState('All');

    const departments = ['All', 'Executive Leadership', 'Engineering', 'Design', 'DevOps & Cloud', 'Marketing'];

    const filteredTeam = selectedDepartment === 'All'
        ? team
        : team.filter((m) => m.department?.toLowerCase() === selectedDepartment.toLowerCase() || (selectedDepartment === 'Engineering' && m.department === 'Engineering'));

    const cultureCards = [
        {
            icon: Code,
            title: 'Engineering Rigor',
            description: 'We adhere to clean code standards, PSR compliance, high test coverage, and modern stack conventions.',
        },
        {
            icon: Sparkles,
            title: 'Human-Centered Design',
            description: 'Designers and developers collaborate early to ensure fluid micro-interactions and accessible user interfaces.',
        },
        {
            icon: Heart,
            title: 'Empathetic Collaboration',
            description: 'Transparent communication, agile daily standups, and direct technical alignment with client stakeholders.',
        },
        {
            icon: Award,
            title: 'Continuous Growth',
            description: 'Investing in continuous learning, open source contributions, and staying ahead of modern AI and cloud trends.',
        },
    ];

    return (
        <div className="min-h-screen bg-[#060B18] text-slate-100 flex flex-col font-sans">
            <SEOHead
                title="Our Leadership & Engineering Team | Tech in Soul"
                description="Meet the software engineers, UI/UX designers, cloud architects, and growth specialists behind Tech in Soul."
            />

            <PublicHeader />

            <main className="flex-grow pt-32 pb-20">
                {/* Hero Header */}
                <div className="max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12 text-center space-y-4 mb-16">
                    <span className="text-xs font-bold text-[#00F2FE] uppercase tracking-widest bg-[#00F2FE]/10 px-3.5 py-1 rounded-full border border-[#00F2FE]/20 inline-block">
                        MEET THE TEAM
                    </span>
                    <h1 className="text-4xl sm:text-6xl font-extrabold text-white tracking-tight leading-tight">
                        Our Multidisciplinary <span className="text-gradient-aqua">Engineers & Strategists</span>
                    </h1>
                    <p className="text-slate-400 text-base sm:text-lg max-w-2xl mx-auto leading-relaxed">
                        Passionate software architects, human-centric UI/UX designers, and cloud specialists dedicated to building high-impact digital products.
                    </p>
                </div>

                {/* Team Stats Banner */}
                <div className="max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12 mb-16">
                    <div className="grid grid-cols-2 md:grid-cols-4 gap-4 sm:gap-6">
                        <div className="glass-card rounded-2xl p-6 text-center space-y-1 border border-slate-800">
                            <div className="text-3xl font-extrabold text-[#00F2FE] font-mono">{team.length}+</div>
                            <div className="text-xs font-bold text-slate-400 uppercase">Core Specialists</div>
                        </div>
                        <div className="glass-card rounded-2xl p-6 text-center space-y-1 border border-slate-800">
                            <div className="text-3xl font-extrabold text-white font-mono">8+ Years</div>
                            <div className="text-xs font-bold text-slate-400 uppercase">Average Experience</div>
                        </div>
                        <div className="glass-card rounded-2xl p-6 text-center space-y-1 border border-slate-800">
                            <div className="text-3xl font-extrabold text-[#00F2FE] font-mono">80+</div>
                            <div className="text-xs font-bold text-slate-400 uppercase">Delivered Projects</div>
                        </div>
                        <div className="glass-card rounded-2xl p-6 text-center space-y-1 border border-slate-800">
                            <div className="text-3xl font-extrabold text-white font-mono">10+</div>
                            <div className="text-xs font-bold text-slate-400 uppercase">Global Countries</div>
                        </div>
                    </div>
                </div>

                {/* Filter Tabs */}
                <div className="max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12 mb-12 flex items-center justify-center flex-wrap gap-2 sm:gap-3">
                    {departments.map((dept) => (
                        <button
                            key={dept}
                            onClick={() => setSelectedDepartment(dept)}
                            className={`px-4 py-2 rounded-xl text-xs font-bold transition-all ${
                                selectedDepartment === dept
                                    ? 'bg-[#00F2FE] text-[#060B18] shadow-lg shadow-[#00F2FE]/20'
                                    : 'bg-[#0B132B] text-slate-300 border border-slate-800 hover:border-[#00F2FE]/40'
                            }`}
                        >
                            {dept}
                        </button>
                    ))}
                </div>

                {/* Team Grid */}
                <div className="max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12 mb-24">
                    {filteredTeam.length === 0 ? (
                        <div className="glass-card rounded-2xl p-12 text-center text-slate-400 border border-slate-800">
                            No team members found in this department category.
                        </div>
                    ) : (
                        <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-8">
                            {filteredTeam.map((member) => (
                                <TeamCard key={member.id} member={member} />
                            ))}
                        </div>
                    )}
                </div>

                {/* Company Culture Section */}
                <div className="max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12 mb-24 space-y-12">
                    <div className="text-center max-w-2xl mx-auto space-y-2">
                        <span className="text-xs font-bold text-[#00F2FE] uppercase tracking-widest">
                            OUR CULTURE & ETHOS
                        </span>
                        <h2 className="text-3xl sm:text-4xl font-bold text-white">How We Work Together</h2>
                    </div>

                    <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
                        {cultureCards.map((card, idx) => {
                            const Icon = card.icon;
                            return (
                                <div key={idx} className="glass-card rounded-2xl p-8 space-y-3 border border-slate-800">
                                    <div className="w-10 h-10 rounded-xl bg-[#00F2FE]/10 border border-[#00F2FE]/30 flex items-center justify-center text-[#00F2FE]">
                                        <Icon className="w-5 h-5" />
                                    </div>
                                    <h3 className="text-lg font-bold text-white">{card.title}</h3>
                                    <p className="text-xs text-slate-400 leading-relaxed">{card.description}</p>
                                </div>
                            );
                        })}
                    </div>
                </div>

                {/* Join Our Team CTA */}
                <div className="max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-12">
                    <div className="glass-card rounded-3xl p-8 sm:p-12 border border-[#00F2FE]/30 text-center space-y-6">
                        <h2 className="text-3xl font-extrabold text-white">Want to Build Great Software with Us?</h2>
                        <p className="text-slate-400 text-sm max-w-2xl mx-auto leading-relaxed">
                            We are always looking for talented software engineers, designers, and growth marketers to join our growing team in Bangladesh and remotely.
                        </p>
                        <Link href="/contact" className="btn-aqua px-8 py-3.5 rounded-xl font-bold text-xs inline-flex items-center gap-2">
                            Get in Touch / Apply Now <ArrowRight className="w-4 h-4" />
                        </Link>
                    </div>
                </div>
            </main>

            <PublicFooter />
        </div>
    );
}
