I changed the way i calculated the magnitudes. So now instead of selecting a single bin from the center of the sidelobes, i now just pick all bins from the desired range, as you guys suggested. So for example, when using a window, i assign the width of the main lobe as the range width of frequencies for both the fundamental and the harmonics. And in case they overlap (example: flattop window), i make sure to handle those exceptions so the bins are never counted twice, and i also make sure that the fundamental always takes priority over the harmonics.
Anyway, for me the problem became obvious when i looked at the FFT representations of the pure sine wave using different windows:
I noticed that a magnitude of about -87 dB (this is in reference to the signal peak value, so i guess the units should be dBc?) Anywayy, i noticed at -87 dB the magnitude is too small to even be noticeable when calculating THD+N with 2 decimals. The magnitude is so small you will not even get 0.01% in the final result. But if the magnitudes are higher than -87dB, then they start being big enough to sum at least 0.01% in the final result. Still super small, but they start being noticeable for the final result. So in the following images i placed the Y1 cursor at about -87dB, for reference.

If you take a look at image number 1, that is the FFT representation of a pure sine wave, using a Rectangular window (no-window). So all the FFT section marked in green is the harmonics+noise higher than -87dB. In fact, the highest sidelobe is -12.16 dB. All that portion of the signal is counted as THD+N, and that's the reason the calculated THD/THD+N values are so high.

Image number 2, same pure sine wave, now using a Hann window. As you can see, the magnitudes of the part of the FFT counted as THD/THD+N are now much smaller, and now the highest sidelobe is only -31.41 dB. Much smaller magnitudes, but there is still a portion over -87dB, which makes the zone in green to be noticeable for the THD/THD+N calculation. The THD/THD+N results are much smaller, but still high for a pure sine wave, which should be zero.

Image number 3, same pure sine wave, using a Blackman window. Highest sidelobe is now way lower, only -56.85 dB. However, the part of the FFT higher than -87dB is still big enough to be noticeable in the THD/THD+N calculations. The calculation results are now near zero, but still not zero.

Image number 4, same pure sine wave, using a Blackman-Harris window (Other windows like Nuttall also give similar results as Blackman-Harris). Now the highest sidelobe is -90 dB. So all the non-fundamental FFT magnitudes are now so small that they don't make even 0.01% in the THD/THD+N calculations. So the results are now 0.00%, as expected.

And to check if it's working properly, i added just a bit of noise to the pure sine wave, and i was welcomed with a proper randomized and everchanging noise floor, with the consequent THD/THD+N results reflecting the presence of noise. Keep in mind that i am not (yet) accounting for the noise in the fundamental or harmonic calculations, so if there is noise contained in the harmonic frequency ranges, this noise is still being counted as "harmonic distortion". I will modify the code to account for that aswell, but for now i was only focusing on the issue i explained in this post.
Ok, so after explaining all of my experiments, my question is: Is it ok to use a Blackman-Harris window? I ask because my understanding prior to this was that the Hann window was widely used for calculating THD/THD+N, but they must have some compensation algorithm implemented in their formulas, because the magnitudes of the FFT are always there unless you use a window with big suppression, like Blackman-Harris or Nuttall.
The problem with using a window with a wide main lobe like Blackman-Harris is that, if the main lobe frequency range (width) is higher than the frequency of the fundamental, then the fundamental and harmonic ranges will overlap. And this means that all existing bins will be used to calculate the fundamental and harmonics, leaving no bins left for calculating the noise.
And if i can't calculate the noise, then i cannot account for it, because it will always be calculated as "zero".
So if the fundamental frequency is 1KHz, then i need a window with a main lobe frequency range lower than 1KHz. Because a main lobe with a width of 1KHz will extend to -0.5KHz and +0.5KHz from the fundamental frequency, and the same will happen with the harmonic lobes, so for the first harmonic (2KHz) both the fundamental and harmonic lobes will meet at 1.5KHz, and this will extend for all the harmonics, leaving no bins left to calculate the noise.