South Korea logs record trade deficit as tech demand falls