

import React from 'react';
import { SECTION_IDS, ACCELERATOR_PROJECTS_CONTENT } from '../constants'; 
import { AcceleratorProject } from '../types'; 
import Button from './Button'; 
import { CubeTransparentIcon, TagIcon, LinkIcon } from '@heroicons/react/24/outline';

interface ProjectCardProps {
  project: AcceleratorProject; 
}

const ProjectCard: React.FC<ProjectCardProps> = ({ project }) => (
  <div className="bg-white rounded-xl transition-all duration-300 ease-in-out flex flex-col overflow-hidden">
    <div className="relative w-full aspect-[16/9] overflow-hidden">
      <img src={project.imageUrl} alt={project.name} className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-300" loading="lazy" />
    </div>
    <div className="p-5 flex flex-col flex-grow">
      <h3 className="font-quicksand text-2xl font-semibold text-slate-800 mb-1">{project.name}</h3>
      <p className="font-inter text-sm text-slate-600 mb-2">{project.tagline}</p>
      <div className="flex items-center text-xs text-slate-500 mb-3">
        <TagIcon className="w-4 h-4 mr-1 text-slate-500" />
        <span>{project.category}</span>
        <span className="mx-1.5">•</span>
        <span className="px-2 py-0.5 rounded-full text-xs font-semibold bg-slate-100 text-slate-700">
          {project.statuspro}
        </span>
      </div>
      <div className="font-inter text-slate-600 leading-relaxed line-clamp-3 mb-4 flex-grow" dangerouslySetInnerHTML={{ __html: project.description }}></div>
      {project.websiteUrl && (
        <Button
          variant="outline"
          size="sm"
          onClick={() => window.open(project.websiteUrl, '_blank')}
          leftIcon={<LinkIcon />}
          className="mt-auto"
        >
          {ACCELERATOR_PROJECTS_CONTENT.projectWebsiteButtonText}
        </Button>
      )}
    </div>
  </div>
);

interface AcceleratorProjectsSectionProps {
  acceleratorProjects: AcceleratorProject[];
}

const AcceleratorProjectsSection: React.FC<AcceleratorProjectsSectionProps> = ({ acceleratorProjects }) => {
  return (
    <section 
      id={SECTION_IDS.acceleratorProjectsPage} 
      className="py-16 md:py-24 bg-white min-h-screen"
    >
      <div className="container mx-auto px-4 sm:px-6 lg:px-8">
        <header className="mb-12 md:mb-16">
          <h1 className="font-quicksand text-4xl sm:text-5xl md:text-6xl font-bold text-slate-900">
            {ACCELERATOR_PROJECTS_CONTENT.title}
          </h1>
          <p className="mt-4 text-lg md:text-xl text-slate-700 max-w-3xl">
            {ACCELERATOR_PROJECTS_CONTENT.subtitle}
          </p>
        </header>
        
        {acceleratorProjects && acceleratorProjects.length > 0 ? (
           <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8">
            {acceleratorProjects.map((project: AcceleratorProject) => (
              <ProjectCard key={project.id} project={project} />
            ))}
          </div>
        ) : (
          <div className="text-center py-10 bg-white p-6 rounded-xl">
            <CubeTransparentIcon className="w-16 h-16 mx-auto text-slate-300 mb-4" />
            <h2 className="text-2xl font-quicksand font-semibold text-slate-700 mb-3">{ACCELERATOR_PROJECTS_CONTENT.emptyStateTitle}</h2>
            <p className="text-slate-600 font-inter">
              {ACCELERATOR_PROJECTS_CONTENT.emptyStateMessage}
            </p>
          </div>
        )}
      </div>
    </section>
  );
};

export default AcceleratorProjectsSection;