Atomic structure and electronic properties of folded graphene nanoribbons: A first-principles study