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

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

  const bikes = [
    {
      name: "COPPERHEAD EVO 1",
      price: "from 3,199.00*",
      rating: 5,
      image: "https://www.bulls-bikes.com/fileadmin/_processed_/4/1/csm_BULLS_Copperhead_EVO_1_29_black_2024_01_a8c8f5e5a7.jpg",
      colors: ['#000', '#666', '#999']
    },
    {
      name: "EVO CX 1",
      price: "4,799.00*",
      rating: 5,
      image: "https://www.bulls-bikes.com/fileadmin/_processed_/8/2/csm_BULLS_EVO_CX_1_black_2024_01_b5c8a5e5a7.jpg",
      colors: ['#000', '#333']
    },
    {
      name: "GRINDER 1",
      price: "3,499.00*",
      rating: 5,
      image: "https://www.bulls-bikes.com/fileadmin/_processed_/1/5/csm_BULLS_Grinder_1_black_2024_01_c8f5e5a7b5.jpg",
      colors: ['#000', '#666', '#999', '#ccc']
    }
  ];

  const BikeCard = ({ bike, index }) => {
    const CardComponent = shouldReduceMotion ? 'div' : motion.div;
    const cardProps = shouldReduceMotion ? {} : fadeUpPreset(index * 0.1, 0.8);

    return (
      <CardComponent {...cardProps} className="product-card">
        <div className="aspect-w-16 aspect-h-12 bg-gray-100">
          <img 
            src={bike.image} 
            alt={bike.name}
            className="w-full h-64 object-contain p-4"
          />
        </div>
        <div className="p-6">
          <h3 className="text-lg font-bold text-bulls-gray mb-2">{bike.name}</h3>
          <div className="flex items-center mb-3">
            {[...Array(bike.rating)].map((_, i) => (
              <Star key={i} className="w-4 h-4 text-yellow-400 fill-current" />
            ))}
          </div>
          <p className="text-xl font-bold text-bulls-gray mb-4">{bike.price}</p>
          <div className="flex space-x-2 mb-4">
            {bike.colors.map((color, i) => (
              <div 
                key={i}
                className="w-4 h-4 rounded-full border border-gray-300"
                style={{ backgroundColor: color }}
              ></div>
            ))}
          </div>
        </div>
      </CardComponent>
    );
  };

  const SectionComponent = shouldReduceMotion ? 'section' : motion.section;
  const sectionProps = shouldReduceMotion ? {} : fadeUpPreset(0.05, 1.0);

  return (
    <SectionComponent {...sectionProps} className="section-padding bg-bulls-light-gray">
      <div className="container-max">
        <div className="text-center mb-12">
          <h2 className="text-3xl md:text-4xl font-bold text-bulls-gray mb-4">TOP E-BIKES</h2>
          <div className="flex justify-center space-x-2 mb-8">
            <div className="w-2 h-2 bg-bulls-blue rounded-full"></div>
            <div className="w-2 h-2 bg-gray-300 rounded-full"></div>
            <div className="w-2 h-2 bg-gray-300 rounded-full"></div>
          </div>
        </div>
        
        <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
          {bikes.map((bike, index) => (
            <BikeCard key={index} bike={bike} index={index} />
          ))}
        </div>
        
        <div className="text-center mt-12">
          <div className="flex justify-center space-x-1">
            {[...Array(12)].map((_, i) => (
              <div 
                key={i}
                className={`w-2 h-2 rounded-full ${
                  i < 4 ? 'bg-bulls-blue' : 'bg-gray-300'
                }`}
              ></div>
            ))}
          </div>
        </div>
      </div>
    </SectionComponent>
  );
};

export default TopEBikes;