// Settings Tab
const tabs = document.querySelectorAll('.tab');
const contents = document.querySelectorAll('.content');

tabs.forEach(tab => {
  tab.addEventListener('click', () => {
    tabs.forEach(tab => tab.classList.remove('active'));
    contents.forEach(content => content.classList.remove('active'));
    tab.classList.add('active');
    document.getElementById(tab.dataset.tab).classList.add('active');
  });
});


// Settings Tab reload active current tab
document.addEventListener('DOMContentLoaded', function () {
  const tabs = document.querySelectorAll('.tab');
  const contents = document.querySelectorAll('.content');
  const activeTabId = localStorage.getItem('activeTab') || 'tab1';
  if (tabs.length === 0 || contents.length === 0) return;
  tabs.forEach(tab => tab.classList.remove('active'));
  contents.forEach(content => content.classList.remove('active'));
  const activeTab = document.querySelector(`.tab[data-tab="${activeTabId}"]`);
  const activeContent = document.getElementById(activeTabId);
  if (activeTab && activeContent) {
    activeTab.classList.add('active');
    activeContent.classList.add('active');
  }
  tabs.forEach(tab => {
    tab.addEventListener('click', () => {
      tabs.forEach(tab => tab.classList.remove('active'));
      contents.forEach(content => content.classList.remove('active'));
      const targetTab = tab.dataset.tab;
      tab.classList.add('active');
      document.getElementById(targetTab).classList.add('active');
      localStorage.setItem('activeTab', targetTab);
    });
  });

 
});


// Each control/input
document.addEventListener('DOMContentLoaded', function () {
  const selectElement = document.getElementById('w_text_img_allow');
  const inputForOption1 = document.getElementById('inputForOption1');
  const inputForOption2 = document.getElementById('inputForOption2');

  selectElement?.addEventListener('change', function () {
    const selectedValue = selectElement.value;
    inputForOption1.style.display = 'none';
    inputForOption2.style.display = 'none';
    if (selectedValue === 'w-text') {
      inputForOption1.style.display = 'block';
    } else if (selectedValue === 'w-logo') {
      inputForOption2.style.display = 'block';
    }
  });

});


