import Link from "next/link";

type TwilioReadinessPanelProps = {
  variant?: "workspace" | "admin" | "quote";
};

const VARIANTS = {
  workspace: {
    eyebrow: "Dispatch Spot Voice admin readiness",
    title: "Twilio service configuration foundation",
    subtitle: "Prepare the workspace for browser calling, caller ID governance, transcript assist policy, and future Twilio token activation without exposing live secrets in the operator workflow.",
    badges: [
      { label: "Caller ID policy", value: "Needs review" },
      { label: "Transcript assist policy", value: "Ready for rule set" },
      { label: "Workspace training", value: "Dispatcher admin setup" },
    ],
    bullets: [
      "Choose the outbound caller identity that should represent the carrier.",
      "Decide whether transcript assist can be enabled by dispatchers or only by admins.",
      "Prepare consent language and a team training note before live voice activation.",
    ],
    links: [
      { href: "/cori/quotes", label: "Open CORI’s Quotes" },
      { href: "/workspaces", label: "Open workspace administration" },
      { href: "/profile", label: "Review profile & security" },
    ],
  },
  admin: {
    eyebrow: "Platform readiness",
    title: "Twilio platform configuration foundation",
    subtitle: "Keep the future Twilio activation surface isolated in the admin control plane so platform credentials, environment mapping, and workspace rollout policy remain separate from day-to-day operations.",
    badges: [
      { label: "Environment mapping", value: "Foundation ready" },
      { label: "Workspace rollout", value: "Per-workspace enablement" },
      { label: "Credential isolation", value: "Admin shell only" },
    ],
    bullets: [
      "Reserve Twilio Account SID, API key, and caller pool controls for the admin shell.",
      "Decide which workspaces can activate browser dialer mode first.",
      "Keep token issuance, number management, and transcript services out of the normal operator shell.",
    ],
    links: [
      { href: "/admin/workspaces", label: "Stay in workspace provisioning" },
      { href: "/admin/profile", label: "Open admin profile" },
      { href: "/cori/quotes", label: "Review CORI’s Quotes" },
    ],
  },
  quote: {
    eyebrow: "Voice service readiness",
    title: "Twilio configuration readiness",
    subtitle: "This quote and dialer workspace is now prepared for later Twilio browser-calling activation, but live service configuration should still be completed by workspace admins and platform admins before rollout.",
    badges: [
      { label: "Workspace policy", value: "Admin review needed" },
      { label: "Token service", value: "Not wired yet" },
      { label: "Browser dialer UX", value: "Foundation active" },
    ],
    bullets: [
      "Use the browser dialer foundation here for workflow validation before live Twilio wiring.",
      "Complete caller ID, consent, and transcript-assist policy in workspace administration.",
      "Keep platform credential and Twilio environment controls in the separate admin surface.",
    ],
    links: [
      { href: "/company", label: "Open workspace settings" },
      { href: "/workspaces", label: "Open workspace administration" },
      { href: "/admin/workspaces", label: "Admin rollout surface" },
    ],
  },
} as const;

export function TwilioReadinessPanel({ variant = "workspace" }: TwilioReadinessPanelProps) {
  const config = VARIANTS[variant];
  return (
    <section className="rounded-[28px] border border-slate-200 bg-white p-5 shadow-sm">
      <div className="flex items-start justify-between gap-3">
        <div>
          <div className="text-xs font-semibold uppercase tracking-wide text-slate-500">{config.eyebrow}</div>
          <div className="mt-2 text-lg font-semibold text-slate-950">{config.title}</div>
          <div className="mt-1 text-sm text-slate-500">{config.subtitle}</div>
        </div>
        <span className="inline-flex rounded-full bg-violet-50 px-3 py-1.5 text-xs font-semibold text-violet-700">Foundation</span>
      </div>
      <div className="mt-4 grid gap-4 xl:grid-cols-[1.1fr_0.9fr]">
        <div>
          <div className="grid gap-3 sm:grid-cols-3">
            {config.badges.map((item) => (
              <div key={item.label} className="rounded-2xl border border-slate-200 bg-slate-50 p-4">
                <div className="text-xs font-semibold uppercase tracking-wide text-slate-500">{item.label}</div>
                <div className="mt-2 text-sm font-semibold text-slate-900">{item.value}</div>
              </div>
            ))}
          </div>
          <ul className="mt-4 space-y-2 text-sm text-slate-600">
            {config.bullets.map((item) => (
              <li key={item}>• {item}</li>
            ))}
          </ul>
        </div>
        <div className="rounded-2xl border border-slate-200 bg-slate-50 p-4">
          <div className="text-xs font-semibold uppercase tracking-wide text-slate-500">Admin readiness controls</div>
          <div className="mt-3 flex flex-wrap gap-2">
            {config.links.map((link) => (
              <Link key={link.href + link.label} href={link.href} className="rounded-xl border border-slate-200 bg-white px-3 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50">
                {link.label}
              </Link>
            ))}
          </div>
          <div className="mt-4 rounded-2xl border border-dashed border-slate-200 bg-white px-4 py-4 text-sm text-slate-600">
            Twilio live calling, token issuance, transcript channels, and caller-number governance should be activated in stages. This foundation keeps the readiness controls visible before real service wiring is introduced.
          </div>
        </div>
      </div>
    </section>
  );
}
