Deductions & credits

Thanks for the answer to my question last year.  I am now doing my 2021 taxes and have similar issues.  If I sold the foreign company stock on a US stock exchange, and had a gain, then it sounds like the gain would not be foreign source income.  However, if I was paid a dividend on that stock before I sold it, and the foreign country withheld taxes on that dividend, please confirm that the dividend is foreign source income and the taxes withheld can be used for a foreign tax credit.

One further question, if the dividend was a qualified dividend, and my taxable income is less than $80,800 so that qualified dividends are taxed at 0%, can I still use the foreign dividend as foreign source income?  Is there an IRS publication that explains the answer to this question?