class AuthModal extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` `; const modal = this.shadowRoot.getElementById('authModal'); const closeBtn = this.shadowRoot.getElementById('closeModal'); const form = this.shadowRoot.getElementById('authForm'); closeBtn.addEventListener('click', () => { modal.style.display = 'none'; }); form.addEventListener('submit', (e) => { e.preventDefault(); modal.style.display = 'none'; document.dispatchEvent(new CustomEvent('auth-success')); }); // Show modal when auth is required document.addEventListener('auth-required', () => { modal.style.display = 'flex'; }); } } customElements.define('auth-modal', AuthModal);