A young Afghan national followed a teenager into a leisure centre toilet and tried to kiss her, a court has heard.