import type { ConsultantProfile } from "@/lib/proposal/profile";
import type { AssembledProposal } from "@/lib/proposal/assemble";

type Props = {
  consultant: ConsultantProfile;
  header: AssembledProposal["header"];
  offer: AssembledProposal["offer"];
};

export function NextStepsSection({ consultant, header }: Props) {
  // Calcola la data di scadenza (validityDays dalla data di generazione)
  const expiryNote = `Valida ${header.validityDays} giorni dalla data di invio.`;

  return (
    <div className="h-full flex flex-col justify-center px-16 py-24 space-y-10">
      <div>
        <p className="text-xs font-mono tracking-widest text-muted-foreground uppercase">Come procedere ora</p>
        <h2 className="text-5xl font-light text-foreground mt-4">
          Tre passaggi <br />
          <span className="text-primary">per attivare il lavoro.</span>
        </h2>
      </div>

      <div className="space-y-4">
        {consultant.nextSteps.map((step) => (
          <div key={step.number} className="flex items-start gap-6">
            <span className="text-xl font-mono text-primary shrink-0">{step.number}</span>
            <p className="text-base text-foreground leading-relaxed">
              {step.highlightedPart ? (
                <>
                  {step.text.split(step.highlightedPart)[0]}
                  <strong>{step.highlightedPart}</strong>
                  {step.text.split(step.highlightedPart)[1]}
                </>
              ) : (
                step.text
              )}
            </p>
          </div>
        ))}
      </div>

      <div className="border-t border-border pt-6 space-y-1">
        <p className="text-sm font-medium text-foreground">
          {consultant.name} · {consultant.contact.email}
          {consultant.contact.phone ? ` · ${consultant.contact.phone}` : ""}
        </p>
        <p className="text-xs font-mono text-muted-foreground">{expiryNote}</p>
      </div>

      {/* Legale + accettazione */}
      <div className="grid grid-cols-2 gap-4 text-xs text-muted-foreground">
        <div className="border border-border rounded-lg p-4 space-y-1">
          <p className="font-mono uppercase tracking-widest text-foreground text-[10px]">Termini legali</p>
          <p>{consultant.legal.revisions}</p>
          <p>{consultant.legal.ip}</p>
          <p>{consultant.legal.nda}</p>
          <p>Foro competente: {consultant.legal.forum}</p>
        </div>
        <div className="border border-border rounded-lg p-4 space-y-1">
          <p className="font-mono uppercase tracking-widest text-foreground text-[10px]">Accettazione</p>
          <p>{consultant.legal.acceptanceInstructions}</p>
          <p className="mt-2 font-medium text-foreground">{expiryNote}</p>
        </div>
      </div>
    </div>
  );
}
