(function() { 'use strict'; const token = localStorage.getItem('auth_token'); if (!token) { window.location.href = '/'; return; } function decodeJwt(token) { try { return JSON.parse(atob(token.split('.')[1])); } catch { return null; } } const decoded = decodeJwt(token); if (!decoded) { localStorage.removeItem('auth_token'); window.location.href = '/'; return; } // Check if admin if (!decoded.admin) { window.location.href = '/picks.html'; return; } // Logout const logOffBtn = document.getElementById('log-off'); if (logOffBtn) { logOffBtn.addEventListener('click', () => { localStorage.removeItem('auth_token'); window.location.href = '/'; }); } let allPicks = []; let categories = []; let currentYear = new Date().getFullYear(); function showAlert(message, type = 'info') { const container = document.getElementById('alert-container'); if (!container) return; container.innerHTML = `