async function getWeather() { const location = document.getElementById("locationInput").value.trim(); const resultDiv = document.getElementById("weatherResult"); if (!location) { resultDiv.innerHTML = `

Please enter a location.

`; return; } const apiKey = "f1a0aa2e08cd47d3a6862520252007"; const url = `http://api.weatherapi.com/v1/current.json?key=${apiKey}&q=${location}&aqi=yes`; try { resultDiv.innerHTML = `

Loading...

`; resultDiv.classList.remove("show"); const response = await fetch(url); if (!response.ok) throw new Error("Location not found"); const data = await response.json(); resultDiv.innerHTML = `

${data.location.name}, ${data.location.country}

${data.current.temp_c}°C

${data.current.condition.text}

Weather icon `; setTimeout(() => resultDiv.classList.add("show"), 50); // smooth fade-in } catch (error) { resultDiv.innerHTML = `

${error.message}

`; } }