<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Age Calculator</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"></link>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Roboto', sans-serif;
        }
    </style>
</head>
<body class="bg-gray-100 text-gray-900">
    <div class="min-h-screen flex items-center justify-center">
        <div class="bg-white p-8 rounded-lg shadow-lg w-full max-w-md">
            <h1 class="text-2xl font-bold mb-6 text-center">Age Calculator</h1>
            <form id="ageForm" class="mb-6">
                <div class="mb-4">
                    <label for="birthdate" class="block text-gray-700">Enter your birthdate:</label>
                    <input type="date" id="birthdate" class="w-full p-2 border border-gray-300 rounded mt-2" required>
                </div>
                <button type="submit" class="w-full bg-blue-500 text-white p-2 rounded">Calculate Age</button>
            </form>
            <div id="result" class="text-center text-lg font-semibold"></div>
        </div>
    </div>

    <script>
        document.getElementById('ageForm').addEventListener('submit', function(event) {
            event.preventDefault();
            const birthdate = new Date(document.getElementById('birthdate').value);
            const now = new Date();
            const ageInMilliseconds = now - birthdate;
            const ageDate = new Date(ageInMilliseconds);

            const years = ageDate.getUTCFullYear() - 1970;
            const months = ageDate.getUTCMonth();
            const days = ageDate.getUTCDate() - 1;
            const hours = ageDate.getUTCHours();
            const minutes = ageDate.getUTCMinutes();
            const seconds = ageDate.getUTCSeconds();

            document.getElementById('result').innerHTML = `
                You are ${years} years, ${months} months, ${days} days, ${hours} hours, ${minutes} minutes, and ${seconds} seconds old.
            `;
        });
    </script>
</body>
</html>