// ========== PANEL TAB SWITCHING (shared utility) ==========
(function() {
  document.addEventListener('click', (e) => {
    const tab = e.target.closest('.panel-tab');
    if (!tab) return;
    const panelId = tab.dataset.panel;
    if (!panelId) return;
    const tabBar = tab.closest('.panel-tabs');
    const modalContent = tabBar.closest('.weather-modal-content');
    tabBar.querySelectorAll('.panel-tab').forEach(t => t.classList.remove('active'));
    tab.classList.add('active');
    modalContent.querySelectorAll('.panel-section').forEach(s => s.classList.remove('active'));
    const target = modalContent.querySelector('#' + panelId);
    if (target) target.classList.add('active');
  });
})();
