Unexpected imaginary part in the fft of a zero-padded cosine
A signal that's discrete in frequency is periodic in time. By using an FFT you inherently make this assumption and the FFT calculates the spectrum of a signal that's infinitely repeated in time.
The FFT is ONLY real valued if the time domain signal has even symmetry, i.e. $x(-t) = x(t)$. For a discrete periodic signal of period N this becomes $x[n] = x[N-n]$. That holds true for a pure cosine (at least for some frequencies), but not for the zero padded version.