Russia didn't lose to Afghanistan, rather Russia, Ukraine and Belarus dismantled the Soviet era occupation force. In fact the pro-Soviet government of Afghanistan lasted 3 more years on its own - unlike the US installed government which collapsed before US troops left.