import { CheckCircleIcon } from "@heroicons/react/24/outline";

interface Step {
  number: number;
  title: string;
  completed: boolean;
}

interface ProgressStepsProps {
  steps: Step[];
  currentStep?: number; // Optional for step-based navigation
  className?: string;
}

export function ProgressSteps({ steps, currentStep, className = "" }: ProgressStepsProps) {
  return (
    <div className={`mb-8 ${className}`}>
      <div className="bg-white p-6 rounded-xl shadow-sm border border-gray-200">
        <div className="overflow-x-auto">
          <div className="flex items-center justify-center space-x-3 md:space-x-4 min-w-max px-2">
            {steps.map((step, index) => (
              <div key={step.number} className="flex items-center flex-shrink-0">
                <div className="flex flex-col items-center gap-2">
                  <div
                    className={`relative flex items-center justify-center w-10 h-10 md:w-12 md:h-12 rounded-full border-2 transition-all duration-200 ease-out ${
                      step.completed
                        ? "bg-green-500 border-green-500 text-white"
                        : currentStep === step.number
                          ? "border-blue-500 text-blue-600 bg-blue-50"
                          : "border-gray-300 text-gray-400 bg-white"
                    }`}
                  >
                    {step.completed ? (
                      <CheckCircleIcon className="w-6 h-6 md:w-7 md:h-7 transition-all duration-150" />
                    ) : (
                      <span className="font-bold text-sm md:text-base transition-all duration-150">
                        {step.number}
                      </span>
                    )}
                  </div>
                  <span
                    className={`text-xs md:text-sm font-medium text-center transition-all duration-150 max-w-[80px] md:max-w-none ${
                      step.completed
                        ? "text-green-600"
                        : currentStep === step.number
                          ? "text-blue-600"
                          : "text-gray-500"
                    }`}
                  >
                    {step.title}
                  </span>
                </div>
                {index < steps.length - 1 && (
                  <div className="relative w-10 md:w-16 h-[2px] mx-2 md:mx-4 flex-shrink-0">
                    <div className="absolute inset-0 bg-gray-200 rounded-full" />
                    <div
                      className={`absolute inset-0 rounded-full transition-all duration-300 ease-out ${
                        step.completed ? "bg-green-500" : "bg-gray-200"
                      }`}
                      style={{
                        transform: step.completed ? "scaleX(1)" : "scaleX(0)",
                        transformOrigin: "left",
                      }}
                    />
                  </div>
                )}
              </div>
            ))}
          </div>
        </div>
      </div>
    </div>
  );
}

export type { ProgressStepsProps, Step };
