Antikaon production and medium effects in relativistic heavy-ion collisions