<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IP - Tracker</title>
<style>
/* Reset dasar */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}

/* Background dengan efek gradient */
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: linear-gradient(to bottom right, #1d3557, #457b9d);
}

/* Efek glassmorphism pada container */
.container {
background: rgba(255, 255, 255, 0.2);
border-radius: 15px;
backdrop-filter: blur(12px);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
padding: 30px;
width: 400px;
max-width: 90%;
text-align: center;
color: white;
transition: all 0.3s ease-in-out;
}

.container h1 {
font-size: 26px;
margin-bottom: 15px;
font-weight: bold;
animation: fadeIn 1s ease-in-out;
}

.container input {
width: calc(100% - 20px);
padding: 12px;
margin: 10px 0;
border: none;
border-radius: 10px;
font-size: 16px;
outline: none;
text-align: center;
background: rgba(255, 255, 255, 0.3);
color: white;
transition: all 0.3s ease;
}

.container input::placeholder {
color: rgba(255, 255, 255, 0.7);
}

.container button {
background: linear-gradient(to right, #1d3557, #457b9d);
color: #fff;
border: none;
padding: 12px 20px;
border-radius: 10px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.container button:hover {
transform: translateY(-3px);
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

#result {
margin-top: 20px;
padding: 15px;
border-radius: 10px;
background-color: rgba(255, 255, 255, 0.3);
color: white;
text-align: left;
border: 1px solid rgba(255, 255, 255, 0.4);
overflow-y: auto;
max-height: 200px;
opacity: 0;
transform: scale(0.9);
transition: opacity 0.5s ease-in-out, transform 0.3s ease-in-out;
}

.error-message {
color: red;
font-weight: bold;
text-align: center;
}

/* Tombol credit */
.credit-btn {
background: none;
border: none;
color: white;
font-size: 14px;
cursor: pointer;
margin-top: 10px;
transition: all 0.3s ease-in-out;
}

.credit-btn:hover {
text-decoration: underline;
transform: scale(1.1);
}

/* Animasi modal */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
justify-content: center;
align-items: center;
opacity: 0;
transition: opacity 0.3s ease-in-out;
}

.modal-content {
background: white;
padding: 20px;
border-radius: 10px;
width: 300px;
text-align: center;
position: relative;
transform: scale(0.8);
transition: transform 0.3s ease-in-out;
}

.modal-content h3 {
margin-bottom: 10px;
color: #1d3557;
}

.modal-content p {
color: #333;
}

.close {
position: absolute;
top: 10px;
right: 15px;
font-size: 20px;
cursor: pointer;
color: #333;
}

/* Responsif */
@media (max-width: 600px) {
.container {
padding: 20px;
}

.container h1 {
font-size: 22px;
}

.container button {
font-size: 14px;
}
}

/* Animasi */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(-20px); }
to { opacity: 1; transform: translateY(0); }
}
</style>
</head>
<body>

<div class="container">
<h1>🌐 IP Tracker </h1>
<input type="text" id="ipInput" placeholder="Enter IP address">
<button onclick="trackIP()">Lacak</button>
<div id="result"></div>
<button class="credit-btn" onclick="openModal()">ℹ️ Creator About</button>
</div>

<!-- Modal Popup -->
<div id="creditModal" class="modal">
<div class="modal-content">
<span class="close" onclick="closeModal()">&times;</span>
<h3>⭐ Created By</h3>
<p><b>Rama Andhika</b><br>Above the sky there is still a sky!</p>
</div>
</div>

<script>
function trackIP() {
const ip = document.getElementById('ipInput').value;
const url = `https://ipapi.co/${ip}/json`;

fetch(url)
.then(response => response.json())
.then(data => {
const resultDiv = document.getElementById('result');
let resultHTML = '';

for (const key in data) {
resultHTML += `<p><b>${key}</b>: ${data[key]}</p>`;
}

resultDiv.innerHTML = resultHTML;
resultDiv.style.opacity = '1';
resultDiv.style.transform = 'scale(1)';
})
.catch(error => {
console.error('Error:', error);
document.getElementById('result').innerHTML = '<p class="error-message">Terjadi kesalahan. Pastikan alamat IP yang Anda masukkan valid.</p>';
});
}

function openModal() {
const modal = document.getElementById('creditModal');
modal.style.display = "flex";
setTimeout(() => {
modal.style.opacity = "1";
modal.querySelector('.modal-content').style.transform = "scale(1)";
}, 10);
}

function closeModal() {
const modal = document.getElementById('creditModal');
modal.style.opacity = "0";
modal.querySelector('.modal-content').style.transform = "scale(0.8)";
setTimeout(() => { modal.style.display = "none"; }, 300);
}
</script>

</body>
</html>
