.elementor-1468 .elementor-element.elementor-element-3989868{--display:flex;--flex-direction:column;--container-widget-width:100%;--container-widget-height:initial;--container-widget-flex-grow:0;--container-widget-align-self:initial;--flex-wrap-mobile:wrap;}/* Start custom CSS for text-editor, class: .elementor-element-0a69a8c */<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Age Calculator</title>

    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: Arial, sans-serif;
        }

        body {
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background: linear-gradient(135deg, #667eea, #764ba2);
            padding: 20px;
        }

        .calculator {
            width: 100%;
            max-width: 450px;
            background: white;
            padding: 35px;
            border-radius: 20px;
            box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
        }

        .calculator h1 {
            text-align: center;
            color: #333;
            margin-bottom: 10px;
        }

        .calculator .subtitle {
            text-align: center;
            color: #777;
            margin-bottom: 30px;
        }

        .input-box {
            margin-bottom: 20px;
        }

        .input-box label {
            display: block;
            font-size: 16px;
            font-weight: bold;
            color: #333;
            margin-bottom: 8px;
        }

        .input-box input {
            width: 100%;
            padding: 13px;
            border: 2px solid #ddd;
            border-radius: 10px;
            font-size: 16px;
            outline: none;
        }

        .input-box input:focus {
            border-color: #667eea;
        }

        .buttons {
            display: flex;
            gap: 10px;
            margin-top: 25px;
        }

        button {
            flex: 1;
            padding: 14px;
            border: none;
            border-radius: 10px;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: 0.3s;
        }

        .calculate-btn {
            background: #667eea;
            color: white;
        }

        .calculate-btn:hover {
            background: #5568d8;
        }

        .reset-btn {
            background: #eee;
            color: #333;
        }

        .reset-btn:hover {
            background: #ddd;
        }

        .result {
            display: none;
            margin-top: 30px;
        }

        .result h2 {
            text-align: center;
            color: #333;
            margin-bottom: 20px;
        }

        .age-boxes {
            display: flex;
            gap: 10px;
        }

        .age-box {
            flex: 1;
            background: #f4f5ff;
            padding: 18px 10px;
            border-radius: 12px;
            text-align: center;
        }

        .age-box span {
            display: block;
            font-size: 28px;
            font-weight: bold;
            color: #667eea;
        }

        .age-box small {
            color: #555;
            font-size: 14px;
        }

        .total-days {
            margin-top: 15px;
            padding: 15px;
            text-align: center;
            background: #f8f8f8;
            border-radius: 10px;
            color: #555;
        }

        .error {
            display: none;
            margin-top: 15px;
            padding: 12px;
            border-radius: 8px;
            background: #ffe5e5;
            color: #d00;
            text-align: center;
        }

        @media (max-width: 500px) {
            .calculator {
                padding: 25px 20px;
            }

            .age-box span {
                font-size: 24px;
            }
        }
    </style>
</head>

<body>

    <div class="calculator">

        <h1>🎂 Age Calculator</h1>

        <p class="subtitle">
            Calculate your exact age
        </p>

        <div class="input-box">
            <label for="dob">📅 Date of Birth</label>

            <input type="date" id="dob">
        </div>

        <div class="buttons">

            <button class="calculate-btn" onclick="calculateAge()">
                📅 Calculate Age
            </button>

            <button class="reset-btn" onclick="resetCalculator()">
                🔄 Reset
            </button>

        </div>

        <div class="error" id="error">
            Please select your date of birth.
        </div>

        <div class="result" id="result">

            <h2>Your Age Is</h2>

            <div class="age-boxes">

                <div class="age-box">
                    <span id="years">0</span>
                    <small>Years</small>
                </div>

                <div class="age-box">
                    <span id="months">0</span>
                    <small>Months</small>
                </div>

                <div class="age-box">
                    <span id="days">0</span>
                    <small>Days</small>
                </div>

            </div>

            <div class="total-days">
                You have lived approximately
                <strong id="totalDays">0</strong> days.
            </div>

        </div>

    </div>


    <script>

        function calculateAge() {

            const dobInput = document.getElementById("dob").value;

            const error = document.getElementById("error");

            const result = document.getElementById("result");


            if (dobInput === "") {

                error.style.display = "block";

                result.style.display = "none";

                return;
            }


            const birthDate = new Date(dobInput);

            const today = new Date();


            if (birthDate > today) {

                error.innerText = "Date of birth cannot be in the future.";

                error.style.display = "block";

                result.style.display = "none";

                return;
            }


            error.style.display = "none";


            let years = today.getFullYear() - birthDate.getFullYear();

            let months = today.getMonth() - birthDate.getMonth();

            let days = today.getDate() - birthDate.getDate();


            if (days < 0) {

                months--;

                const previousMonth = new Date(
                    today.getFullYear(),
                    today.getMonth(),
                    0
                );

                days += previousMonth.getDate();
            }


            if (months < 0) {

                years--;

                months += 12;
            }


            const difference = today - birthDate;

            const totalDays = Math.floor(
                difference / (1000 * 60 * 60 * 24)
            );


            document.getElementById("years").innerText = years;

            document.getElementById("months").innerText = months;

            document.getElementById("days").innerText = days;

            document.getElementById("totalDays").innerText = totalDays;


            result.style.display = "block";
        }


        function resetCalculator() {

            document.getElementById("dob").value = "";

            document.getElementById("result").style.display = "none";

            document.getElementById("error").style.display = "none";
        }

    </script>

</body>
</html>/* End custom CSS */