"use client";

import { LuX, LuSave, LuRotateCcw } from "react-icons/lu";

interface FieldsConfigModalProps {
  fields: string;
  setFields: (value: string) => void;
  onSave: () => void;
  onClose: () => void;
  onReset: () => void;
}

export default function FieldsConfigModal({ fields, setFields, onSave, onClose, onReset }: FieldsConfigModalProps) {
  return (
    <div className="fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4">
      <div className="bg-background rounded-xl shadow-2xl p-6 w-full max-w-lg animate-fade-in-up border border-border-subtle">
        <div className="flex justify-between items-start mb-4">
          <div>
            <h3 className="font-semibold text-lg text-text">Configurar Campos a Extraer</h3>
            <p className="text-sm text-text-muted mt-1">
              Define los campos que la IA buscará en los documentos, separados por comas.
            </p>
          </div>
          <button onClick={onClose} className="text-text-subtle hover:text-text cursor-pointer transition-colors">
            <LuX size={20} />
          </button>
        </div>
        <div className="space-y-4">
          <textarea
            value={fields}
            onChange={(e) => setFields(e.target.value)}
            rows={3}
            placeholder="Ej: Fecha, RNC, NCF..."
            className="w-full p-3 border border-border-subtle rounded-lg bg-background text-text focus:ring-2 focus:ring-primary focus:border-transparent transition-all"
          />
          <div className="flex flex-col-reverse sm:flex-row sm:justify-between sm:items-center gap-3">
            <button onClick={onReset} className="cursor-pointer flex items-center justify-center gap-2 text-sm text-text-muted hover:text-text font-medium transition-colors">
              <LuRotateCcw size={14} /> Restaurar por defecto
            </button>
            <div className="flex gap-3">
              <button onClick={onClose} className="cursor-pointer w-full sm:w-auto px-4 py-2 border border-border-subtle rounded-lg hover:bg-background-alt text-text font-semibold transition-colors">
                Cancelar
              </button>
              <button onClick={onSave} className="cursor-pointer w-full sm:w-auto flex items-center justify-center gap-2 px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary-hover font-semibold transition-colors">
                <LuSave size={16} /> Guardar
              </button>
            </div>
          </div>
        </div>
      </div>
    </div>
  );
}