// dj-drag.js
document.addEventListener('DOMContentLoaded', () => {
  const list = document.getElementById('dj-list');
  let draggedItem = null;

  list.querySelectorAll('.dj-item').forEach(item => {
    item.addEventListener('dragstart', () => {
      draggedItem = item;
      item.style.opacity = '0.5';
    });

    item.addEventListener('dragend', () => {
      draggedItem = null;
      item.style.opacity = '1';
    });

    item.addEventListener('dragover', e => {
      e.preventDefault();
    });

    item.addEventListener('drop', e => {
      e.preventDefault();
      if (draggedItem && draggedItem !== item) {
        list.insertBefore(draggedItem, item.nextSibling);
      }
    });
  });
});
