"use client";

import { AlertTriangle, CheckCircle2, HelpCircle } from "lucide-react";
import { Badge } from "@/components/ui/badge";

type Props = {
  drift: boolean;
  // When false, Coolify was unreachable: drift state is unknown, not "synced".
  coolifyAvailable?: boolean;
};

export function DriftBadge({ drift, coolifyAvailable = true }: Props) {
  if (!coolifyAvailable) {
    return (
      <Badge
        variant="outline"
        className="text-ink-muted border-rule gap-1"
        title="Coolify לא זמין — מצב ה-drift לא ידוע"
      >
        <HelpCircle className="w-3 h-3" />
        Unknown
      </Badge>
    );
  }
  if (drift) {
    return (
      <Badge variant="outline" className="text-warn border-warn/40 gap-1">
        <AlertTriangle className="w-3 h-3" />
        Drift
      </Badge>
    );
  }
  return (
    <Badge variant="outline" className="text-success border-success/40 gap-1">
      <CheckCircle2 className="w-3 h-3" />
      Synced
    </Badge>
  );
}
