(function() {
// 1. VYTVORENIE ŠTÝLOV (CSS)
const style = document.createElement('style');
style.innerHTML = `
@keyframes ikSlideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
#ik-vol-btn:hover { transform: scale(1.1); box-shadow: 0 10px 30px rgba(197, 160, 89, 0.4); }
#ik-vol-btn:hover #ik-vol-tooltip { opacity: 1; visibility: visible; }
#ik-w-typy label { padding: 8px 4px; font-size: 10px; background: #fff; border: 1px solid #ddd; border-radius: 8px; text-align: center; cursor: pointer; font-weight: bold; transition: 0.2s; display: block; }
#ik-w-typy input:checked + label { background: #1a1a1a; color: #c5a059; border-color: #c5a059; }
#ik-vol-window::-webkit-scrollbar { width: 6px; }
#ik-vol-window::-webkit-scrollbar-thumb { background: #c5a059; border-radius: 10px; }
`;
document.head.appendChild(style);
// 2. VYTVORENIE HTML KONTAJNERA
const container = document.createElement('div');
container.id = "ik-vol-widget-container";
container.setAttribute("data-nosnippet", "");
container.style.cssText = "position: fixed; bottom: 20px; left: 20px; z-index: 999999; font-family: 'Segoe UI', Roboto, Arial, sans-serif;";
container.innerHTML = `
`;
document.body.appendChild(container);
// 3. LOGIKA VÝPOČTOV
const btn = document.getElementById('ik-vol-btn');
const win = document.getElementById('ik-vol-window');
const slider = document.getElementById('w-pocet-slider');
const valDisp = document.getElementById('w-pocet-val');
const resKotlik = document.getElementById('w-res-kotlik');
const resMasoVal = document.getElementById('w-res-maso-val');
const resMasoLabel = document.getElementById('w-res-maso-label');
const listSuroviny = document.getElementById('w-list-suroviny');
const kZoznam = [4, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 60, 70, 80, 100, 120, 150];
const data = {
hovadzi: { label: "Glejka", ing: [["🧅 Cibuľa", 0.9], ["🥔 Zemiaky", 0.65], ["🧴 Voda", 0.85, "L"], ["🏺 Masť", 80, "g"]] },
bravcovy: { label: "Pliecko", ing: [["🧅 Cibuľa", 0.8], ["🥔 Zemiaky", 0.95], ["🧴 Voda", 0.8, "L"], ["🏺 Masť", 70, "g"]] },
divinovy: { label: "Divina", ing: [["🧅 Cibuľa", 0.85], ["🍷 Červené víno", 0.25, "L"], ["🥔 Zemiaky", 0.4], ["🏺 Masť", 85, "g"]] },
fazulovy: { label: "Údené", ing: [["🫘 Fazuľa", 0.45], ["🧅 Cibuľa", 0.6], ["🥔 Zemiaky", 0.55], ["🥕 Zelenina", 0.4]] },
kapustnica: { label: "Mäso/Klobása", ing: [["🥬 Kapusta", 1.25], ["🧅 Cibuľa", 0.3], ["🧴 Voda", 0.75, "L"], ["🍄 Hríby", 15, "g"]] },
vegansky: { label: "Hliva/Sója", ing: [["🧅 Cibuľa", 0.8], ["🥔 Zemiaky", 1.0], ["🍄 Hliva", 0.8], ["🌻 Olej", 80, "ml"]] }
};
btn.onclick = () => {
const isHidden = win.style.display === 'none' || win.style.display === '';
win.style.display = isHidden ? 'block' : 'none';
};
document.getElementById('ik-vol-close').onclick = (e) => {
e.stopPropagation();
win.style.display = 'none';
};
function update() {
const n = parseInt(slider.value);
valDisp.innerText = n;
const activeTyp = document.querySelector('input[name="w-typ"]:checked').value;
const r = data[activeTyp];
const celkovyObjemLitre = (n * 500) / 1000;
const masoKg = celkovyObjemLitre * (activeTyp === 'vegansky' ? 0.35 : 0.45);
const rezerva = (activeTyp === 'fazulovy' || activeTyp === 'kapustnica') ? 1.35 : 1.25;
const potreba = celkovyObjemLitre * rezerva;
let finalK = kZoznam.find(k => k >= potreba) || "150+";
resKotlik.innerText = finalK + " L";
resMasoLabel.innerText = r.label.toUpperCase();
resMasoVal.innerText = masoKg.toFixed(1) + " kg";
let html = "";
r.ing.forEach(i => {
let u = i[2] || "kg";
let v = (masoKg * i[1]).toFixed(1);
if(u === "g" || u === "ml") v = Math.round(masoKg * i[1]);
html += `${i[0]}${v} ${u}
`;
});
listSuroviny.innerHTML = html;
}
slider.oninput = update;
document.querySelectorAll('input[name="w-typ"]').forEach(el => el.onchange = update);
update();
})();