// Dynamic DataTables initialization for items table
document.addEventListener('DOMContentLoaded', function() {
    if ($('#itemsTable').length) {
        $('#itemsTable').DataTable({
            responsive: true,
            pageLength: 25,
            lengthMenu: [[10, 25, 50, 100, -1], [10, 25, 50, 100, 'All']],
            order: [[0, 'asc']],
            columnDefs: [
                { orderable: false, targets: -1 }, // Actions column no sort
                { className: 'text-nowrap', targets: '_all' }
            ],
            language: {
                search: 'Search items:',
                lengthMenu: 'Show _MENU_ items per page',
                paginate: {
                    first: '<<',
                    last: '>>',
                    next: '>',
                    previous: '<'
                }
            },
            dom: '<"top"lf>rt<"bottom"ip><"clear">'
        });
    }
});

