<style>
    .sov-header {
        background-color: #1c2e4a;
        color: white;
        text-align: center;
        padding: 15px;
        font-weight: bold;
        border-top-left-radius: .25rem;
        border-top-right-radius: .25rem;
    }

    .input-group-text {
        background-color: #f8f9fa;
        border-right: 0;
    }

    .form-control {
        border-left: 0;
    }

    .btn-success {
        background-color: #28a745;
        border-color: #28a745;
    }

    .btn-success:hover {
        background-color: #218838;
        border-color: #1e7e34;
    }

    .password-toggle {
        cursor: pointer;
    }
</style>

<div class="row justify-content-center">
    <div class="col-md-6 col-lg-5">
        <div class="card shadow">
            <div class="sov-header">Redefinir Senha</div>

            <div class="card-body">
                <?php Sessao::mensagem('nova_senha'); ?>

                <form method="POST" action="">
                    <div class="form-group mb-3">
                        <label for="senha">Nova Senha:</label>
                        <div class="input-group">
                            <span class="input-group-text">
                                <i class="bi bi-lock-fill"></i>
                            </span>
                            <input type="password" name="senha" id="senha" class="form-control" required minlength="6">
                            <span class="input-group-text password-toggle" onclick="toggleSenha('senha')">
                                <i class="bi bi-eye-fill" id="icon-senha"></i>
                            </span>
                        </div>
                        <small class="text-muted">Mínimo 6 caracteres.</small>
                    </div>

                    <div class="form-group mb-4">
                        <label for="confirmar_senha">Confirmar Nova Senha:</label>
                        <div class="input-group">
                            <span class="input-group-text">
                                <i class="bi bi-lock-fill"></i>
                            </span>
                            <input type="password" name="confirmar_senha" id="confirmar_senha" class="form-control" required minlength="6">
                            <span class="input-group-text password-toggle" onclick="toggleSenha('confirmar_senha')">
                                <i class="bi bi-eye-fill" id="icon-confirmar_senha"></i>
                            </span>
                        </div>
                    </div>

                    <button type="submit" class="btn btn-success w-100 mb-2">Salvar Nova Senha</button>
                    <a href="<?= URL ?>/usuarios/login" class="btn btn-link w-100">Voltar ao login</a>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    function toggleSenha(idCampo) {
        const campo = document.getElementById(idCampo);
        const icone = document.getElementById('icon-' + idCampo);
        if (campo.type === "password") {
            campo.type = "text";
            icone.classList.remove('bi-eye-fill');
            icone.classList.add('bi-eye-slash-fill');
        } else {
            campo.type = "password";
            icone.classList.remove('bi-eye-slash-fill');
            icone.classList.add('bi-eye-fill');
        }
    }
</script>
