"use client";

import { Euro } from "lucide-react";
import { OriginalContractData } from "@/types/amendments";

interface AmendmentRemunerationFormProps {
  originalData: OriginalContractData;
  data: any;
  onChange: (data: any) => void;
}

export default function AmendmentRemunerationForm({
  originalData,
  data,
  onChange,
}: AmendmentRemunerationFormProps) {
  const formatCurrency = (amount?: number) => {
    if (!amount) return "-";
    return new Intl.NumberFormat("fr-FR", {
      style: "currency",
      currency: "EUR",
    }).format(amount);
  };

  return (
    <div className="bg-green-50/50 rounded-lg p-4 border border-green-200 space-y-4">
      <h3 className="font-medium text-slate-900 text-sm">Modification de la rémunération</h3>

      {/* Type de salaire */}
      <div>
        <label className="block text-xs font-medium text-slate-700 mb-2">
          Type de salaire
        </label>
        <div className="text-xs text-slate-500 mb-2">
          Actuellement : {originalData.type_salaire || "Brut"}
        </div>
        <select
          value={data.type_salaire || "Brut"}
          onChange={(e) =>
            onChange({
              ...data,
              type_salaire: e.target.value as any,
            })
          }
          className="w-full px-3 py-2 border rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500"
        >
          <option value="Brut">Brut</option>
          <option value="Net avant PAS">Net avant PAS</option>
          <option value="Coût total employeur">Coût total employeur</option>
          <option value="Minimum conventionnel">Minimum conventionnel</option>
        </select>
      </div>

      {/* Montant du salaire */}
      <div>
        <label className="block text-xs font-medium text-slate-700 mb-2">
          Montant du salaire
        </label>
        <div className="text-xs text-slate-500 mb-2">
          Actuellement : {formatCurrency(originalData.gross_pay)}
        </div>
        <div className="relative">
          <Euro className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400" />
          <input
            type="number"
            min="0"
            step="0.01"
            value={data.gross_pay}
            onChange={(e) =>
              onChange({
                ...data,
                gross_pay: e.target.value ? Number(e.target.value) : "",
              })
            }
            placeholder="0.00"
            className="w-full pl-10 pr-4 py-2 border rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500"
          />
        </div>
      </div>

      {/* Précisions salaire */}
      <div>
        <label className="block text-xs font-medium text-slate-700 mb-2">
          Précisions sur le salaire
        </label>
        <div className="text-xs text-slate-500 mb-2">
          Actuellement : {originalData.precisions_salaire || "-"}
        </div>
        <textarea
          value={data.precisions_salaire || ""}
          onChange={(e) =>
            onChange({
              ...data,
              precisions_salaire: e.target.value,
            })
          }
          placeholder="Détails ou précisions complémentaires..."
          rows={3}
          className="w-full px-3 py-2 border rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 resize-none"
        />
      </div>
    </div>
  );
}
