import { cn } from "./ui";

export default function ProgressTracker({
  steps,
  current,
}: {
  steps: { key: string; label: string }[];
  current: number;
}) {
  return (
    <div className="w-full">
      <div className="flex items-center gap-1.5">
        {steps.map((s, i) => (
          <div
            key={s.key}
            className={cn(
              "flex-1 h-1.5 rounded-full transition-colors",
              i <= current ? "bg-accent-700" : "bg-background-300",
            )}
          />
        ))}
      </div>
      <div className="flex items-start gap-1 mt-2.5">
        {steps.map((s, i) => (
          <div key={s.key} className="flex-1 flex flex-col items-center gap-1">
            <div
              className={cn(
                "w-5 h-5 rounded-full flex items-center justify-center",
                i <= current ? "bg-accent-700" : "bg-background-300",
              )}
            >
              {i < current ? (
                <i className="ri-check-line text-[11px] text-background-50 leading-none" />
              ) : (
                <span
                  className={cn(
                    "w-1.5 h-1.5 rounded-full",
                    i === current ? "bg-background-50" : "bg-background-100",
                  )}
                />
              )}
            </div>
            <span
              className={cn(
                "text-[12px] text-center leading-[1.2] px-0.5",
                i <= current ? "text-foreground-950 font-semibold" : "text-foreground-500",
              )}
            >
              {s.label}
            </span>
          </div>
        ))}
      </div>
    </div>
  );
}