import React from 'react';
import { ArrowDown, ArrowRight, ArrowUp } from 'lucide-react';

const DegradomeSequencingPipeline = ({
  title = "Degradome Sequencing",
  backgroundColor = "bg-gray-50",
  cardColor = "bg-blue-200",
  textColor = "text-gray-800",
  arrowColor = "text-gray-600",
  className = "",
  cardClassName = "",
  titleClassName = ""
}) => {
  const leftSteps = [
    "Raw Sequencing Data (fastq files)",
    "Quality Control and Preprocessing of Data", 
    "High Quality Sequencing Data (fastq file)",
    "Alignment to Reference Genome"
  ];

  const rightSteps = [
    "Related miRNA Identification",
    "mRNAs Degradome Sites",
    "Identify Target mRNAs",
    "Retain mRNA data Remove rRNA, tRNA and other RNA"
  ];

  const middleSteps = [
    "Functional Analysis"
  ];

  return (
    <section className={`py-6 sm:py-8 lg:py-12 ${backgroundColor} ${className}`}>
      <div className="container mx-auto max-w-none px-3 sm:px-4 lg:px-6">
        <h2 className={`text-gray-700 text-left pb-4 sm:pb-6 text-xl sm:text-2xl lg:text-3xl font-normal ${titleClassName}`}>
          {title}
        </h2>

        {/* Pipeline Flowchart */}
        <div className="bg-white rounded-xl shadow-lg p-4 sm:p-6 lg:p-8">
          <div className="flex justify-center">
            <div className="w-full max-w-6xl">
              <div className="relative">
                {/* Mobile Layout - Single Column */}
                <div className="block lg:hidden">
                  <div className="flex flex-col items-center space-y-3">
                    {[...leftSteps, ...rightSteps.slice().reverse(), ...middleSteps].map((step, index) => (
                      <React.Fragment key={index}>
                        <div className={`${cardColor} rounded-lg p-3 w-full text-center border ${cardClassName}`}>
                          <h3 className={`text-xs font-medium ${textColor}`}>{step}</h3>
                        </div>
                        {index < leftSteps.length + rightSteps.length + middleSteps.length - 1 && (
                          <ArrowDown className={`w-5 h-5 ${arrowColor}`} />
                        )}
                      </React.Fragment>
                    ))}
                  </div>
                </div>

                {/* Desktop Layout - Complex Flow */}
                <div className="hidden lg:block">
                  <div className="grid grid-cols-3 gap-6 lg:gap-8">
                    {/* Left Column */}
                    <div className="flex flex-col items-center space-y-3">
                      {leftSteps.map((step, index) => (
                        <React.Fragment key={index}>
                          <div className={`${cardColor} rounded-lg p-4 w-full max-w-80 text-center border ${cardClassName}`}>
                            <h3 className={`text-sm font-medium ${textColor}`}>{step}</h3>
                          </div>
                          {index < leftSteps.length - 1 && (
                            <ArrowDown className={`w-6 h-6 ${arrowColor}`} />
                          )}
                        </React.Fragment>
                      ))}
                    </div>

                    {/* Middle Column */}
                    <div className="flex flex-col items-center justify-center space-y-3">
                      {middleSteps.map((step, index) => (
                        <div key={index} className={`${cardColor} rounded-lg p-4 w-full max-w-60 text-center border ${cardClassName}`}>
                          <h3 className={`text-sm font-medium ${textColor}`}>{step}</h3>
                        </div>
                      ))}
                    </div>

                    {/* Right Column */}
                    <div className="flex flex-col items-center space-y-3">
                      {rightSteps.map((step, index) => (
                        <React.Fragment key={index}>
                          <div className={`${cardColor} rounded-lg p-4 w-full max-w-80 text-center border ${cardClassName}`}>
                            <h3 className={`text-sm font-medium ${textColor}`}>{step}</h3>
                          </div>
                          {index < rightSteps.length - 1 && (
                            <ArrowUp className={`w-6 h-6 ${arrowColor}`} />
                          )}
                        </React.Fragment>
                      ))}
                    </div>
                  </div>

                  {/* Horizontal Arrow from left to right (after alignment) */}
                  <div className="absolute bottom-4 left-1/3 transform -translate-x-1/2 flex items-center justify-center">
                    <ArrowRight className={`w-8 h-8 ${arrowColor}`} />
                  </div>

                  {/* Bidirectional arrows between middle and right columns */}
                  <div className="absolute top-1/2 right-1/3 transform translate-x-1/2 -translate-y-1/2 flex flex-col items-center space-y-2">
                    <ArrowUp className={`w-6 h-6 ${arrowColor}`} />
                    <ArrowDown className={`w-6 h-6 ${arrowColor}`} />
                  </div>

                  {/* Additional arrows for the circular flow in right column */}
                  <div className="absolute top-1/4 right-6 flex items-center justify-center">
                    <ArrowUp className={`w-5 h-5 ${arrowColor}`} />
                  </div>
                  
                  <div className="absolute top-2/3 right-6 flex items-center justify-center">
                    <ArrowUp className={`w-5 h-5 ${arrowColor}`} />
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
};

export default DegradomeSequencingPipeline;