interface ProgressBarProps {
  currentStep: number
  totalSteps: number
  elapsedMinutes?: number
  estimatedTotalMinutes?: number
}

export function ProgressBar({ currentStep, totalSteps, elapsedMinutes, estimatedTotalMinutes }: ProgressBarProps) {
  const percentage = totalSteps > 0 ? Math.round((currentStep / totalSteps) * 100) : 0
  const elapsed = Math.max(0, elapsedMinutes ?? 0)

  const formatTime = (minutes: number) => {
    if (minutes < 1) return '<1m'
    if (minutes < 60) return `${minutes}m`
    const h = Math.floor(minutes / 60)
    const m = minutes % 60
    return m > 0 ? `${h}h ${m}m` : `${h}h`
  }

  return (
    <div className="space-y-1.5">
      <div className="flex items-center justify-between text-xs">
        <span className="text-muted-foreground">
          Step {currentStep} of {totalSteps}
        </span>
        <div className="flex items-center gap-3">
          {elapsedMinutes !== undefined && (
            <span className="text-muted-foreground">
              {formatTime(elapsed)}
              {estimatedTotalMinutes ? (
                <span className="text-muted-foreground"> / est. {formatTime(estimatedTotalMinutes)}</span>
              ) : null}
            </span>
          )}
          <span className="font-medium text-muted-foreground">{percentage}%</span>
        </div>
      </div>
      <div className="h-1.5 overflow-hidden rounded-full bg-accent">
        <div
          className="h-full rounded-full bg-gradient-brand transition-all duration-300"
          style={{ width: `${percentage}%` }}
        />
      </div>
    </div>
  )
}
