Statistical Mechanics of jamming and segregation in granular media