/* OK ITHAKI R10F28 — multilingual official site, secure APK and local-profile QR */
(()=>{'use strict';
const SITE='https://www.ok-ithaki.gr/';const GUEST='https://ok-ithaki.gr/?mode=guest';const APK=SITE+'downloads/ok-ithaki.apk';const PAIR='https://ok-ithaki.gr/?pair=local-profile';
const LANGS=[['el','🇬🇷'],['en','🇬🇧'],['de','🇩🇪'],['fr','🇫🇷'],['es','🇪🇸'],['it','🇮🇹'],['pl','🇵🇱'],['ro','🇷🇴'],['hu','🇭🇺'],['sr','🇷🇸'],['bg','🇧🇬'],['pt','🇵🇹']];
function openExternal(url){try{if(window.Android?.openExternalUrl){window.Android.openExternalUrl(url);return}}catch(e){}try{if(window.Android?.openUrl){window.Android.openUrl(url);return}}catch(e){}window.open(url,'_blank','noopener,noreferrer')}
function showHub(){document.getElementById('ithSiteQr28')?.remove();const x=document.createElement('div');x.id='ithSiteQr28';x.innerHTML=`<div class="ithSiteQrCard28"><button class="ithSiteQrClose28">×</button><h2>OK ITHAKI · Επίσημη σύνδεση</h2><p>APK μόνο από το επίσημο site. Το QR ίδιου προφίλ συνδέει τη δεύτερη συσκευή χωρίς email ή τηλέφωνο και δεν αποτελεί ανάκτηση λογαριασμού.</p><div class="ithQrTabs28"><button data-img="${SITE}assets/qr-mobile.png" data-url="${APK}">📱 APK</button><button data-img="${SITE}assets/qr-pair.png" data-url="${PAIR}">🔗 Ίδιο avatar</button></div><img class="ithSiteQrImage28" src="${SITE}assets/qr-mobile.png" alt="QR OK ITHAKI"><button class="ithOpen28">Άνοιγμα</button><div class="ithLangs28">${LANGS.map(([c,f])=>`<button data-lang="${c}">${f}</button>`).join('')}</div></div>`;document.body.appendChild(x);let url=APK;x.querySelector('.ithSiteQrClose28').onclick=()=>x.remove();x.onclick=e=>{if(e.target===x)x.remove()};x.querySelectorAll('.ithQrTabs28 button').forEach(b=>b.onclick=()=>{url=b.dataset.url;x.querySelector('.ithSiteQrImage28').src=b.dataset.img});x.querySelector('.ithOpen28').onclick=()=>openExternal(url);x.querySelectorAll('.ithLangs28 button').forEach(b=>b.onclick=()=>openExternal(SITE+'?lang='+b.dataset.lang));}
function css(){if(document.getElementById('ithSiteQrCss28'))return;const s=document.createElement('style');s.id='ithSiteQrCss28';s.textContent=`#ithSiteQr28{position:fixed;inset:0;z-index:2147483647;display:grid;place-items:center;padding:18px;background:rgba(1,7,14,.9);backdrop-filter:blur(12px)}.ithSiteQrCard28{position:relative;width:min(460px,100%);max-height:94vh;overflow:auto;padding:24px;border:1px solid #328bc1;border-radius:22px;background:linear-gradient(155deg,#09233a,#020b15);color:#fff;text-align:center;box-shadow:0 24px 70px #000}.ithSiteQrCard28 h2{color:#7de4ff}.ithSiteQrImage28{width:min(290px,78vw);border:8px solid #fff;border-radius:12px}.ithSiteQrCard28 button{padding:11px;border-radius:10px;border:1px solid #328bc1;background:#0a3454;color:#fff;font-weight:900}.ithSiteQrClose28{position:absolute;right:12px;top:10px;width:42px}.ithQrTabs28,.ithLangs28{display:flex;justify-content:center;gap:7px;flex-wrap:wrap;margin:12px}.ithOpen28{display:block;width:100%;margin-top:10px}.ithSitePlus28{border-color:#48bde9!important;background:linear-gradient(135deg,#11324b,#071725)!important;color:#e8fbff!important}`;document.head.appendChild(s)}
function button(label,action){const b=document.createElement('button');b.type='button';b.className='ithSitePlus28';b.textContent=label;b.onclick=e=>{e.preventDefault();e.stopPropagation();action()};return b}
function suitable(el){if(!el||el.dataset.ithSite28==='1')return false;const t=(el.textContent||'').toLowerCase(),id=(el.id+' '+el.className).toLowerCase();return /δημοσί|δημιουργ|create|publish|κέντρο|μενού/.test(t)||/plus.*menu|create.*menu|publish.*menu|composer.*menu/.test(id)}
function install(){css();[...document.querySelectorAll('[id*="plus" i],[class*="plus" i],[id*="create" i],[class*="create" i],[id*="publish" i],[class*="publish" i],dialog,.modal')].filter(suitable).forEach(el=>{el.dataset.ithSite28='1';const box=document.createElement('div');box.append(button('🌐 Επίσημη ιστοσελίδα',()=>openExternal(SITE)),button('👤 Δες ως επισκέπτης',()=>openExternal(GUEST)),button('▣ QR APK / ίδιο avatar',showHub));el.appendChild(box)})}
window.ITHAKI_OFFICIAL_SITE=()=>openExternal(SITE);window.ITHAKI_GUEST=()=>openExternal(GUEST);window.ITHAKI_APK_QR=showHub;new MutationObserver(install).observe(document.documentElement,{childList:true,subtree:true});addEventListener('DOMContentLoaded',install);setTimeout(install,600);setInterval(install,4000);
})();