Literally is a commonly used intensifier in modern English. Obstinate prescriptivist pedants who disagree can be found in no small number, but they are, for the most part, merely cranky grammar cultists who would prefer the language stagnate and calcify. They are best ignored.
Nuts is commonly used as a synonym for 'crazy', however it is generally used in a colloquial sense - use of the term for people who are clinically mentally ill fell out of fashion several decades ago. It does not under any circumstance mean stupid, however.
Thus, 'literally nuts' is a correct usage if you mean to say, 'very crazy'.
Doing so to refer to a person who is actually mentally ill, would generally be considered rude or offensive however.