'use client';

import { useRef } from 'react';
import Link from 'next/link';
import Image from 'next/image';
import { motion, useInView, useScroll, useTransform } from 'framer-motion';
import {
  Ship,
  Shield,
  Zap,
  BarChart3,
  Package,
  Clock,
  CheckCircle2,
  ArrowRight,
  Search,
  Anchor,
  Container,
  FileText,
  LayoutDashboard,
  Bell,
  BookOpen,
  Users,
  Check,
  X,
} from 'lucide-react';
import { useAuth } from '@/lib/context/auth-context';
import { LandingHeader, LandingFooter } from '@/components/layout';

export default function LandingPage() {
  const { user, isAuthenticated } = useAuth();

  const heroRef = useRef(null);
  const featuresRef = useRef(null);
  const statsRef = useRef(null);
  const toolsRef = useRef(null);
  const pricingRef = useRef(null);
  const testimonialsRef = useRef(null);
  const ctaRef = useRef(null);

  const isHeroInView = useInView(heroRef, { once: true });
  const isFeaturesInView = useInView(featuresRef, { once: true });
  const isStatsInView = useInView(statsRef, { once: true });
  const isToolsInView = useInView(toolsRef, { once: true });
  const isPricingInView = useInView(pricingRef, { once: true });
  const isTestimonialsInView = useInView(testimonialsRef, { once: true });
  const isCtaInView = useInView(ctaRef, { once: true });

  const { scrollYProgress } = useScroll();
  const backgroundY = useTransform(scrollYProgress, [0, 1], ['0%', '50%']);

  const features = [
    {
      icon: BarChart3,
      title: 'Dashboard Analytics',
      description:
        'Suivez tous vos KPIs en temps réel : bookings, volumes, revenus et alertes personnalisées.',
      color: 'from-blue-500 to-cyan-500',
      link: '/dashboard',
    },
    {
      icon: Package,
      title: 'Gestion des Bookings',
      description: 'Créez, gérez et suivez vos réservations maritimes LCL/FCL avec un historique complet.',
      color: 'from-purple-500 to-pink-500',
      link: '/dashboard/bookings',
    },
    {
      icon: FileText,
      title: 'Documents Maritimes',
      description: 'Centralisez tous vos documents : B/L, factures, certificats et documents douaniers.',
      color: 'from-orange-500 to-red-500',
      link: '/dashboard/documents',
    },
    {
      icon: Search,
      title: 'Track & Trace',
      description:
        'Suivez vos conteneurs en temps réel auprès de 10+ transporteurs majeurs (Maersk, MSC, CMA CGM...).',
      color: 'from-green-500 to-emerald-500',
      link: '/dashboard/track-trace',
    },
    {
      icon: BookOpen,
      title: 'Wiki Maritime',
      description:
        'Base de connaissances complète : Incoterms, documents, procédures douanières et plus encore.',
      color: 'from-yellow-500 to-orange-500',
      link: '/dashboard/wiki',
    },
    {
      icon: Bell,
      title: 'Notifications Temps Réel',
      description:
        'Restez informé avec des alertes instantanées sur vos bookings, documents et mises à jour.',
      color: 'from-indigo-500 to-purple-500',
      link: '/dashboard',
    },
  ];

  const tools = [
    {
      icon: LayoutDashboard,
      title: 'Dashboard',
      description: 'Vue d\'ensemble de votre activité maritime',
      link: '/dashboard',
    },
    {
      icon: Package,
      title: 'Mes Bookings',
      description: 'Gérez toutes vos réservations en un seul endroit',
      link: '/dashboard/bookings',
    },
    {
      icon: FileText,
      title: 'Documents',
      description: 'Accédez à tous vos documents maritimes',
      link: '/dashboard/documents',
    },
    {
      icon: Search,
      title: 'Track & Trace',
      description: 'Suivez vos conteneurs en temps réel',
      link: '/dashboard/track-trace',
    },
    {
      icon: BookOpen,
      title: 'Wiki Maritime',
      description: 'Base de connaissances du fret maritime',
      link: '/dashboard/wiki',
    },
    {
      icon: Users,
      title: 'Mon Profil',
      description: 'Gérez vos informations personnelles',
      link: '/dashboard/profile',
    },
  ];

  const stats = [
    { value: '50+', label: 'Compagnies Maritimes', icon: Ship },
    { value: '10K+', label: 'Ports Mondiaux', icon: Anchor },
    { value: '<2s', label: 'Temps de Réponse', icon: Zap },
    { value: '99.5%', label: 'Disponibilité', icon: CheckCircle2 },
  ];

  const pricingPlans = [
    {
      name: 'Starter',
      price: 'Gratuit',
      period: '',
      description: 'Idéal pour découvrir la plateforme',
      features: [
        { text: 'Jusqu\'à 5 bookings/mois', included: true },
        { text: 'Track & Trace illimité', included: true },
        { text: 'Wiki maritime complet', included: true },
        { text: 'Dashboard basique', included: true },
        { text: 'Support par email', included: true },
        { text: 'Gestion des documents', included: false },
        { text: 'Notifications temps réel', included: false },
        { text: 'API access', included: false },
      ],
      cta: 'Commencer gratuitement',
      highlighted: false,
    },
    {
      name: 'Professional',
      price: '99€',
      period: '/mois',
      description: 'Pour les transitaires en croissance',
      features: [
        { text: 'Bookings illimités', included: true },
        { text: 'Track & Trace illimité', included: true },
        { text: 'Wiki maritime complet', included: true },
        { text: 'Dashboard avancé + KPIs', included: true },
        { text: 'Support prioritaire', included: true },
        { text: 'Gestion des documents', included: true },
        { text: 'Notifications temps réel', included: true },
        { text: 'API access', included: false },
      ],
      cta: 'Essai gratuit 14 jours',
      highlighted: true,
    },
    {
      name: 'Enterprise',
      price: 'Sur mesure',
      period: '',
      description: 'Pour les grandes entreprises',
      features: [
        { text: 'Tout Professional +', included: true },
        { text: 'API access complet', included: true },
        { text: 'Intégrations personnalisées', included: true },
        { text: 'Account manager dédié', included: true },
        { text: 'SLA garanti 99.9%', included: true },
        { text: 'Formation sur site', included: true },
        { text: 'Multi-organisations', included: true },
        { text: 'Audit & conformité', included: true },
      ],
      cta: 'Contactez-nous',
      highlighted: false,
    },
  ];

  const testimonials = [
    {
      quote:
        'Xpeditis a révolutionné notre façon de gérer le fret maritime. Les tarifs sont compétitifs et la plateforme est intuitive.',
      author: 'Marie Dubois',
      role: 'Directrice Logistique',
      company: 'LogiFrance',
    },
    {
      quote:
        'Le gain de temps est considérable. Ce qui nous prenait des heures se fait maintenant en quelques minutes.',
      author: 'Thomas Martin',
      role: 'Responsable Transport',
      company: 'EuroShipping',
    },
    {
      quote:
        "L'interface est claire, les données sont précises et le support client est réactif. Un vrai partenaire de confiance.",
      author: 'Sophie Bernard',
      role: 'CEO',
      company: 'MariTime Solutions',
    },
  ];

  const containerVariants = {
    hidden: { opacity: 0, y: 50 },
    visible: {
      opacity: 1,
      y: 0,
      transition: {
        duration: 0.6,
        staggerChildren: 0.1,
      },
    },
  };

  const itemVariants = {
    hidden: { opacity: 0, y: 20 },
    visible: {
      opacity: 1,
      y: 0,
      transition: { duration: 0.5 },
    },
  };

  return (
    <div className="min-h-screen bg-white">
      <LandingHeader transparentOnTop={true} />

      {/* Hero Section */}
      <section ref={heroRef} className="relative min-h-screen flex items-center overflow-hidden">
        {/* Background Image */}
        <motion.div style={{ y: backgroundY }} className="absolute inset-0 z-0">
          {/* Container background image */}
          <div
            className="absolute inset-0"
            style={{
              backgroundImage: 'url(/assets/images/background-section-1-landingpage.png)',
              backgroundSize: 'cover',
              backgroundPosition: 'center',
              backgroundRepeat: 'no-repeat',
            }}
          />
          {/* Dark overlay for text readability */}
          <div className="absolute inset-0 bg-brand-navy/60" />
          {/* Gradient overlay */}
          <div className="absolute inset-0 bg-gradient-to-br from-brand-navy/70 via-brand-navy/50 to-brand-turquoise/20" />
        </motion.div>

        <div className="relative z-10 max-w-7xl mx-auto px-6 lg:px-8">
          <motion.div
            initial={{ opacity: 0, y: 30 }}
            animate={isHeroInView ? { opacity: 1, y: 0 } : {}}
            transition={{ duration: 0.8 }}
            className="text-center"
          >
            <motion.div
              initial={{ scale: 0.8, opacity: 0 }}
              animate={isHeroInView ? { scale: 1, opacity: 1 } : {}}
              transition={{ duration: 0.6, delay: 0.2 }}
              className="inline-flex items-center space-x-2 bg-white/10 backdrop-blur-sm px-4 py-2 rounded-full mb-8 border border-white/20"
            >
              <Ship className="w-5 h-5 text-brand-turquoise" />
              <span className="text-white/90 text-sm font-medium">
                Plateforme B2B de Fret Maritime #1 en Europe
              </span>
            </motion.div>

            <motion.h1
              initial={{ opacity: 0, y: 20 }}
              animate={isHeroInView ? { opacity: 1, y: 0 } : {}}
              transition={{ duration: 0.8, delay: 0.3 }}
              className="text-5xl lg:text-7xl font-bold text-white mb-6 leading-tight"
            >
              Réservez votre fret
              <br />
              <span className="text-transparent bg-clip-text bg-gradient-to-r from-brand-turquoise to-brand-green">
                en quelques clics
              </span>
            </motion.h1>

            <motion.p
              initial={{ opacity: 0, y: 20 }}
              animate={isHeroInView ? { opacity: 1, y: 0 } : {}}
              transition={{ duration: 0.8, delay: 0.4 }}
              className="text-xl lg:text-2xl text-white/80 mb-12 max-w-3xl mx-auto leading-relaxed"
            >
              Comparez les tarifs de 50+ compagnies maritimes, réservez en ligne et suivez vos
              envois en temps réel.
            </motion.p>

            <motion.div
              initial={{ opacity: 0, y: 20 }}
              animate={isHeroInView ? { opacity: 1, y: 0 } : {}}
              transition={{ duration: 0.8, delay: 0.5 }}
              className="flex flex-col sm:flex-row items-center justify-center space-y-4 sm:space-y-0 sm:space-x-6 mb-12"
            >
              {isAuthenticated && user ? (
                <Link
                  href="/dashboard"
                  className="group px-8 py-4 bg-brand-turquoise text-white rounded-lg hover:bg-brand-turquoise/90 transition-all hover:shadow-2xl hover:scale-105 font-semibold text-lg w-full sm:w-auto flex items-center justify-center space-x-2"
                >
                  <span>Accéder au Dashboard</span>
                  <LayoutDashboard className="w-5 h-5 group-hover:translate-x-1 transition-transform" />
                </Link>
              ) : (
                <>
                  <Link
                    href="/register"
                    className="group px-8 py-4 bg-brand-turquoise text-white rounded-lg hover:bg-brand-turquoise/90 transition-all hover:shadow-2xl hover:scale-105 font-semibold text-lg w-full sm:w-auto flex items-center justify-center space-x-2"
                  >
                    <span>Créer un compte gratuit</span>
                    <ArrowRight className="w-5 h-5 group-hover:translate-x-1 transition-transform" />
                  </Link>
                  <Link
                    href="/login"
                    className="px-8 py-4 bg-white text-brand-navy rounded-lg hover:bg-gray-50 transition-all hover:shadow-xl font-semibold text-lg w-full sm:w-auto"
                  >
                    Voir la démo
                  </Link>
                </>
              )}
            </motion.div>
          </motion.div>
        </div>

        {/* Animated Waves */}
        <div className="absolute bottom-0 left-0 right-0">
          <svg className="w-full h-24 lg:h-32" viewBox="0 0 1440 120" preserveAspectRatio="none">
            <motion.path
              initial={{ pathLength: 0 }}
              animate={{ pathLength: 1 }}
              transition={{ duration: 2, ease: 'easeInOut' }}
              d="M0,60 C240,90 480,30 720,60 C960,90 1200,30 1440,60 L1440,120 L0,120 Z"
              fill="white"
              opacity="0.8"
            />
            <motion.path
              initial={{ pathLength: 0 }}
              animate={{ pathLength: 1 }}
              transition={{ duration: 2.5, ease: 'easeInOut' }}
              d="M0,80 C240,50 480,110 720,80 C960,50 1200,110 1440,80 L1440,120 L0,120 Z"
              fill="white"
            />
          </svg>
        </div>
      </section>

      {/* Stats Section */}
      <section ref={statsRef} className="py-16 bg-gray-50">
        <motion.div
          variants={containerVariants}
          initial="hidden"
          animate={isStatsInView ? 'visible' : 'hidden'}
          className="max-w-7xl mx-auto px-6 lg:px-8"
        >
          <div className="grid grid-cols-2 lg:grid-cols-4 gap-8">
            {stats.map((stat, index) => {
              const IconComponent = stat.icon;
              return (
                <motion.div
                  key={index}
                  variants={itemVariants}
                  className="text-center group cursor-pointer"
                >
                  <div className="flex justify-center mb-3">
                    <div className="p-3 bg-brand-turquoise/10 rounded-full group-hover:bg-brand-turquoise/20 transition-colors">
                      <IconComponent className="w-8 h-8 text-brand-turquoise" />
                    </div>
                  </div>
                  <motion.div
                    initial={{ scale: 0 }}
                    animate={isStatsInView ? { scale: 1 } : {}}
                    transition={{ duration: 0.5, delay: index * 0.1 }}
                    className="text-5xl lg:text-6xl font-bold text-brand-navy mb-2"
                  >
                    {stat.value}
                  </motion.div>
                  <div className="text-gray-600 font-medium">{stat.label}</div>
                </motion.div>
              );
            })}
          </div>
        </motion.div>
      </section>

      {/* Features Section */}
      <section ref={featuresRef} id="features" className="py-20 lg:py-32">
        <div className="max-w-7xl mx-auto px-6 lg:px-8">
          <motion.div
            initial={{ opacity: 0, y: 30 }}
            animate={isFeaturesInView ? { opacity: 1, y: 0 } : {}}
            transition={{ duration: 0.8 }}
            className="text-center mb-16"
          >
            <h2 className="text-4xl lg:text-5xl font-bold text-brand-navy mb-4">
              Pourquoi choisir Xpeditis ?
            </h2>
            <p className="text-xl text-gray-600 max-w-2xl mx-auto">
              Une plateforme complète pour gérer tous vos besoins en fret maritime
            </p>
          </motion.div>

          <motion.div
            variants={containerVariants}
            initial="hidden"
            animate={isFeaturesInView ? 'visible' : 'hidden'}
            className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8"
          >
            {features.map((feature, index) => {
              const IconComponent = feature.icon;
              return (
                <motion.div
                  key={index}
                  variants={itemVariants}
                  whileHover={{ scale: 1.05, y: -10 }}
                >
                  <Link
                    href={feature.link}
                    className="group block bg-white p-8 rounded-2xl shadow-lg hover:shadow-2xl transition-all border border-gray-100"
                  >
                    <div
                      className={`w-14 h-14 rounded-xl bg-gradient-to-br ${feature.color} flex items-center justify-center mb-4 group-hover:scale-110 transition-transform`}
                    >
                      <IconComponent className="w-7 h-7 text-white" />
                    </div>
                    <h3 className="text-2xl font-bold text-brand-navy mb-3 group-hover:text-brand-turquoise transition-colors">{feature.title}</h3>
                    <p className="text-gray-600 leading-relaxed">{feature.description}</p>
                    <div className="mt-4 flex items-center text-brand-turquoise font-medium opacity-0 group-hover:opacity-100 transition-opacity">
                      <span>Découvrir</span>
                      <ArrowRight className="w-4 h-4 ml-2 group-hover:translate-x-1 transition-transform" />
                    </div>
                  </Link>
                </motion.div>
              );
            })}
          </motion.div>
        </div>
      </section>

      {/* Tools & Calculators Section */}
      <section
        ref={toolsRef}
        id="tools"
        className="py-20 lg:py-32 bg-gradient-to-br from-gray-50 to-white"
      >
        <div className="max-w-7xl mx-auto px-6 lg:px-8">
          <motion.div
            initial={{ opacity: 0, y: 30 }}
            animate={isToolsInView ? { opacity: 1, y: 0 } : {}}
            transition={{ duration: 0.8 }}
            className="text-center mb-16"
          >
            <h2 className="text-4xl lg:text-5xl font-bold text-brand-navy mb-4">
              Outils & Calculateurs
            </h2>
            <p className="text-xl text-gray-600 max-w-2xl mx-auto">
              Des outils puissants pour optimiser vos opérations maritimes
            </p>
          </motion.div>

          <motion.div
            variants={containerVariants}
            initial="hidden"
            animate={isToolsInView ? 'visible' : 'hidden'}
            className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"
          >
            {tools.map((tool, index) => {
              const IconComponent = tool.icon;
              return (
                <motion.div
                  key={index}
                  variants={itemVariants}
                  whileHover={{ y: -5 }}
                  className="group"
                >
                  <Link
                    href={tool.link}
                    className="block bg-white p-6 rounded-xl border-2 border-gray-200 hover:border-brand-turquoise transition-all hover:shadow-lg"
                  >
                    <div className="flex items-start space-x-4">
                      <div className="flex-shrink-0 w-12 h-12 bg-brand-turquoise/10 rounded-lg flex items-center justify-center group-hover:bg-brand-turquoise/20 transition-colors">
                        <IconComponent className="w-6 h-6 text-brand-turquoise" />
                      </div>
                      <div className="flex-1">
                        <h3 className="text-lg font-bold text-brand-navy mb-1 group-hover:text-brand-turquoise transition-colors">
                          {tool.title}
                        </h3>
                        <p className="text-sm text-gray-600">{tool.description}</p>
                      </div>
                      <ArrowRight className="w-5 h-5 text-gray-400 group-hover:text-brand-turquoise group-hover:translate-x-1 transition-all" />
                    </div>
                  </Link>
                </motion.div>
              );
            })}
          </motion.div>
        </div>
      </section>

      {/* Partner Logos Section */}
      <section className="py-16 bg-white">
        <div className="max-w-7xl mx-auto px-6 lg:px-8">
          <motion.div
            initial={{ opacity: 0, y: 20 }}
            whileInView={{ opacity: 1, y: 0 }}
            viewport={{ once: true }}
            transition={{ duration: 0.6 }}
            className="text-center mb-12"
          >
            <h3 className="text-2xl font-bold text-brand-navy mb-2">
              En partenariat avec les plus grandes compagnies maritimes
            </h3>
            <p className="text-gray-600">Accédez aux tarifs de 50+ transporteurs mondiaux</p>
          </motion.div>

          <motion.div
            initial={{ opacity: 0 }}
            whileInView={{ opacity: 1 }}
            viewport={{ once: true }}
            transition={{ duration: 0.8, delay: 0.2 }}
            className="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-8 items-center"
          >
            {[
              'ECU Line 2.png',
              'ICL 1.png',
              'NVO Consolidation 1.png',
              'TCC LOG 1.png',
              'VANGUARD 1.png',
              'image 1.png',
            ].map((logo, index) => (
              <motion.div
                key={index}
                initial={{ opacity: 0, scale: 0.8 }}
                whileInView={{ opacity: 1, scale: 1 }}
                viewport={{ once: true }}
                transition={{ duration: 0.5, delay: index * 0.1 }}
                whileHover={{ scale: 1.1 }}
                className="flex items-center justify-center p-4 grayscale hover:grayscale-0 transition-all cursor-pointer"
              >
                <Image
                  src={`/assets/logos/partner/${logo}`}
                  alt={`Partner ${index + 1}`}
                  width={120}
                  height={60}
                  className="object-contain h-12 w-auto"
                />
              </motion.div>
            ))}
          </motion.div>
        </div>
      </section>

      {/* Pricing Section */}
      <section
        ref={pricingRef}
        id="pricing"
        className="py-20 lg:py-32 bg-gradient-to-br from-gray-50 to-white"
      >
        <div className="max-w-7xl mx-auto px-6 lg:px-8">
          <motion.div
            initial={{ opacity: 0, y: 30 }}
            animate={isPricingInView ? { opacity: 1, y: 0 } : {}}
            transition={{ duration: 0.8 }}
            className="text-center mb-16"
          >
            <h2 className="text-4xl lg:text-5xl font-bold text-brand-navy mb-4">
              Tarifs simples et transparents
            </h2>
            <p className="text-xl text-gray-600 max-w-2xl mx-auto">
              Choisissez le plan adapté à vos besoins. Évoluez à tout moment.
            </p>
          </motion.div>

          <motion.div
            variants={containerVariants}
            initial="hidden"
            animate={isPricingInView ? 'visible' : 'hidden'}
            className="grid grid-cols-1 md:grid-cols-3 gap-8"
          >
            {pricingPlans.map((plan, index) => (
              <motion.div
                key={index}
                variants={itemVariants}
                whileHover={{ y: -10 }}
                className={`relative bg-white rounded-2xl shadow-lg border-2 transition-all ${
                  plan.highlighted
                    ? 'border-brand-turquoise shadow-2xl scale-105'
                    : 'border-gray-200 hover:border-brand-turquoise/50'
                }`}
              >
                {plan.highlighted && (
                  <div className="absolute -top-4 left-1/2 transform -translate-x-1/2">
                    <span className="bg-brand-turquoise text-white text-sm font-bold px-4 py-1 rounded-full">
                      Populaire
                    </span>
                  </div>
                )}
                <div className="p-8">
                  <h3 className="text-2xl font-bold text-brand-navy mb-2">{plan.name}</h3>
                  <p className="text-gray-600 mb-6">{plan.description}</p>
                  <div className="mb-6">
                    <span className="text-5xl font-bold text-brand-navy">{plan.price}</span>
                    <span className="text-gray-500">{plan.period}</span>
                  </div>
                  <ul className="space-y-3 mb-8">
                    {plan.features.map((feature, featureIndex) => (
                      <li key={featureIndex} className="flex items-center">
                        {feature.included ? (
                          <Check className="w-5 h-5 text-brand-green mr-3 flex-shrink-0" />
                        ) : (
                          <X className="w-5 h-5 text-gray-300 mr-3 flex-shrink-0" />
                        )}
                        <span className={feature.included ? 'text-gray-700' : 'text-gray-400'}>
                          {feature.text}
                        </span>
                      </li>
                    ))}
                  </ul>
                  <Link
                    href={plan.name === 'Enterprise' ? '/contact' : '/register'}
                    className={`block w-full text-center py-3 px-6 rounded-lg font-semibold transition-all ${
                      plan.highlighted
                        ? 'bg-brand-turquoise text-white hover:bg-brand-turquoise/90 shadow-lg hover:shadow-xl'
                        : 'bg-gray-100 text-brand-navy hover:bg-gray-200'
                    }`}
                  >
                    {plan.cta}
                  </Link>
                </div>
              </motion.div>
            ))}
          </motion.div>

          <motion.div
            initial={{ opacity: 0, y: 20 }}
            animate={isPricingInView ? { opacity: 1, y: 0 } : {}}
            transition={{ duration: 0.8, delay: 0.4 }}
            className="mt-12 text-center"
          >
            <p className="text-gray-600">
              Tous les plans incluent un essai gratuit de 14 jours. Aucune carte bancaire requise.
            </p>
            <p className="text-sm text-gray-500 mt-2">
              Des questions ? <Link href="/contact" className="text-brand-turquoise hover:underline">Contactez notre équipe commerciale</Link>
            </p>
          </motion.div>
        </div>
      </section>

      {/* How It Works Section */}
      <section className="py-20 lg:py-32 bg-gradient-to-br from-brand-navy to-brand-navy/95 relative overflow-hidden">
        <div className="absolute inset-0 opacity-10">
          <div className="absolute top-10 left-10 w-72 h-72 bg-brand-turquoise rounded-full blur-3xl" />
          <div className="absolute bottom-10 right-10 w-72 h-72 bg-brand-green rounded-full blur-3xl" />
        </div>

        <div className="max-w-7xl mx-auto px-6 lg:px-8 relative z-10">
          <motion.div
            initial={{ opacity: 0, y: 30 }}
            whileInView={{ opacity: 1, y: 0 }}
            viewport={{ once: true }}
            transition={{ duration: 0.8 }}
            className="text-center mb-16"
          >
            <h2 className="text-4xl lg:text-5xl font-bold text-white mb-4">Comment ça marche ?</h2>
            <p className="text-xl text-white/80 max-w-2xl mx-auto">
              Réservez votre fret maritime en 4 étapes simples
            </p>
          </motion.div>

          <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8">
            {[
              {
                step: '01',
                title: 'Recherchez',
                description: "Entrez vos ports de départ et d'arrivée",
                icon: Search,
              },
              {
                step: '02',
                title: 'Comparez',
                description: 'Analysez les tarifs de 50+ compagnies',
                icon: BarChart3,
              },
              {
                step: '03',
                title: 'Réservez',
                description: 'Confirmez votre booking en un clic',
                icon: CheckCircle2,
              },
              {
                step: '04',
                title: 'Suivez',
                description: 'Trackez votre envoi en temps réel',
                icon: Container,
              },
            ].map((step, index) => {
              const IconComponent = step.icon;
              return (
                <motion.div
                  key={index}
                  initial={{ opacity: 0, y: 30 }}
                  whileInView={{ opacity: 1, y: 0 }}
                  viewport={{ once: true }}
                  transition={{ duration: 0.6, delay: index * 0.1 }}
                  className="text-center"
                >
                  <div className="relative mb-6">
                    <div className="w-20 h-20 bg-brand-turquoise rounded-full flex items-center justify-center text-3xl font-bold text-white mx-auto shadow-xl">
                      {step.step}
                    </div>
                    <div className="absolute inset-0 flex items-center justify-center">
                      <IconComponent className="w-8 h-8 text-white/30" />
                    </div>
                    {index < 3 && (
                      <div className="hidden lg:block absolute top-10 left-[60%] w-full h-0.5 bg-brand-turquoise/30" />
                    )}
                  </div>
                  <h3 className="text-2xl font-bold text-white mb-2">{step.title}</h3>
                  <p className="text-white/70">{step.description}</p>
                </motion.div>
              );
            })}
          </div>
        </div>
      </section>

      {/* Testimonials Section */}
      <section
        ref={testimonialsRef}
        className="py-20 lg:py-32 bg-gradient-to-br from-gray-50 to-white"
      >
        <div className="max-w-7xl mx-auto px-6 lg:px-8">
          <motion.div
            initial={{ opacity: 0, y: 30 }}
            animate={isTestimonialsInView ? { opacity: 1, y: 0 } : {}}
            transition={{ duration: 0.8 }}
            className="text-center mb-16"
          >
            <h2 className="text-4xl lg:text-5xl font-bold text-brand-navy mb-4">
              Ils nous font confiance
            </h2>
            <p className="text-xl text-gray-600 max-w-2xl mx-auto">
              Découvrez les témoignages de nos clients satisfaits
            </p>
          </motion.div>

          <motion.div
            variants={containerVariants}
            initial="hidden"
            animate={isTestimonialsInView ? 'visible' : 'hidden'}
            className="grid grid-cols-1 md:grid-cols-3 gap-8"
          >
            {testimonials.map((testimonial, index) => (
              <motion.div
                key={index}
                variants={itemVariants}
                whileHover={{ y: -10 }}
                className="bg-white p-8 rounded-2xl shadow-lg border border-gray-100"
              >
                <div className="flex mb-4">
                  {[...Array(5)].map((_, i) => (
                    <svg
                      key={i}
                      className="w-5 h-5 text-yellow-400 fill-current"
                      viewBox="0 0 20 20"
                    >
                      <path d="M10 15l-5.878 3.09 1.123-6.545L.489 6.91l6.572-.955L10 0l2.939 5.955 6.572.955-4.756 4.635 1.123 6.545z" />
                    </svg>
                  ))}
                </div>
                <p className="text-gray-700 mb-6 leading-relaxed italic">"{testimonial.quote}"</p>
                <div className="border-t pt-4">
                  <div className="font-bold text-brand-navy">{testimonial.author}</div>
                  <div className="text-sm text-gray-600">
                    {testimonial.role} - {testimonial.company}
                  </div>
                </div>
              </motion.div>
            ))}
          </motion.div>
        </div>
      </section>

      {/* CTA Section */}
      <section ref={ctaRef} className="py-20 lg:py-32">
        <motion.div
          variants={containerVariants}
          initial="hidden"
          animate={isCtaInView ? 'visible' : 'hidden'}
          className="max-w-4xl mx-auto px-6 lg:px-8 text-center"
        >
          <motion.div variants={itemVariants}>
            <h2 className="text-4xl lg:text-5xl font-bold text-brand-navy mb-6">
              Prêt à simplifier votre fret maritime ?
            </h2>
            <p className="text-xl text-gray-600 mb-10">
              Rejoignez des centaines de transitaires qui font confiance à Xpeditis pour leurs
              expéditions maritimes.
            </p>
          </motion.div>

          <motion.div
            variants={itemVariants}
            className="flex flex-col sm:flex-row items-center justify-center space-y-4 sm:space-y-0 sm:space-x-6"
          >
            {isAuthenticated && user ? (
              <Link
                href="/dashboard"
                className="group px-8 py-4 bg-brand-turquoise text-white rounded-lg hover:bg-brand-turquoise/90 transition-all hover:shadow-2xl hover:scale-105 font-semibold text-lg w-full sm:w-auto flex items-center justify-center space-x-2"
              >
                <span>Accéder au Dashboard</span>
                <LayoutDashboard className="w-5 h-5 group-hover:translate-x-1 transition-transform" />
              </Link>
            ) : (
              <>
                <Link
                  href="/register"
                  className="group px-8 py-4 bg-brand-turquoise text-white rounded-lg hover:bg-brand-turquoise/90 transition-all hover:shadow-2xl hover:scale-105 font-semibold text-lg w-full sm:w-auto flex items-center justify-center space-x-2"
                >
                  <span>Créer un compte gratuit</span>
                  <ArrowRight className="w-5 h-5 group-hover:translate-x-1 transition-transform" />
                </Link>
                <Link
                  href="/login"
                  className="px-8 py-4 bg-brand-navy text-white rounded-lg hover:bg-brand-navy/90 transition-all hover:shadow-xl font-semibold text-lg w-full sm:w-auto"
                >
                  Se connecter
                </Link>
              </>
            )}
          </motion.div>

          <motion.div
            variants={itemVariants}
            className="flex items-center justify-center space-x-6 mt-8 text-sm text-gray-500"
          >
            <div className="flex items-center space-x-2">
              <CheckCircle2 className="w-4 h-4 text-brand-green" />
              <span>Sans carte bancaire</span>
            </div>
            <div className="flex items-center space-x-2">
              <Clock className="w-4 h-4 text-brand-green" />
              <span>Configuration en 2 min</span>
            </div>
            <div className="flex items-center space-x-2">
              <Shield className="w-4 h-4 text-brand-green" />
              <span>Données sécurisées</span>
            </div>
          </motion.div>
        </motion.div>
      </section>

      <LandingFooter />
    </div>
  );
}
