Entanglement and thermal entropy of gauge fields