// Wait for the DOM to be fully loaded
document.addEventListener('DOMContentLoaded', function() {
    // Copy Link functionality
    const copyLinkBtn = document.getElementById('copyLinkBtn');
    
    if (copyLinkBtn) {
        copyLinkBtn.addEventListener('click', () => {
            const url = copyLinkBtn.getAttribute('data-url');
            
            // Create a temporary input element
            const tempInput = document.createElement('input');
            tempInput.value = url;
            document.body.appendChild(tempInput);
            
            // Select and copy the text
            tempInput.select();
            document.execCommand('copy');
            
            // Remove the temporary element
            document.body.removeChild(tempInput);
            
            // Show toast notification
            showToast('Link copied to clipboard!');
        });
    }
    
    // Toast notification function
    function showToast(message) {
        // Check if toast already exists
        let toast = document.querySelector('.toast');
        
        // If not, create it
        if (!toast) {
            toast = document.createElement('div');
            toast.className = 'toast';
            document.body.appendChild(toast);
        }
        
        // Set message and show
        toast.textContent = message;
        toast.classList.add('show');
        
        // Hide after 3 seconds
        setTimeout(() => {
            toast.classList.remove('show');
        }, 3000);
    }
}); 