'use client';

import { useTranslator } from '@/contexts/TranslatorContext';
import { motion } from 'framer-motion';
import Image from 'next/image';
import { Button } from '@/components/ui/button';

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

  return (
    <section
      className='w-full py-1 md:py-2 lg:py-3 relative overflow-hidden -mt-8 md:-mt-12 lg:-mt-16'
      dir={dir}>
      <div className='w-full flex justify-center'>
        <div className='w-[80%] bg-[#333C5E] rounded-lg py-1 md:py-2 lg:py-3 relative'>
          <div className='container mx-auto px-4 relative z-10'>
            <div className='flex flex-col lg:flex-row items-center justify-between gap-3 lg:gap-4'>
              {/* Left Side - Database Stack (Top) and Cloud with Arrow (Bottom) */}
              <motion.div
                initial={{ opacity: 0, x: -50 }}
                whileInView={{ opacity: 1, x: 0 }}
                transition={{ duration: 0.8, delay: 0.2 }}
                viewport={{ once: true }}
                className='flex-shrink-0 hidden lg:block'>
                <div className='relative w-48 h-48 flex flex-col items-center justify-center gap-3'>
                  {/* Database Stack - Top - حركة نبض للأيقونة */}
                  <div className='relative w-24 h-24 animate-icon-pulse'>
                    <Image
                      src='/images/Backups/database-stack.svg'
                      alt='Database stack'
                      fill
                      className='object-contain'
                      priority
                    />
                  </div>
                  {/* Cloud with Arrow - Bottom */}
                  <div className='relative w-24 h-24 animate-icon-pulse animate-icon-pulse-delay-1'>
                    <Image
                      src='/images/Backups/datacenter-right.svg'
                      alt='Cloud with arrow'
                      fill
                      className='object-contain'
                      priority
                    />
                  </div>
                </div>
              </motion.div>

              {/* Center Content */}
              <div className='flex-1 text-center lg:text-center space-y-1 md:space-y-2'>
                <motion.h2
                  initial={{ opacity: 0, y: 30 }}
                  whileInView={{ opacity: 1, y: 0 }}
                  transition={{ duration: 0.6, delay: 0.3 }}
                  viewport={{ once: true }}
                  className='text-lg md:text-xl lg:text-2xl font-bold text-white leading-relaxed'>
                  {translations['backupsCTA.title'] ||
                    'انضم لآلاف العملاء الذين يثقون بنا في حماية مواقعهم. احصل على نسخ احتياطية تلقائية وحماية شاملة لبياناتك'}
                </motion.h2>

                <motion.div
                  initial={{ opacity: 0, y: 20 }}
                  whileInView={{ opacity: 1, y: 0 }}
                  transition={{ duration: 0.6, delay: 0.5 }}
                  viewport={{ once: true }}>
                  <Button
                    className='bg-white text-[#333C5E] hover:bg-gray-100 rounded-lg px-6 py-4 text-base md:text-lg font-semibold mt-1'
                    dir={dir}>
                    {translations['backupsCTA.button'] ||
                      'ابدأ النسخ الاحتياطية الآن !'}
                  </Button>
                </motion.div>

                <motion.p
                  initial={{ opacity: 0, y: 20 }}
                  whileInView={{ opacity: 1, y: 0 }}
                  transition={{ duration: 0.6, delay: 0.7 }}
                  viewport={{ once: true }}
                  className='text-white/90 text-xs md:text-sm mt-12 md:mt-16'>
                  {translations['backupsCTA.disclaimer'] ||
                    'لا يتطلب بطاقة ائتمانية • إلغاء مجاني في أي وقت • دعم فني مجاني'}
                </motion.p>
              </div>

              {/* Right Side - Cloud with Servers */}
              <motion.div
                initial={{ opacity: 0, x: 50 }}
                whileInView={{ opacity: 1, x: 0 }}
                transition={{ duration: 0.8, delay: 0.2 }}
                viewport={{ once: true }}
                className='flex-shrink-0 hidden lg:block'>
                <div className='relative w-48 h-48 animate-icon-pulse animate-icon-pulse-delay-2'>
                  <Image
                    src='/images/Backups/cloud-server-left.svg'
                    alt='Cloud with servers'
                    fill
                    className='object-contain'
                    priority
                  />
                </div>
              </motion.div>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
};

export default BackupsCTASection;

