<header>
    <img id="logo" src="/img/logo pokemon.png" alt="logo pokÃ©mon">
    <nav>
        <ul>
            <a href="/"><li>Home</a></li></a>
            <a href="/cadastro"><li>Cadastro</li></a>

            <div>
                <label for="switch">
                    <input type="checkbox" id="switch"> Dark Mode
                </label>
            </div>
        </ul>
    </nav>
</header>

<script>
    const nightModeStorage = localStorage.getItem('gmtNightMode');
    const nightMode = document.querySelector('#switch');

    if (nightModeStorage) {
        document.documentElement.classList.add('night-mode');
        nightMode.checked = true;
    };


    nightMode.addEventListener('click', () => {
    document.documentElement.classList.toggle('night-mode')

    if (document.documentElement.classList.contains('night-mode')) {
        localStorage.setItem('gmtNightMode', true)
        return
    }
    localStorage.removeItem('gmtNightMode')
    });
</script>