window.ADMIN_TOKEN_KEY = 'stanzin_admin_token';

window.isAdmin = function() {
  try {
    return Boolean(localStorage.getItem(window.ADMIN_TOKEN_KEY));
  } catch (err) {
    return false;
  }
};

window.getAdminToken = function() {
  try {
    return localStorage.getItem(window.ADMIN_TOKEN_KEY);
  } catch (err) {
    return null;
  }
};

window.setAdminToken = function(token) {
  try {
    localStorage.setItem(window.ADMIN_TOKEN_KEY, token);
  } catch (err) {
    console.warn('Failed to set admin token', err);
  }
};

window.clearAdminToken = function() {
  try {
    localStorage.removeItem(window.ADMIN_TOKEN_KEY);
  } catch (err) {
    console.warn('Failed to clear admin token', err);
  }
};
