
(function () {
  var PHONE = "tel:+302111103762";

  function normalizeCallButtons() {
    document.querySelectorAll('a, button').forEach(function(el) {
      var text = (el.textContent || '').trim().toLowerCase();
      var isCall =
        text.indexOf('κλήση τώρα') !== -1 ||
        text.indexOf('κάλεσέ μας') !== -1 ||
        text.indexOf('καλεσε μας') !== -1 ||
        text.indexOf('call now') !== -1 ||
        text.indexOf('call us') !== -1;

      if (!isCall) return;

      if (el.tagName.toLowerCase() === 'a') {
        el.setAttribute('href', PHONE);
        el.removeAttribute('target');
        el.style.pointerEvents = 'auto';
      }
    });
  }

  document.addEventListener('DOMContentLoaded', normalizeCallButtons);
  window.addEventListener('pageshow', normalizeCallButtons);
  document.addEventListener('visibilitychange', function () {
    if (!document.hidden) normalizeCallButtons();
  });
  window.addEventListener('focus', normalizeCallButtons);
})();
