  In this paper we prove a sub-Riemannian version of the classical Santal\'o
formula: a result in integral geometry that describes the intrinsic Liouville
measure on the unit cotangent bundle in terms of the geodesic flow. Our
construction works under quite general assumptions, satisfied by any
sub-Riemannian structure associated with a Riemannian foliation with totally
geodesic leaves (e.g. CR and QC manifolds with symmetries), any Carnot group,
and some non-equiregular structures such as the Martinet one. A key ingredient
is a "reduction procedure" that allows to consider only a simple subset of
sub-Riemannian geodesics.
  As an application, we derive isoperimetric-type and (p-)Hardy-type
inequalities for a compact domain $M$ with piecewise $C^{1,1}$ boundary, and a
universal lower bound for the first Dirichlet eigenvalue $\lambda_1(M)$ of the
sub-Laplacian, \[ \lambda_1(M) \geq \frac{k \pi^2}{L^2}, \] in terms of the
rank $k$ of the distribution and the length $L$ of the longest reduced
sub-Riemannian geodesic contained in $M$. All our results are sharp for the
sub-Riemannian structures on the hemispheres of the complex and quaternionic
Hopf fibrations: \[ \mathbb{S}^1\hookrightarrow \mathbb{S}^{2d+1}
\xrightarrow{p} \mathbb{CP}^d, \qquad \mathbb{S}^3\hookrightarrow
\mathbb{S}^{4d+3} \xrightarrow{p} \mathbb{HP}^d, \qquad d \geq 1, \] where the
sub-Laplacian is the standard hypoelliptic operator of CR and QC geometries, $L
= \pi$ and $k=2d$ or $4d$, respectively.
