function EditInventoryModal({ currentUser, doctors, editingInventory, handleEditInventorySubmit, lang, renderCategoryField, setEditingInventory, setShowEditInventory, strings }) {
    return (
        <>
        <div className="fixed inset-0 bg-brand-harbor/60 backdrop-blur-md z-50 flex items-center justify-center p-4">
            <div className="bg-white border border-brand-dune/80 rounded-3xl max-w-lg w-full p-8 shadow-2xl text-brand-harbor max-h-[90vh] overflow-y-auto">
                <div className="flex items-center justify-between mb-6">
                    <h3 className="text-xl font-bold text-brand-harbor">{strings.editInventory}</h3>
                    <button type="button" onClick={() => { setShowEditInventory(false); setEditingInventory(null); }} className="w-8 h-8 rounded-full bg-brand-linen hover:bg-brand-dune/40 flex items-center justify-center text-brand-steel">✕</button>
                </div>
                <form onSubmit={handleEditInventorySubmit} className="space-y-4">
                    <div>
                        <label className="block text-xs font-bold uppercase text-brand-steel mb-1.5">{strings.itemName}</label>
                        <input type="text" required value={editingInventory.name || ''} onChange={e => setEditingInventory({...editingInventory, name: e.target.value})} className="w-full px-4 py-3 rounded-2xl bg-brand-linen/50 border border-brand-dune text-brand-harbor text-sm font-medium focus:outline-none focus:ring-2 focus:ring-brand-sky focus:bg-white" />
                    </div>
                    <div className="grid grid-cols-2 gap-4">
                        {renderCategoryField(editingInventory.category || '', v => setEditingInventory({...editingInventory, category: v}))}
                        <div>
                            <label className="block text-xs font-bold uppercase text-brand-steel mb-1.5">{strings.batchNo}</label>
                            <input type="text" required value={editingInventory.batch || ''} onChange={e => setEditingInventory({...editingInventory, batch: e.target.value})} className="w-full px-4 py-3 rounded-2xl bg-brand-linen/50 border border-brand-dune text-brand-harbor text-sm font-medium focus:outline-none focus:ring-2 focus:ring-brand-sky focus:bg-white" />
                        </div>
                    </div>
                    <div className="grid grid-cols-2 gap-4">
                        <div>
                            <label className="block text-xs font-bold uppercase text-brand-steel mb-1.5">{lang === 'ar' ? 'الكمية الحالية' : 'Stock Qty'}</label>
                            <input type="number" min="0" required value={editingInventory.stock ?? ''} onChange={e => setEditingInventory({...editingInventory, stock: e.target.value})} className="w-full px-4 py-3 rounded-2xl bg-brand-linen/50 border border-brand-dune text-brand-harbor text-sm font-medium focus:outline-none focus:ring-2 focus:ring-brand-sky focus:bg-white" />
                        </div>
                        <div>
                            <label className="block text-xs font-bold uppercase text-brand-steel mb-1.5">{lang === 'ar' ? 'حد تنبيه النقص' : 'Minimum Alert Qty'}</label>
                            <input type="number" min="0" required value={editingInventory.minStock ?? ''} onChange={e => setEditingInventory({...editingInventory, minStock: e.target.value})} className="w-full px-4 py-3 rounded-2xl bg-brand-linen/50 border border-brand-dune text-brand-harbor text-sm font-medium focus:outline-none focus:ring-2 focus:ring-brand-sky focus:bg-white" />
                        </div>
                    </div>
                    <div className="grid grid-cols-2 gap-4">
                        <div>
                            <label className="block text-xs font-bold uppercase text-brand-steel mb-1.5">{strings.expiryDate}</label>
                            <input type="date" required value={editingInventory.expiryDate || ''} onChange={e => setEditingInventory({...editingInventory, expiryDate: e.target.value})} className="w-full px-4 py-3 rounded-2xl bg-brand-linen/50 border border-brand-dune text-brand-harbor text-sm font-medium focus:outline-none focus:ring-2 focus:ring-brand-sky focus:bg-white" />
                        </div>
                        <div>
                            <label className="block text-xs font-bold uppercase text-brand-steel mb-1.5">{strings.inventoryScope}</label>
                            <select value={editingInventory.doctorId} onChange={e => setEditingInventory({...editingInventory, doctorId: e.target.value})} className="w-full px-4 py-3 rounded-2xl bg-brand-linen/50 border border-brand-dune text-brand-harbor text-sm font-medium focus:outline-none focus:ring-2 focus:ring-brand-sky focus:bg-white">
                                {(() => {
                                    const opts = [];
                                    if (currentUser.isAdmin) {
                                        opts.push({ v: 'all', l: strings.generalClinicInventory });
                                        doctors.forEach(d => opts.push({ v: d.id, l: d.name }));
                                    } else {
                                        opts.push({ v: currentUser.id, l: `${strings.myDoctorInventory} (${currentUser.name})` });
                                        if (editingInventory.doctorId === 'all') opts.push({ v: 'all', l: strings.generalClinicInventory });
                                    }
                                    if (!opts.some(o => o.v === editingInventory.doctorId)) opts.push({ v: editingInventory.doctorId, l: String(editingInventory.doctorId) });
                                    return opts.map(o => <option key={o.v} value={o.v}>{o.l}</option>);
                                })()}
                            </select>
                        </div>
                    </div>
                    <div className="flex justify-end space-x-3 rtl:space-x-reverse pt-4 border-t border-brand-dune/30">
                        <button type="button" onClick={() => { setShowEditInventory(false); setEditingInventory(null); }} className="px-5 py-2.5 rounded-2xl text-sm font-semibold text-brand-steel hover:bg-brand-linen">{strings.cancel}</button>
                        <button type="submit" className="px-5 py-2.5 rounded-2xl text-sm font-bold bg-brand-harbor hover:bg-brand-sky text-white shadow-md">{lang === 'ar' ? 'حفظ التعديلات' : 'Save Changes'}</button>
                    </div>
                </form>
            </div>
        </div>
        </>
    );
}
