    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        document.getElementById('sidebarToggle')?.addEventListener('click', function() {
            document.querySelector('.sidebar').classList.add('open');
        });
        document.getElementById('sidebarOverlay')?.addEventListener('click', function() {
            document.querySelector('.sidebar').classList.remove('open');
        });
        document.getElementById('profileToggle')?.addEventListener('click', function() {
            document.getElementById('profileDropdown').classList.toggle('open');
        });
        window.onclick = function(event) {
            if (!event.target.closest('.profile-menu')) {
                document.getElementById('profileDropdown')?.classList.remove('open');
            }
        }
    </script>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <script>
        function globalConfirmDelete(url, title = 'Tem certeza?', text = 'Esta ação não pode ser revertida!') {
            Swal.fire({
                title: title,
                text: text,
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#0066FF',
                cancelButtonColor: '#3085d6',
                confirmButtonText: 'Sim, excluir!',
                cancelButtonText: 'Cancelar',
                background: '#0B1121',
                color: '#fff'
            }).then((result) => {
                if (result.isConfirmed) {
                    window.location.href = url;
                }
            });
        }
        
        function globalAjaxDelete(url, rowSelector, title = 'Tem certeza?', text = 'Esta ação não pode ser revertida!') {
            Swal.fire({
                title: title,
                text: text,
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#0066FF',
                cancelButtonColor: '#3085d6',
                confirmButtonText: 'Sim, excluir!',
                cancelButtonText: 'Cancelar',
                background: '#0B1121',
                color: '#fff'
            }).then((result) => {
                if (result.isConfirmed) {
                    fetch(url, { method: 'GET' })
                    .then(response => {
                        if (response.ok) {
                            if (rowSelector) {
                                document.querySelector(rowSelector)?.remove();
                            } else {
                                window.location.reload();
                            }
                            Swal.fire({
                                title: 'Removido!',
                                text: 'Item excluído com sucesso.',
                                icon: 'success',
                                background: '#0B1121',
                                color: '#fff'
                            });
                        }
                    });
                }
            });
        }
    </script>
    <?php if (isset($msg) && !empty($msg)): 
        $icon = 'success';
        $title = 'Sucesso!';
        if (stripos($msg, 'erro') !== false || stripos($msg, 'falha') !== false || stripos($msg, 'inválido') !== false) {
            $icon = 'error';
            $title = 'Erro!';
        }
    ?>
    <script>
        Swal.fire({
            title: '<?php echo $title; ?>',
            text: '<?php echo htmlspecialchars($msg); ?>',
            icon: '<?php echo $icon; ?>',
            background: '#0B1121',
            color: '#fff',
            confirmButtonColor: '#0066FF',
            confirmButtonText: 'OK'
        });
    </script>
    <?php endif; ?>
</body>
</html>
