"use client";

import { Check, X } from "lucide-react";
import type { PasswordChecks } from "../hooks/usePasswordValidation";

interface RequirementCheckProps {
  met: boolean;
  label: string;
}

function RequirementCheck({ met, label }: RequirementCheckProps) {
  return (
    <div className="flex items-center gap-1">
      {met ? (
        <Check className="h-3 w-3 text-success" />
      ) : (
        <X className="h-3 w-3 text-muted-foreground" />
      )}
      <span className={met ? "text-success" : "text-muted-foreground"}>{label}</span>
    </div>
  );
}

interface PasswordRequirementsProps {
  checks: PasswordChecks;
  showHint?: boolean | undefined;
}

export function PasswordRequirements({ checks, showHint = false }: PasswordRequirementsProps) {
  if (showHint) {
    return (
      <p className="text-xs text-muted-foreground">
        At least 8 characters with uppercase, lowercase, and numbers
      </p>
    );
  }

  return (
    <div className="grid grid-cols-2 gap-1 text-xs">
      <RequirementCheck met={checks.minLength} label="8+ characters" />
      <RequirementCheck met={checks.hasUppercase} label="Uppercase letter" />
      <RequirementCheck met={checks.hasLowercase} label="Lowercase letter" />
      <RequirementCheck met={checks.hasNumber} label="Number" />
    </div>
  );
}
