import { Link } from 'react-router-dom';
import { motion } from 'framer-motion';
import { HiArrowRight } from 'react-icons/hi';
import { PROGRAMS } from '../../utils/constants';
import './ProgramsGrid.css';

const PROGRAM_IMAGES = {
  medical: 'https://images.unsplash.com/photo-1584515933487-779824d29309?auto=format&fit=crop&q=80',
  education: 'https://images.unsplash.com/photo-1503676260728-1c00da094a0b?auto=format&fit=crop&q=80',
  animal: 'https://images.unsplash.com/photo-1454179083322-198bb4daae41?auto=format&fit=crop&q=80',
  disaster: 'https://images.unsplash.com/photo-1617494532490-297fc0eb515e?auto=format&fit=crop&q=80',
  elderly: 'https://images.unsplash.com/photo-1490349708435-19d432984978?auto=format&fit=crop&q=80',
};

export default function ProgramsGrid() {
  return (
    <section className="programs section" id="programs">
      <div className="container">
        <div className="section-header">
          <span className="section-header__tag">🌍 Our Programs</span>
          <h2 className="section-header__title">What We Do</h2>
          <p className="section-header__subtitle">
            We work across five critical areas to create lasting impact in communities that need it most.
          </p>
        </div>

        <div className="programs__grid">
          {PROGRAMS.map((program, index) => (
            <motion.div
              key={program.id}
              className="programs__card"
              initial={{ opacity: 0, y: 30 }}
              whileInView={{ opacity: 1, y: 0 }}
              viewport={{ once: true }}
              transition={{ delay: index * 0.12, duration: 0.5 }}
              style={{
                display: 'flex',
                flexDirection: 'column',
                justifyContent: 'flex-end',
                minHeight: '350px',
                border: 'none',
              }}
            >
              {/* Background Image with Overlay */}
              <div
                style={{
                  position: 'absolute',
                  top: 0, left: 0, right: 0, bottom: 0,
                  backgroundImage: `url(${PROGRAM_IMAGES[program.id]})`,
                  backgroundSize: 'cover',
                  backgroundPosition: 'center',
                  zIndex: 0,
                  transition: 'transform 0.5s ease',
                }}
                className="programs__card-bg-img"
              />
              <div
                style={{
                  position: 'absolute',
                  top: 0, left: 0, right: 0, bottom: 0,
                  background: 'linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.4) 50%, rgba(0,0,0,0.1) 100%)',
                  zIndex: 1
                }}
              />

              {/* Content */}
              <div style={{ position: 'relative', zIndex: 2 }}>
                <h3 className="programs__title" style={{ color: 'white', fontSize: '1.5rem', marginBottom: '0.5rem' }}>{program.title}</h3>
                <p className="programs__desc" style={{ color: 'rgba(255, 255, 255, 0.9)', marginBottom: '1.25rem' }}>{program.description}</p>
                <Link to={`/our-work#${program.id}`} className="programs__link" style={{ color: program.color, textShadow: '0 1px 2px rgba(0,0,0,0.5)' }}>
                  Learn More <HiArrowRight />
                </Link>
              </div>
            </motion.div>
          ))}
        </div>
      </div>
    </section>
  );
}
