Thermodynamics of type II superconductors in electromagnetic field based on the Ginzburg-Landau theory is presented. The Abrikosov flux lattice solution is derived using an expansion in a parameter characterizing the "distance" to the superconductor-normal phase transition line. The expansion allows a systematic improvement of the solution. The phase diagram of the vortex matter in magnetic field is determined in detail. In the presence of significant thermal fluctuations on the mesoscopic scale (for example, in high Tc materials) the vortex crystal melts into a vortex liquid. A quantitative theory of thermal fluctuations using the lowest Landau level approximation is given. It allows one to determine the melting line and discontinuities at melt, as well as important characteristics of the vortex liquid state. In the presence of quenched disorder (pinning) the vortex matter acquires certain "glassy" properties. The irreversibility line and static properties of the vortex glass state are studied using the "replica" method. Most of the analytical methods are introduced and presented in some detail. Various quantitative and qualitative features are compared to experiments in type II superconductors, although the use of a rather universal Ginzburg-Landau theory is not restricted to superconductivity and can be applied with certain adjustments to other physical systems, for example, rotating Bose-Einstein condensate.