Let $$\mathbb T=\{z\in \mathbb C: z=e^{i x}$$ for some real $$x \}$$, then $$L^2 (\mathbb T)$$ is a Hilbert space with the inner product $$\langle f,g\rangle=\frac 1 {2\pi}\int _0^{2\pi}f (x)\overline{g(x)} dx$$. The functions $$e_n=e^{inx}$$, $$n$$ integer, form an orthonormal basis for $$L^2 (\mathbb T)$$, and $$\langle f,e_n \rangle = \hat f (n)$$.

From here in the course we introduced the real form of Fourier transform, using $$e_n =\cos (nx) +i \sin (nx)$$ in the linear combination $$\sum\langle f,e_n \rangle e_n$$, and since the inner products between the $$\cos nx$$ and the $$\sin mx$$ are zero, the $$\cos (nx),\sin (nx)$$ form an orthonormal basis.

So now I come to the part that is not clear: if I do $$\langle f,\cos (nx) \rangle + \langle f,\cos (-nx) \rangle =$$ $$=2\langle f,\cos (nx) \rangle$$ (since the cosine is even) I obtain the same result as doing the calculations described in the paragraph above; however the sine is odd so $$\langle f,\sin (nx) \rangle + \langle f,\sin (-nx) \rangle =0$$, that clearly is different from the coefficient of $$\sin (nx)$$ that one finds proceeding as above. I just can't find the mistake, thank you in advance.

Consider $$f:\mathbb{T}\to\mathbb{C}$$ with $$f\in L^2(\Bbb{T})$$.
For the basis $$(e^{inx})_{n\in\Bbb{Z}}$$, $$\hat{f}(n)=\frac{1}{2\pi}\int_0^{2\pi}f(x)e^{inx}\,dx.$$
If one considers the real basis $$\{\sin (x), \sin (2x), \cdots, \}\cup\{1,\cos(x),\cos(2x),\cdots\}$$, then $$\langle f(x), \cos(nx)\rangle=\langle f(x),\frac{e^{inx}+e^{-inx}}{2}\rangle =\frac{1}{2}\big( \hat{f}(n)+\hat{f}(-n) \big)$$ and $$\langle f(x), \sin(nx)\rangle=\langle f(x),\frac{e^{inx}-e^{-inx}}{2i}\rangle =\frac{1}{2i}\big( \hat{f}(n)+\hat{f}(-n) \big).$$