import Link from "next/link";

type DispatchFirstPolishAction = {
  label: string;
  count: number;
  detail: string;
  href: string;
  cta: string;
  tone: "urgent" | "watch" | "calm";
};

const toneClasses: Record<DispatchFirstPolishAction["tone"], string> = {
  urgent: "border-red-200 bg-red-50 text-red-700",
  watch: "border-amber-200 bg-amber-50 text-amber-700",
  calm: "border-emerald-200 bg-emerald-50 text-emerald-700",
};

export function DispatchFirstPolishPanel({
  actions,
  summary,
}: {
  actions: DispatchFirstPolishAction[];
  summary: string[];
}) {
  return (
    <section className="rounded-2xl border bg-white p-4 shadow-sm">
      <div className="flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between">
        <div>
          <div className="text-sm font-semibold text-gray-900">Dispatch-first launch rail</div>
          <div className="text-xs text-gray-500">Keep the first three operator moves obvious before dropping into the full board and support surfaces.</div>
        </div>
        <div className="flex flex-wrap gap-2">
          {summary.map((item) => (
            <span key={item} className="rounded-full bg-gray-100 px-2.5 py-1 text-xs font-medium text-gray-700">{item}</span>
          ))}
        </div>
      </div>
      <div className="mt-4 grid gap-3 xl:grid-cols-3">
        {actions.map((action, index) => (
          <div key={action.label} className="rounded-xl border p-4">
            <div className="flex items-start justify-between gap-3">
              <div>
                <div className="text-[11px] font-semibold uppercase tracking-wide text-gray-500">{index === 0 ? "Now" : index === 1 ? "Next" : "Then"}</div>
                <div className="mt-1 text-sm font-semibold text-gray-900">{action.label}</div>
              </div>
              <div className={`rounded-full border px-2.5 py-1 text-xs font-semibold ${toneClasses[action.tone]}`}>{action.count}</div>
            </div>
            <div className="mt-3 text-xs text-gray-600">{action.detail}</div>
            <div className="mt-4">
              <Link href={action.href} className="inline-flex items-center rounded-full border bg-white px-3 py-1.5 text-xs font-medium text-gray-700">
                {action.cta}
              </Link>
            </div>
          </div>
        ))}
      </div>
    </section>
  );
}
