'use client';

import { motion } from 'framer-motion';
import { useTranslator } from '@/contexts/TranslatorContext';
import { ShieldCheck, MailX, Mail, Radar } from 'lucide-react';

const WhyChooseUs = () => {
  const { translations, dir } = useTranslator();

  const features = [
    {
      icon: ShieldCheck,
      title:
        translations.whyChooseUs?.features?.blockUnauthorized?.title ||
        'حظر البريد الإلكتروني غير المصرح به',
      description:
        translations.whyChooseUs?.features?.blockUnauthorized?.description ||
        'يقوم PowerDMARC باستخدام القوة المشتركة لتقنيتي SPF و DKIM ليوفر لك حماية لا مثيل لها للبريد الإلكتروني. مع إمكانية الحصول على نتائج رسائل البريد الإلكتروني التي فشلت في المصادقة حتى تتمتع بالتحكم الكامل.',
    },
    {
      icon: MailX,
      title:
        translations.whyChooseUs?.features?.brandImage?.title ||
        'عزز صورة علامتك التجارية',
      description:
        translations.whyChooseUs?.features?.brandImage?.description ||
        'عندما تقوم باستخدام PowerDMARC، فإنك لا تقضي على عمليات انتحال البريد الإلكتروني فحسب، بل يمكنك أيضًا استخدام التقارير المفصلة لتغيير استراتيجية المحتوى الخاصة بك على الفور. لا تترك مجالًا للصدفة.',
    },
    {
      icon: Mail,
      title:
        translations.whyChooseUs?.features?.deliverability?.title ||
        'تحسين إمكانية التسليم',
      description:
        translations.whyChooseUs?.features?.deliverability?.description ||
        'تطبيق PowerDMARC يوضح للخدمات المتلقية أنك ملتزم بتحسين أمان بريدك الإلكتروني، مما يزيد من احتمالية وصول بريدك الإلكتروني إلى صناديق البريد الوارد للأشخاص المستهدفين.',
    },
    {
      icon: Radar,
      title:
        translations.whyChooseUs?.features?.threatMonitoring?.title ||
        'مراقبة التهديدات في الوقت الفعلي',
      description:
        translations.whyChooseUs?.features?.threatMonitoring?.description ||
        'باستخدام محرك استخبارات التهديدات المعتمد على الذكاء الاصطناعي، يمكنك تتبع المصادر الضارة التي تنتحل اسم نطاقك أينما كانت في العالم.',
    },
  ];

  const containerVariants = {
    hidden: { opacity: 0 },
    visible: {
      opacity: 1,
      transition: {
        staggerChildren: 0.15,
      },
    },
  };

  const cardVariants = {
    hidden: { opacity: 0, y: 40 },
    visible: {
      opacity: 1,
      y: 0,
      transition: { duration: 0.5, ease: 'easeOut' },
    },
  };

  return (
    <section
      className='w-full py-16 md:py-20 bg-[#f8f9fc]'
      dir={dir}>
      <div className='container mx-auto px-4 md:px-6'>
        {/* Title */}
        <motion.div
          className='text-center mb-12'
          initial={{ opacity: 0, y: 30 }}
          whileInView={{ opacity: 1, y: 0 }}
          viewport={{ once: true }}
          transition={{ duration: 0.6 }}>
          <h2 className='text-2xl md:text-3xl font-bold text-[#1a1a2e]'>
            {translations.whyChooseUs?.title || 'لماذا نختار النمور'}
          </h2>
        </motion.div>

        {/* Cards Grid */}
        <motion.div
          className='grid grid-cols-1 md:grid-cols-2 gap-6 max-w-5xl mx-auto'
          initial='hidden'
          whileInView='visible'
          viewport={{ once: true }}
          variants={containerVariants}>
          {features.map((feature, index) => (
            <motion.div
              key={index}
              variants={cardVariants}
              whileHover={{ y: -5, transition: { duration: 0.2 } }}
              className='bg-white rounded-xl p-8 shadow-sm hover:shadow-lg transition-shadow text-right'>
              {/* Icon */}
              <motion.div
                className='flex justify-start mb-5'
                initial={{ scale: 0.8, opacity: 0 }}
                whileInView={{ scale: 1, opacity: 1 }}
                viewport={{ once: true }}
                transition={{ duration: 0.4, delay: index * 0.1 }}>
                <div className='w-12 h-12 flex items-center justify-center'>
                  <feature.icon className='w-10 h-10 text-[#3B82F6]' strokeWidth={1.5} />
                </div>
              </motion.div>

              {/* Title */}
              <h3 className='text-base md:text-lg font-semibold text-[#1a1a2e] mb-3'>
                {feature.title}
              </h3>

              {/* Description */}
              <p className='text-sm text-gray-500 leading-relaxed'>
                {feature.description}
              </p>
            </motion.div>
          ))}
        </motion.div>
      </div>
    </section>
  );
};

export default WhyChooseUs;
