The Hamilton-Type Principle in Fluid Dynamics: Fundamentals and Applications to Magnetohydrodynamics, Thermodynamics, and Astrophysics