import type {
  CreatorIntentReadiness,
  CustomWorldPendingClarification,
} from '../../../packages/shared/src/contracts/customWorldAgent';

type CustomWorldAgentClarificationPanelProps = {
  pendingClarifications: CustomWorldPendingClarification[];
  readiness: CreatorIntentReadiness;
};

export function CustomWorldAgentClarificationPanel({
  pendingClarifications,
  readiness,
}: CustomWorldAgentClarificationPanelProps) {
  if (readiness.isReady) {
    return (
      <section className="rounded-[1.5rem] border border-emerald-300/18 bg-emerald-500/8 px-4 py-4">
        <div className="text-[11px] font-bold tracking-[0.2em] text-emerald-100/80">
          下一阶段
        </div>
        <div className="mt-2 text-lg font-semibold text-white">
          最小锚点已齐备，可以进入下一阶段
        </div>
      </section>
    );
  }

  return (
    <section className="rounded-[1.5rem] border border-white/10 bg-black/18 px-4 py-4">
      <div className="flex items-center justify-between gap-3">
        <div>
          <div className="text-[11px] font-bold tracking-[0.2em] text-zinc-400">
            待补充问题
          </div>
          <div className="mt-2 text-lg font-semibold text-white">
            先补最关键的 1 到 3 项
          </div>
        </div>
        <span className="rounded-full border border-sky-300/20 bg-sky-500/10 px-3 py-1 text-[11px] text-sky-100">
          {pendingClarifications.length}
        </span>
      </div>

      <div className="mt-4 space-y-2">
        {pendingClarifications.slice(0, 3).map((item, index) => (
          <div
            key={item.id}
            className="rounded-[1.15rem] border border-white/8 bg-white/5 px-3 py-3"
          >
            <div className="flex items-start justify-between gap-3">
              <div className="text-sm font-semibold text-white">
                {index + 1}. {item.label}
              </div>
              <div className="text-[11px] text-zinc-500">P{item.priority}</div>
            </div>
            <div className="mt-2 text-sm leading-6 text-zinc-300">
              {item.question}
            </div>
          </div>
        ))}
      </div>
    </section>
  );
}
