 // Georgia state tax brackets
    const taxBracketsGeorgia = {
        single: [
            { rate: 0.01, max: 750 },
            { rate: 0.02, max: 2250 },
            { rate: 0.03, max: 3750 },
            { rate: 0.04, max: 5250 },
            { rate: 0.05, max: 7000 },
            { rate: 0.0575, max: Infinity }
        ],
        married_jointly: [
            { rate: 0.01, max: 1000 },
            { rate: 0.02, max: 3000 },
            { rate: 0.03, max: 5000 },
            { rate: 0.04, max: 7000 },
            { rate: 0.05, max: 10000 },
            { rate: 0.0575, max: Infinity }
        ],
        married_separately: [
            { rate: 0.01, max: 500 },
            { rate: 0.02, max: 1500 },
            { rate: 0.03, max: 2500 },
            { rate: 0.04, max: 3500 },
            { rate: 0.05, max: 5000 },
            { rate: 0.0575, max: Infinity }
        ],
        head_of_household: [
            { rate: 0.01, max: 1000 },
            { rate: 0.02, max: 3000 },
            { rate: 0.03, max: 5000 },
            { rate: 0.04, max: 7000 },
            { rate: 0.05, max: 10000 },
            { rate: 0.0575, max: Infinity }
        ]
    };

    // Federal tax brackets
    const taxBracketsFederal = {
        single: [
            { rate: 0.10, max: 11600 },
            { rate: 0.12, max: 47150 },
            { rate: 0.22, max: 100525 },
            { rate: 0.24, max: 191950 },
            { rate: 0.32, max: 243725 },
            { rate: 0.35, max: 609350 },
            { rate: 0.37, max: Infinity }
        ],
        married_jointly: [
            { rate: 0.10, max: 23200 },
            { rate: 0.12, max: 94300 },
            { rate: 0.22, max: 201050 },
            { rate: 0.24, max: 383900 },
            { rate: 0.32, max: 487450 },
            { rate: 0.35, max: 731200 },
            { rate: 0.37, max: Infinity }
        ],
        married_separately: [
            { rate: 0.10, max: 11600 },
            { rate: 0.12, max: 47150 },
            { rate: 0.22, max: 100525 },
            { rate: 0.24, max: 191950 },
            { rate: 0.32, max: 243725 },
            { rate: 0.35, max: 365600 },
            { rate: 0.37, max: Infinity }
        ],
        head_of_household: [
            { rate: 0.10, max: 16550 },
            { rate: 0.12, max: 59850 },
            { rate: 0.22, max: 95350 },
            { rate: 0.24, max: 182100 },
            { rate: 0.32, max: 231250 },
            { rate: 0.35, max: 578100 },
            { rate: 0.37, max: Infinity }
        ]
    };

    // Function to calculate state tax
    function calculateStateTax(income, brackets) {
        let stateTax = 0;
        let remainingIncome = income;

        for (let i = 0; i < brackets.length; i++) {
            let bracket = brackets[i];
            if (remainingIncome > bracket.max) {
                stateTax += (bracket.max - (brackets[i - 1] ? brackets[i - 1].max : 0)) * bracket.rate;
            } else {
                stateTax += (remainingIncome - (brackets[i - 1] ? brackets[i - 1].max : 0)) * bracket.rate;
                break;
            }
        }
        return stateTax;
    }

    // Function to calculate federal tax
    function calculateFederalTax(income, brackets) {
        let federalTax = 0;
        let remainingIncome = income;

        for (let i = 0; i < brackets.length; i++) {
            let bracket = brackets[i];
            if (remainingIncome > bracket.max) {
                federalTax += (bracket.max - (brackets[i - 1] ? brackets[i - 1].max : 0)) * bracket.rate;
            } else {
                federalTax += (remainingIncome - (brackets[i - 1] ? brackets[i - 1].max : 0)) * bracket.rate;
                break;
            }
        }
        return federalTax;
    }

    // Main function to calculate total tax and take-home salary
    function calculateTax() {
        let income = parseFloat(document.getElementById("income").value);
        let filingStatus = document.getElementById("filingStatus").value;

        // Calculate Georgia state tax
        const georgiaBrackets = taxBracketsGeorgia[filingStatus];
        const stateTax = calculateStateTax(income, georgiaBrackets);

        // Calculate Federal tax
        const federalBrackets = taxBracketsFederal[filingStatus];
        const federalTax = calculateFederalTax(income, federalBrackets);

        // Social Security and Medicare
        const socialSecurityTax = income * 0.062;
        const medicareTax = income * 0.0145;

        // Total Tax Calculation
        const totalTax = stateTax + federalTax + socialSecurityTax + medicareTax;
        const takeHomeSalary = income - totalTax;

        // Display the result
        document.getElementById("result").innerHTML = `
            <strong>Income before tax:</strong> $${income.toFixed(2)}<br>
            <strong>Federal Tax:</strong> $${federalTax.toFixed(2)}<br>
            <strong>Georgia State Tax:</strong> $${stateTax.toFixed(2)}<br>
            <strong>Social Security (6.2%):</strong> $${socialSecurityTax.toFixed(2)}<br>
            <strong>Medicare (1.45%):</strong> $${medicareTax.toFixed(2)}<br>
            <strong>Total Tax:</strong> $${totalTax.toFixed(2)}<br>
            <strong>Take-home Salary:</strong> $${takeHomeSalary.toFixed(2)}
        `;
    }