import React from 'react';
import { motion, useReducedMotion } from 'framer-motion';

const fadeUpPreset = (delay = 0, duration = 1.2) => ({
  initial: { opacity: 0, y: 20 },
  whileInView: { opacity: 1, y: 0 },
  viewport: { once: true, amount: 0.2 },
  transition: { delay, duration, ease: "easeOut" }
});

const EnterpriseSection = () => {
  const shouldReduce = useReducedMotion();

  if (shouldReduce) {
    return (
      <section className="section-padding bg-nest-red text-white relative overflow-hidden">
        <div className="absolute inset-0">
          <img 
            src="https://nestjs.com/img/enterprise-bg.jpg" 
            alt="" 
            className="w-full h-full object-cover opacity-20"
          />
        </div>
        
        <div className="relative z-10 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
          <div className="grid grid-cols-1 lg:grid-cols-2 gap-12 items-center">
            <div>
              <h2 className="text-4xl lg:text-5xl font-bold mb-6">
                The open source platform designed for the future. Build enterprise.
              </h2>
              <p className="text-red-100 text-lg mb-8 leading-relaxed">
                A complete development platform for building enterprise-grade applications. Get professional support, training, and consulting services.
              </p>
              <button className="bg-white text-nest-red px-8 py-4 rounded-lg font-semibold hover:bg-gray-100 transition-colors">
                Learn more about Enterprise
              </button>
            </div>
            
            <div className="flex justify-center lg:justify-end">
              <img 
                src="https://nestjs.com/img/cat-enterprise.png" 
                alt="NestJS Enterprise" 
                className="max-w-sm w-full h-auto"
              />
            </div>
          </div>
        </div>
      </section>
    );
  }

  return (
    <motion.section 
      {...fadeUpPreset(0.1, 1.0)}
      className="section-padding bg-nest-red text-white relative overflow-hidden"
    >
      <div className="absolute inset-0">
        <img 
          src="https://nestjs.com/img/enterprise-bg.jpg" 
          alt="" 
          className="w-full h-full object-cover opacity-20"
        />
      </div>
      
      <div className="relative z-10 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div className="grid grid-cols-1 lg:grid-cols-2 gap-12 items-center">
          <motion.div {...fadeUpPreset(0.2, 0.8)}>
            <h2 className="text-4xl lg:text-5xl font-bold mb-6">
              The open source platform designed for the future. Build enterprise.
            </h2>
            <p className="text-red-100 text-lg mb-8 leading-relaxed">
              A complete development platform for building enterprise-grade applications. Get professional support, training, and consulting services.
            </p>
            <button className="bg-white text-nest-red px-8 py-4 rounded-lg font-semibold hover:bg-gray-100 transition-colors">
              Learn more about Enterprise
            </button>
          </motion.div>
          
          <motion.div 
            {...fadeUpPreset(0.3, 0.8)}
            className="flex justify-center lg:justify-end"
          >
            <img 
              src="https://nestjs.com/img/cat-enterprise.png" 
              alt="NestJS Enterprise" 
              className="max-w-sm w-full h-auto"
            />
          </motion.div>
        </div>
      </div>
    </motion.section>
  );
};

export default EnterpriseSection;