.copy-list li {
display: flex;
justify-content: space-between;
align-items: center;
} listItems.forEach(function(item) {
if (item.querySelector('.copy-icon')) return; // Wrap text inside a span (only if not already wrapped)
if (!item.querySelector('.copy-text')) {
const textSpan = document.createElement('span');
textSpan.classList.add('copy-text');
textSpan.textContent = item.textContent.trim();
item.textContent = '';
item.appendChild(textSpan);
} // Create copy icon
const copyIcon = document.createElement('i');
copyIcon.classList.add('fas', 'fa-copy', 'copy-icon');
item.appendChild(copyIcon); // Copy logic
copyIcon.addEventListener('click', function() {
const textToCopy = item.querySelector('.copy-text').innerText;
navigator.clipboard.writeText(textToCopy).then(() => {
console.log('Copied:', textToCopy);
});
});
});