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 EverythingYouNeed = () => {
  const shouldReduce = useReducedMotion();

  const features = [
    {
      icon: (
        <svg className="w-12 h-12" viewBox="0 0 48 48" fill="none">
          <rect x="8" y="8" width="32" height="32" rx="4" stroke="#666" strokeWidth="2" fill="none"/>
          <path d="M16 20h16M16 24h12M16 28h8" stroke="#666" strokeWidth="2"/>
        </svg>
      ),
      title: "POWERFUL CLI",
      description: "Scaffold projects and generate application components with a single command."
    },
    {
      icon: (
        <svg className="w-12 h-12" viewBox="0 0 48 48" fill="none">
          <path d="M24 8l8 8-8 8-8-8 8-8z" stroke="#666" strokeWidth="2" fill="none"/>
          <path d="M12 20l6 6-6 6-6-6 6-6z" stroke="#666" strokeWidth="2" fill="none"/>
          <path d="M36 20l6 6-6 6-6-6 6-6z" stroke="#666" strokeWidth="2" fill="none"/>
          <path d="M24 32l8 8-8 8-8-8 8-8z" stroke="#666" strokeWidth="2" fill="none"/>
        </svg>
      ),
      title: "LANGUAGE AGNOSTIC",
      description: "Built with TypeScript, but preserves compatibility with pure JavaScript."
    },
    {
      icon: (
        <svg className="w-12 h-12" viewBox="0 0 48 48" fill="none">
          <circle cx="24" cy="24" r="16" stroke="#666" strokeWidth="2" fill="none"/>
          <path d="M24 8v32M8 24h32" stroke="#666" strokeWidth="2"/>
          <circle cx="24" cy="24" r="4" fill="#666"/>
        </svg>
      ),
      title: "MICROSERVICE READY",
      description: "Build microservices with gRPC, TCP, and message queue support."
    },
    {
      icon: (
        <svg className="w-12 h-12" viewBox="0 0 48 48" fill="none">
          <path d="M8 16h32v24H8V16z" stroke="#666" strokeWidth="2" fill="none"/>
          <path d="M16 24h16M16 28h12" stroke="#666" strokeWidth="2"/>
          <circle cx="20" cy="20" r="2" fill="#666"/>
        </svg>
      ),
      title: "ELEGANT SYNTAX",
      description: "Highly testable, scalable, loosely coupled, and easily maintainable applications."
    },
    {
      icon: (
        <svg className="w-12 h-12" viewBox="0 0 48 48" fill="none">
          <rect x="8" y="12" width="32" height="24" rx="2" stroke="#666" strokeWidth="2" fill="none"/>
          <path d="M8 20h32" stroke="#666" strokeWidth="2"/>
          <circle cx="14" cy="16" r="1" fill="#666"/>
          <circle cx="18" cy="16" r="1" fill="#666"/>
          <circle cx="22" cy="16" r="1" fill="#666"/>
        </svg>
      ),
      title: "RICH ECOSYSTEM",
      description: "Leverage the countless third-party plugins and libraries."
    },
    {
      icon: (
        <svg className="w-12 h-12" viewBox="0 0 48 48" fill="none">
          <path d="M24 8l12 8v16l-12 8-12-8V16l12-8z" stroke="#666" strokeWidth="2" fill="none"/>
          <path d="M24 8v32M12 16l24 16M36 16L12 32" stroke="#666" strokeWidth="2"/>
        </svg>
      ),
      title: "DEPENDENCY INJECTION",
      description: "Built-in IoC container with a sophisticated dependency injection system."
    },
    {
      icon: (
        <svg className="w-12 h-12" viewBox="0 0 48 48" fill="none">
          <circle cx="24" cy="24" r="16" stroke="#666" strokeWidth="2" fill="none"/>
          <path d="M16 24l6 6 12-12" stroke="#666" strokeWidth="2" fill="none"/>
        </svg>
      ),
      title: "TESTING UTILITIES",
      description: "Dedicated testing utilities and mocks for easier application testing."
    },
    {
      icon: (
        <svg className="w-12 h-12" viewBox="0 0 48 48" fill="none">
          <rect x="8" y="8" width="32" height="32" rx="4" stroke="#666" strokeWidth="2" fill="none"/>
          <path d="M16 18h16M16 24h16M16 30h10" stroke="#666" strokeWidth="2"/>
          <circle cx="34" cy="14" r="3" fill="#e0234e"/>
        </svg>
      ),
      title: "AUTO-DOCS",
      description: "Automatically generate API documentation using decorators."
    }
  ];

  if (shouldReduce) {
    return (
      <section className="section-padding bg-white">
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
          <div className="text-center mb-16">
            <h2 className="text-4xl md:text-5xl font-bold text-nest-text mb-4">
              Everything you need...
            </h2>
            <p className="text-xl text-nest-text-light max-w-3xl mx-auto">
              Built with powerful features and an extensive ecosystem. The framework that scales with your needs.
            </p>
          </div>
          
          <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8">
            {features.map((feature, index) => (
              <div key={index} className="text-center p-6">
                <div className="flex justify-center mb-4">
                  {feature.icon}
                </div>
                <h3 className="font-semibold text-sm text-nest-text mb-3 tracking-wider">
                  {feature.title}
                </h3>
                <p className="text-nest-text-light text-sm leading-relaxed">
                  {feature.description}
                </p>
              </div>
            ))}
          </div>
        </div>
      </section>
    );
  }

  return (
    <motion.section 
      {...fadeUpPreset(0.1, 1.0)}
      className="section-padding bg-white"
    >
      <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-4xl md:text-5xl font-bold text-nest-text mb-4">
            Everything you need...
          </h2>
          <p className="text-xl text-nest-text-light max-w-3xl mx-auto">
            Built with powerful features and an extensive ecosystem. The framework that scales with your needs.
          </p>
        </motion.div>
        
        <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8">
          {features.map((feature, index) => (
            <motion.div 
              key={index} 
              {...fadeUpPreset(0.3 + (index * 0.05), 0.6)}
              className="text-center p-6"
            >
              <div className="flex justify-center mb-4">
                {feature.icon}
              </div>
              <h3 className="font-semibold text-sm text-nest-text mb-3 tracking-wider">
                {feature.title}
              </h3>
              <p className="text-nest-text-light text-sm leading-relaxed">
                {feature.description}
              </p>
            </motion.div>
          ))}
        </div>
      </div>
    </motion.section>
  );
};

export default EverythingYouNeed;