Hi Gianluca, the quick answer to your question about maximum GIF file size is 3MB.
Glad to explain this a bit further. The media/upload endpoint is used to upload media to our servers independently of how it will eventually be used and is always a 5MB file size limit.
Further limits apply in how your uploaded media is used. As you mentioned, one way is to attach it to a Tweet and that limit (for images including GIFs) is 3MB. If you were using the media upload for your profile image, the limit is 700KB. You can even use the media/upload endpoint to update your profile header image.
Hopefully that helps to explain other uses of the endpoint and why other limits exist.