"use client"

import { ticketStatusSchema, type TicketStatus } from "@/lib/schemas/ticket"
import { Badge } from "@/components/ui/badge"
import { cn } from "@/lib/utils"

const statusStyles: Record<TicketStatus, { label: string; className: string }> = {
  NEW: { label: "Novo", className: "border border-slate-200 bg-slate-100 text-slate-700" },
  OPEN: { label: "Aberto", className: "border border-slate-200 bg-[#dff1fb] text-[#0a4760]" },
  PENDING: { label: "Pendente", className: "border border-slate-200 bg-[#fdebd6] text-[#7b4107]" },
  ON_HOLD: { label: "Em espera", className: "border border-slate-200 bg-[#ede8ff] text-[#4f2f96]" },
  RESOLVED: { label: "Resolvido", className: "border border-slate-200 bg-[#dcf4eb] text-[#1f6a45]" },
  CLOSED: { label: "Fechado", className: "border border-slate-200 bg-slate-200 text-slate-700" },
}

type TicketStatusBadgeProps = { status: TicketStatus }

export function TicketStatusBadge({ status }: TicketStatusBadgeProps) {
  const parsed = ticketStatusSchema.parse(status)
  const styles = statusStyles[parsed]
  return (
    <Badge className={cn('inline-flex items-center rounded-full px-3 py-0.5 text-xs font-semibold', styles?.className)}>
      {styles?.label ?? parsed}
    </Badge>
  )
}
