/**
 * WorthDoing.ai
 * Author: Simon-Pierre Boucher
 * Contact: contact@spboucher.ai
 * File: src/components/wd/ConfidenceBar.tsx
 * Description: Thin animated confidence bar — width transitions on real confidence changes.
 */
import { cn } from "@/lib/utils";

export function ConfidenceBar({
  value,
  tone = "auto",
  className,
}: {
  value: number; // 0..1
  tone?: "auto" | "verdict" | "signal" | "rust" | "tele" | "ink";
  className?: string;
}) {
  const resolved =
    tone === "auto" ? (value >= 0.65 ? "verdict" : value >= 0.4 ? "signal" : "rust") : tone;
  const toneClass: Record<string, string> = {
    verdict: "bg-verdict",
    signal: "bg-signal",
    rust: "bg-rust",
    tele: "bg-tele",
    ink: "bg-ink",
  };
  return (
    <div className={cn("h-1.5 w-full overflow-hidden rounded-full bg-line/70", className)}>
      <div
        className={cn("wd-bar h-full rounded-full", toneClass[resolved])}
        style={{ width: `${Math.round(Math.max(0, Math.min(1, value)) * 100)}%` }}
      />
    </div>
  );
}
