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 Services = () => {
  const shouldReduceMotion = useReducedMotion();

  if (shouldReduceMotion) {
    return (
      <section className="py-20 gradient-bg">
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
          <div className="text-center mb-16">
            <h2 className="text-3xl lg:text-4xl font-bold text-gray-900 mb-4">
              Explore our services
            </h2>
          </div>

          <div className="grid lg:grid-cols-2 gap-16 items-center">
            {/* Web Development */}
            <div className="service-card">
              <h3 className="text-2xl font-bold text-gray-900 mb-4">Web Development</h3>
              <p className="text-gray-600 mb-6">Custom web applications built with modern technologies and best practices.</p>
              <div className="w-full h-64 bg-gradient-to-br from-blue-100 to-blue-200 rounded-lg flex items-center justify-center">
                <div className="text-center">
                  <div className="w-16 h-16 bg-blue-500 rounded-lg mx-auto mb-4 flex items-center justify-center">
                    <span className="text-white text-2xl">🌐</span>
                  </div>
                  <p className="text-blue-700 font-medium">Web Development</p>
                </div>
              </div>
            </div>

            {/* Mobile Development */}
            <div className="service-card">
              <h3 className="text-2xl font-bold text-gray-900 mb-4">Mobile Development</h3>
              <p className="text-gray-600 mb-6">Native and cross-platform mobile applications for iOS and Android.</p>
              <div className="w-full h-64 bg-gradient-to-br from-gray-100 to-gray-200 rounded-lg flex items-center justify-center">
                <div className="w-32 h-56 bg-blue-500 rounded-2xl shadow-lg flex items-center justify-center">
                  <div className="w-24 h-48 bg-white rounded-xl flex items-center justify-center">
                    <span className="text-blue-500 text-2xl">📱</span>
                  </div>
                </div>
              </div>
            </div>
          </div>

          <div className="text-center mt-16">
            <div className="bg-white rounded-xl p-8 card-shadow max-w-2xl mx-auto">
              <h3 className="text-xl font-semibold text-gray-900 mb-2">
                Get the same high-quality service for a smaller task
              </h3>
            </div>
          </div>
        </div>
      </section>
    );
  }

  return (
    <motion.section 
      {...fadeUpPreset(0.1, 1.0)}
      className="py-20 gradient-bg"
    >
      <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <motion.div 
          {...fadeUpPreset(0.2, 0.8)}
          className="text-center mb-16"
        >
          <h2 className="text-3xl lg:text-4xl font-bold text-gray-900 mb-4">
            Explore our services
          </h2>
        </motion.div>

        <div className="grid lg:grid-cols-2 gap-16 items-center">
          {/* Web Development */}
          <motion.div 
            {...fadeUpPreset(0.3, 0.8)}
            className="service-card"
          >
            <h3 className="text-2xl font-bold text-gray-900 mb-4">Web Development</h3>
            <p className="text-gray-600 mb-6">Custom web applications built with modern technologies and best practices.</p>
            <div className="w-full h-64 bg-gradient-to-br from-blue-100 to-blue-200 rounded-lg flex items-center justify-center">
              <div className="text-center">
                <div className="w-16 h-16 bg-blue-500 rounded-lg mx-auto mb-4 flex items-center justify-center">
                  <span className="text-white text-2xl">🌐</span>
                </div>
                <p className="text-blue-700 font-medium">Web Development</p>
              </div>
            </div>
          </motion.div>

          {/* Mobile Development */}
          <motion.div 
            {...fadeUpPreset(0.4, 0.8)}
            className="service-card"
          >
            <h3 className="text-2xl font-bold text-gray-900 mb-4">Mobile Development</h3>
            <p className="text-gray-600 mb-6">Native and cross-platform mobile applications for iOS and Android.</p>
            <div className="w-full h-64 bg-gradient-to-br from-gray-100 to-gray-200 rounded-lg flex items-center justify-center">
              <div className="w-32 h-56 bg-blue-500 rounded-2xl shadow-lg flex items-center justify-center">
                <div className="w-24 h-48 bg-white rounded-xl flex items-center justify-center">
                  <span className="text-blue-500 text-2xl">📱</span>
                </div>
              </div>
            </div>
          </motion.div>
        </div>

        <motion.div 
          {...fadeUpPreset(0.5, 0.8)}
          className="text-center mt-16"
        >
          <div className="bg-white rounded-xl p-8 card-shadow max-w-2xl mx-auto">
            <h3 className="text-xl font-semibold text-gray-900 mb-2">
              Get the same high-quality service for a smaller task
            </h3>
          </div>
        </motion.div>
      </div>
    </motion.section>
  );
};

export default Services;