Mudanças entre as edições de "Widget:VisnoTeste"

De Wiki Gla
Ir para navegação Ir para pesquisar
Linha 1: Linha 1:
<div class="infobox-boss-wide">
<div class="full-receitas">
  <div class="infobox-boss-right">
<div class="receitas-wrapper">
    <div class="infobox-skill-info-area">
  <div style="font-size: 180%; font-weight: bold; border-bottom: 1px solid #aaa; margin-bottom: 0.5em;">» <span style="color:#4393ff">Receitas Aliança</span></div>
      <div class="skill-box">
  <div id="receitas-alianca" class="receitas-container"></div>
        <div class="infobox-skill-tabs">
 
          <button class="infobox-skill-tab active" data-video="video1">Golpe Congelante</button>
  <div style="font-size: 180%; font-weight: bold; border-bottom: 1px solid #aaa; margin-bottom: 0.5em;">» <span style="color:#4393ff">Receitas Baratie</span></div>
          <button class="infobox-skill-tab" data-video="video2">Muralha de Gelo</button>
  <div id="receitas-baratie" class="receitas-container"></div>
          <button class="infobox-skill-tab" data-video="video3">Explosão Ártica</button>
</div>
        </div>
<div id="carrinho-container"></div>
        <div class="skill-desc" id="desc-text">
          Golpe Congelante: Causa dano em área e reduz a velocidade dos inimigos.
        </div>
      </div>
    </div>
    <div class="infobox-skill-video-area">
      <video id="video1" class="skill-video" controls autoplay loop>
        <source src="https://wiki.gla.com.br/images/2/22/Aokiji_sk3.webm" type="video/mp4">
        Seu navegador não suporta vídeo.
      </video>
      <video id="video2" class="skill-video" controls autoplay loop style="display:none"></video>
      <video id="video3" class="skill-video" controls autoplay loop style="display:none"></video>
    </div>
  </div>
</div>
</div>


<script>
<script>
  const videoSources = {
let receitasSelecionadas = {
    video1: "https://wiki.gla.com.br/images/2/22/Aokiji_sk3.webm",
  0: null,
    video2: "https://wiki.gla.com.br/images/6/6b/Aokiji_sk2.webm",
  1: null
    video3: "https://wiki.gla.com.br/images/7/76/Aokiji_sk1.webm"
};
  };
let receitas = {};
  const skillDescriptions = {
const berryGif = "/images/thumb/d/d1/Berrynewgif.gif/32px-Berrynewgif.gif";
    video1: "Golpe Congelante: Causa dano em área e reduz a velocidade dos inimigos.",
    video2: "Muralha de Gelo: Cria uma barreira protetora de gelo.",
    video3: "Explosão Ártica: Dispara fragmentos de gelo em várias direções."
  };


  const tabs = document.querySelectorAll('.infobox-skill-tab');
function selecionarReceita(id) {
   const videos = document.querySelectorAll('.skill-video');
   const receita = encontrarReceita(id);
   const desc = document.getElementById('desc-text');
   if (!receita) return;


   tabs.forEach(tab => {
   if (Object.values(receitasSelecionadas).some(r => r && r.id === id)) return;
     tab.addEventListener('click', () => {
 
       tabs.forEach(i => i.classList.remove('active'));
  for (let i = 0; i < 2; i++) {
      tab.classList.add('active');
     if (!receitasSelecionadas[i]) {
      const vid = tab.getAttribute('data-video');
       receitasSelecionadas[i] = {
       desc.textContent = skillDescriptions[vid];
        id: receita.id,
       videos.forEach(v => {
        nome: receita.nome,
         if (v.id === vid) {
        preco: receita.preco,
          if (!v.querySelector('source')) {
        img: receita.img,
            const source = document.createElement('source');
        ingredientes: receita.ingredientes,
            source.src = videoSources[vid];
        lvl: receita.lvl,
            source.type = "video/mp4";
        tempo: receita.tempo,
            v.appendChild(source);
        descricao: receita.descricao,
          }
        quantidade: 1
          v.style.display = '';
      };
          v.load();
      break;
          v.play();
    }
         } else {
  }
          v.pause();
 
          v.style.display = 'none';
  renderizarSelecao();
          while (v.firstChild) v.removeChild(v.firstChild);
}
        }
 
       });
 
     });
// Função para carregar as receitas a partir do JSON
async function cargarReceitas() {
  try {
    const response = await fetch('https://wiki.gla.com.br/index.php?title=Receitas.json&action=raw');
    const data = await response.json();
   
    receitas = {
       baratie: Object.entries(data.baratie).map(([id, item]) => ({
        id,
        nome: item.nome,
        preco: item.cost,
        img: item.thumb,
        ingredientes: item.ingredients || [],
        lvl: item.lvl,
        tempo: item.time,
        descricao: item.description
      })),
       alianca: Object.entries(data.alianca).map(([id, item]) => ({
         id,
        nome: item.nome,
        preco: item.cost,
        img: item.thumb,
        ingredientes: item.ingredients || [],
        lvl: item.lvl,
        tempo: item.time,
        descricao: item.description
      }))
    };
   
    renderizarReceitas();
  } catch (error) {
    console.error('Error al cargar las receitas:', error);
    alert('No se pudieron cargar las receitas. Por favor, inténtalo más tarde.');
  }
}
 
function renderizarReceitas() {
  renderizarSecao('baratie');
  renderizarSecao('alianca');
}
 
function renderizarSecao(secao) {
  const container = document.getElementById(`receitas-${secao}`);
  if (!container) return;
 
  container.innerHTML = '';
 
  receitas[secao].forEach(receita => {
    const card = document.createElement('div');
    card.className = 'receita-card';
    card.setAttribute('data-id', receita.id);
    card.innerHTML = `
      <button class="info-btn" onclick="mostrarModalReceita(this)"
         data-descricao="${encodeURIComponent(receita.descricao)}"
        data-lvl="${receita.lvl}"
        data-tempo="${receita.tempo}">i</button>
      <img src="${receita.img}" width="48" height="48" />
      <div class="receita-nome">${receita.nome}</div>
      <div class="receita-preco">${receita.preco.toLocaleString()} <img src="${berryGif}" alt="Berry" width="25" height="25" style="transform: translateY(-1px);"/></div>
       <button class="add-to-cart-btn" onclick="selecionarReceita('${receita.id}')">Selecionar</button>
    `;
     container.appendChild(card);
   });
   });
</script>
}
 
function mostrarModalReceita(button) {
  const descricao = decodeURIComponent(button.getAttribute('data-descricao'));
  const lvl = button.getAttribute('data-lvl');
  const tempo = button.getAttribute('data-tempo');
  const descricaoFormatada = descricao
    .replace(/\n/g, '<br>')
    .replace(/Tempo de recarga/g, '<br><strong>Tempo de recarga</strong>');


<style>
  const modalHTML = `
.infobox-boss-wide {
    <div class="modal-overlay active" onclick="cerrarModal(event)">
  display: flex;
      <div class="modal-content" onclick="event.stopPropagation()">
  flex-direction: column;
        <button class="close-modal" onclick="cerrarModal(event)">×</button>
  align-items: center;
        <p><strong>Nível:</strong> ${lvl}</p>
  justify-content: center;
        <p><strong>Tempo de preparo:</strong> ${tempo} min</p>
  width: 100%;
        <p><strong>Descrição:</strong><br>${descricaoFormatada}</p>
  min-height: unset;
      </div>
  background: none;
    </div>
  border: none;
   `;
  border-radius: 12px;
    
   box-shadow: none;
   document.body.insertAdjacentHTML('beforeend', modalHTML);
   font-family: sans-serif;
   document.addEventListener('keydown', (e) => e.key === 'Escape' && cerrarModal(e));
   color: #222;
   overflow: hidden;
}
}
.infobox-boss-right {
 
   width: 100%;
function cerrarModal(event) {
   display: flex;
   event.preventDefault();
   flex-direction: column;
   const modal = document.querySelector('.modal-overlay');
  align-items: center;
   if (modal) {
   justify-content: center;
    modal.classList.remove('active');
    setTimeout(() => modal.remove(), 300);
   }
}
}
.skill-box {
 
   background: none;;
function encontrarReceita(id) {
  color: #222;
   for (const secao in receitas) {
  border-radius: 12px;
    const receita = receitas[secao].find(r => r.id === id);
  box-shadow: none;
    if (receita) return receita;
  width: 100%;
   }
   max-width: 700px;
   return null;
  box-sizing: border-box;
  padding: 24px 24px 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  backdrop-filter: blur(2px);
   margin: 0 auto 24px auto;
}
}
.infobox-skill-info-area {
 
   width: 100%;
function renderizarSelecao() {
   max-width: 900px;
  const container = document.getElementById('carrinho-container');
   display: flex;
   container.innerHTML = '';
  flex-direction: column;
 
  align-items: center;
   let totalSlots = 2;
  justify-content: center;
 
  margin-bottom: 16px;
   for (let i = 0; i < totalSlots; i++) {
  margin-top: 24px;
    const receita = receitasSelecionadas[i];
   gap: 12px;
 
    const itemDiv = document.createElement('div');
    itemDiv.className = 'item-carrinho';
 
    if (receita) {
      const subtotal = receita.preco * receita.quantidade;
      tempo = formatarTempo(receita.tempo * receita.quantidade);
 
      const ingredientesHtml = receita.ingredientes.map(([nome, qtd]) => {
        const totalIngrediente = qtd * receita.quantidade;
        return `<div><img class="ingrediente-img" src="URL_DA_IMAGEM" alt="${nome}"/>${nome}: ${totalIngrediente}</div>`;
      }).join('');
 
      itemDiv.innerHTML = `
        <img src="${receita.img}" width="40" height="40" />
        <div class="info-carrinho">
          <div class="nome-item">${receita.nome}</div>
          <div class="atributes">
            <div class="">Level: ${receita.lvl}</div>
            <div class="">Time: ${tempo}</div>
            <p class="texto-centrado">${receita.descricao}</p>
          </div>
          <div class="controle-quantidade">
            <button onclick="alterarQuantidadeSelecionada(${i}, -1)">−</button>
            <input type="number" value="${receita.quantidade}" min="1"
                  onchange="atualizarQuantidadeManualSelecionada(${i}, event)">
            <button onclick="alterarQuantidadeSelecionada(${i}, 1)">+</button>
            <button class="btn-100" onclick="definir100Selecionada(${i})">x100</button>
          </div>
          <div class="ingredientes">
            ${ingredientesHtml}
          </div>
        </div>
        <div class="subtotal">${subtotal.toLocaleString()} <img src="${berryGif}" alt="Berry" width="25" height="25" style="transform: translateY(-1px);" /></div>
        <button class="remover-item" onclick="removerReceitaSelecionada(${i})">🗑️</button>
      `;
    } else {
      itemDiv.innerHTML = `<div class="placeholder">Selecione uma receita</div>`;
    }
 
    container.appendChild(itemDiv);
   }
}
}
.infobox-skill-tabs {
 
   display: flex;
function alterarQuantidadeSelecionada(index, alteracao) {
   gap: 12px;
   const receita = receitasSelecionadas[index];
   justify-content: center;
   if (!receita) return;
   margin-bottom: 0;
   receita.quantidade += alteracao;
   width: 100%;
   if (receita.quantidade < 1) receita.quantidade = 1;
   renderizarSelecao();
}
}
.infobox-skill-tab {
 
   cursor: pointer;
function atualizarQuantidadeManualSelecionada(index, event) {
   background: #fff;
   const valor = parseInt(event.target.value);
  color: #222;
   if (valor && valor >= 1) {
  border: 2px solid #ffc107;
    receitasSelecionadas[index].quantidade = valor;
  border-radius: 8px;
    renderizarSelecao();
  padding: 10px 24px;
   }
  font-size: 1em;
  font-weight: bold;
  transition: 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
   opacity: 0.7;
  margin-bottom: 0;
}
}
.infobox-skill-tab.active,
 
.infobox-skill-tab:hover {
function definir100Selecionada(index) {
   opacity: 1;
   if (receitasSelecionadas[index]) {
  background: #ffc107;
    receitasSelecionadas[index].quantidade = 100;
  color: #181f2a;
    renderizarSelecao();
   border-color: #ffc107;
   }
}
}
.skill-desc {
 
   font-size: 1.08em;
function removerReceitaSelecionada(index) {
  width: 100%;
   receitasSelecionadas[index] = null;
  text-align: center;
   renderizarSelecao();
  font-weight: 500;
  line-height: 1.5;
  margin-top: 0;
  margin-bottom: 0;
  background: none;
  color: #222;
  box-shadow: none;
  border-radius: 0;
   padding: 0;
}
}
.infobox-skill-video-area {
 
   width: 100%;
function formatarTempo(minutosDecimal) {
   max-width: 900px;
   const minutosInt = Math.floor(minutosDecimal);
  min-height: 270px;
   const segundos = Math.round((minutosDecimal % 1) * 60);
   display: flex;
 
  align-items: center;
   if (minutosInt < 1) {
  justify-content: center;
    return `${segundos}seg`;
  background: transparent;
   } else if (segundos === 0) {
  border-radius: 8px;
    return `${minutosInt}min`;
   margin-top: 0;
   } else {
  margin-bottom: 0;
    return `${minutosInt}min ${segundos.toString().padStart(2, '0')}seg`;
   box-shadow: none;
   }
  padding: 16px 0;
   margin-left: auto;
  margin-right: auto;
}
}
.skill-video {
 
   width: 100%;
document.addEventListener('DOMContentLoaded', () => {
  height: auto;
   renderizarSelecao();
  max-width: 700px;
});
   border-radius: 8px;
 
  background: #000;
// CSS
  display: block;
document.head.insertAdjacentHTML('beforeend', `
   margin: 0 auto;
<style>
   @import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&display=swap');
 
body, html {
   font-family: 'Noto Sans', Arial, Helvetica, sans-serif;
}
}
@media (max-width: 900px) {
 
  .infobox-boss-wide {
  .receitas-container {
     min-height: unset;
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-bottom: 24px;
    justify-content: center;
    background: #f6f7fa;
     border-radius: 10px;
    padding: 10px 0;
   }
   }
   .infobox-skill-info-area,
   .nome-item, .subtotal{
  .infobox-skill-video-area {
     user-select: none;
     max-width: 100vw;
    width: 100%;
    padding: 0 2vw;
   }
   }
   .skill-video,
 
  .skill-box {
   .receita-card {
     max-width: 100vw;
    width: 150px;          /* aumente a largura */
     width: 100%;
    text-align: center;
    border: 1.5px solid #e0e0e0;
    border-radius: 12px;
    padding: 12px 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(180,180,180,0.10);
    transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
     user-select: none;
     position: relative;
   }
   }
  .receita-card:hover {
    transform: translateY(-4px) scale(1.06);
    box-shadow: 0 8px 24px rgba(180,180,180,0.18);
    background: #f2f2f2;
  }
  .modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(80, 80, 80, 0.18);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }
  .modal-overlay.active {
    opacity: 1;
    visibility: visible;
  }
  .modal-content {
    background: #fff;
    padding: 22px;
    border-radius: 10px;
    width: 320px;
    position: relative;
    box-shadow: 0 4px 16px rgba(120,120,120,0.18);
  }
  .close-modal {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    cursor: pointer;
    background: none;
    border: none;
    color: #888;
  }
  .info-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #e0e0e0;
    color: #333;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s;
  }
  .info-btn:hover {
    background: #bdbdbd;
  }
  .receita-nome {
    font-weight: bold;
    margin: 4px 0;
    min-height: 3em;
    max-height: 3em;
    line-height: 1.5em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 80%;        /* pode aumentar ou diminuir conforme preferir */
    color: #222;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
  }
  .nome-item{
    font-weight: bold;
    color: #222;
  }
  .ingredientes{
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 5px;
    margin-bottom: 10px;
  }
  .ingredientes div {
    background-color: #f3f3f3;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 5px 7px 5px 32px; /* espaço à esquerda para a imagem */
    font-size: 13px;
    text-align: left;
    color: #444;
    white-space: normal;
    overflow: hidden;
    text-overflow: unset;
    overflow-wrap: break-word;
    align-content: center;
    position: relative;
    min-height: 32px;
    display: flex;
    align-items: center;
  }
  /* Espaço reservado para a imagem do ingrediente */
.ingrediente-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  margin-right: 6px;
  margin-left: -24px;
  flex-shrink: 0;
  background: transparent;
  display: inline-block;
}
}


  .receita-preco {
    margin-bottom: 2px;
    color: #555;
  }
 
  .item-carrinho {
    display: flex;
    gap: 12px;
    padding: 12px;
    border: 1.5px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 12px;
    width: 44.5%;
    margin-inline: 1%;
    flex-direction: column;
    align-items: center;
    background: #fafbfc;
    box-shadow: 0 2px 8px rgba(180,180,180,0.08);
    height: fit-content;
    min-height: 97%;
    transition: box-shadow 0.18s, background 0.18s;
  }
  .item-carrinho:hover {
    background: #f2f2f2;
    box-shadow: 0 8px 24px rgba(180,180,180,0.13);
  }
  .info-carrinho {
    flex: 1;
    justify-items: center;
  }
 
  .controle-quantidade {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2%;
    margin-bottom: 5%;
  }
 
  .controle-quantidade input {
    width: 44px;
    text-align: center;
    padding: 2px;
    border: 1px solid #bbb;
    border-radius: 4px;
    background: #f7f7f7;
    color: #333;
  }
 
  .controle-quantidade button {
    width: 24px;
    height: 24px;
    background: #e0e0e0;
    border: none;
    border-radius: 4px;
    color: #222;
    cursor: pointer;
    transition: background 0.2s;
  }
  .controle-quantidade button:hover {
    background: #bdbdbd;
  }
 
  .btn-100 {
    width: auto !important;
    padding: 0 4px;
    margin-left: 4px;
    font-size: 12px;
    background: #d1d5db !important;
    color: #222;
  }
 
  .remover-item {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #888;
    transition: color 0.2s;
  }
  .remover-item:hover {
    color: #d32f2f;
  }
 
  .acao-carrinho {
    padding: 8px 16px;
    background-color: #4393ff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
  }
 
  .acao-carrinho:hover {
    background-color: #3275c7;
  }
  #carrinho-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    width: 69%;
  }
  .receita-card.highlighted {
    background-color: #e8f5e9;
  }
  .detalhe-receita ul {
    padding-left: 20px;
  }
  .detalhe-receita li {
    margin-bottom: 3px;
  }
  .detalhe-receita {
    width: 16%;
    justify-items: anchor-center;
  }
  .receitas-wrapper{
    display: flex;
    flex-direction: column;
    width: 32.5%;
    position: static;
    max-height: 620px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1.5px solid #e0e0e0;
    padding: 10px;
    border-radius: 12px;
    background: #fafbfc;
  }
  .full-receitas {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    background: #f6f7fa;
  }
  @media screen and (max-width: 1366px) {
    .item-carrinho {
      width: 45%;
    }
    .receitas-wrapper{
      display: flex;
      flex-direction: column;
      width: 35.5vw;
    }
  }
  .atributes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 5px;
    margin-bottom: 10px;
    width: 80%;
    justify-items: center;
  }
  .texto-centrado {
    text-align: center;
    grid-column: 1 / -1;
  }
  @media (max-width: 768px) {
    .item-carrinho {
      width: 43%;
    }
  }
  @media only screen and (min-width: 1280px) and (max-width: 1280px) and (min-height: 1024px) and (max-height: 1024px) {
    .item-carrinho {
      width: 32%;
    }
  }
</style>
</style>
`);
// Carregar as receitas ao iniciar
document.addEventListener('DOMContentLoaded', cargarReceitas);
</script>

Edição das 19h44min de 27 de maio de 2025

» Receitas Aliança
» Receitas Baratie


<script> let receitasSelecionadas = {

 0: null,
 1: null

}; let receitas = {}; const berryGif = "/images/thumb/d/d1/Berrynewgif.gif/32px-Berrynewgif.gif";

function selecionarReceita(id) {

 const receita = encontrarReceita(id);
 if (!receita) return;
 if (Object.values(receitasSelecionadas).some(r => r && r.id === id)) return;
 for (let i = 0; i < 2; i++) {
   if (!receitasSelecionadas[i]) {
     receitasSelecionadas[i] = {
       id: receita.id,
       nome: receita.nome,
       preco: receita.preco,
       img: receita.img,
       ingredientes: receita.ingredientes,
       lvl: receita.lvl,
       tempo: receita.tempo,
       descricao: receita.descricao,
       quantidade: 1
     };
     break;
   }
 }
 renderizarSelecao();

}


// Função para carregar as receitas a partir do JSON async function cargarReceitas() {

 try {
   const response = await fetch('https://wiki.gla.com.br/index.php?title=Receitas.json&action=raw');
   const data = await response.json();
   
   receitas = {
     baratie: Object.entries(data.baratie).map(([id, item]) => ({
       id,
       nome: item.nome,
       preco: item.cost,
       img: item.thumb,
       ingredientes: item.ingredients || [],
       lvl: item.lvl,
       tempo: item.time,
       descricao: item.description
     })),
     alianca: Object.entries(data.alianca).map(([id, item]) => ({
       id,
       nome: item.nome,
       preco: item.cost,
       img: item.thumb,
       ingredientes: item.ingredients || [],
       lvl: item.lvl,
       tempo: item.time,
       descricao: item.description
     }))
   };
   
   renderizarReceitas();
 } catch (error) {
   console.error('Error al cargar las receitas:', error);
   alert('No se pudieron cargar las receitas. Por favor, inténtalo más tarde.');
 }

}

function renderizarReceitas() {

 renderizarSecao('baratie');
 renderizarSecao('alianca');

}

function renderizarSecao(secao) {

 const container = document.getElementById(`receitas-${secao}`);
 if (!container) return;
 container.innerHTML = ;
 receitas[secao].forEach(receita => {
   const card = document.createElement('div');
   card.className = 'receita-card';
   card.setAttribute('data-id', receita.id);
   card.innerHTML = `
     <button class="info-btn" onclick="mostrarModalReceita(this)" 
       data-descricao="${encodeURIComponent(receita.descricao)}"
       data-lvl="${receita.lvl}"
       data-tempo="${receita.tempo}">i</button>
     <img src="${receita.img}" width="48" height="48" />
${receita.nome}
${receita.preco.toLocaleString()} <img src="${berryGif}" alt="Berry" width="25" height="25" style="transform: translateY(-1px);"/>
     <button class="add-to-cart-btn" onclick="selecionarReceita('${receita.id}')">Selecionar</button>
   `;
   container.appendChild(card);
 });

}

function mostrarModalReceita(button) {

 const descricao = decodeURIComponent(button.getAttribute('data-descricao'));
 const lvl = button.getAttribute('data-lvl');
 const tempo = button.getAttribute('data-tempo');
 const descricaoFormatada = descricao
   .replace(/\n/g, '
') .replace(/Tempo de recarga/g, '
Tempo de recarga');
 const modalHTML = `
 `;
 
 document.body.insertAdjacentHTML('beforeend', modalHTML);
 document.addEventListener('keydown', (e) => e.key === 'Escape' && cerrarModal(e));

}

function cerrarModal(event) {

 event.preventDefault();
 const modal = document.querySelector('.modal-overlay');
 if (modal) {
   modal.classList.remove('active');
   setTimeout(() => modal.remove(), 300);
 }

}

function encontrarReceita(id) {

 for (const secao in receitas) {
   const receita = receitas[secao].find(r => r.id === id);
   if (receita) return receita;
 }
 return null;

}

function renderizarSelecao() {

 const container = document.getElementById('carrinho-container');
 container.innerHTML = ;
 let totalSlots = 2;
 for (let i = 0; i < totalSlots; i++) {
   const receita = receitasSelecionadas[i];
   const itemDiv = document.createElement('div');
   itemDiv.className = 'item-carrinho';
   if (receita) {
     const subtotal = receita.preco * receita.quantidade;
     tempo = formatarTempo(receita.tempo * receita.quantidade);
     const ingredientesHtml = receita.ingredientes.map(([nome, qtd]) => {
       const totalIngrediente = qtd * receita.quantidade;

return `

<img class="ingrediente-img" src="URL_DA_IMAGEM" alt="${nome}"/>${nome}: ${totalIngrediente}

`;

     }).join();
     itemDiv.innerHTML = `
       <img src="${receita.img}" width="40" height="40" />
${receita.nome}
Level: ${receita.lvl}
Time: ${tempo}

${receita.descricao}

           <button onclick="alterarQuantidadeSelecionada(${i}, -1)">−</button>
           <input type="number" value="${receita.quantidade}" min="1"
                  onchange="atualizarQuantidadeManualSelecionada(${i}, event)">
           <button onclick="alterarQuantidadeSelecionada(${i}, 1)">+</button>
           <button class="btn-100" onclick="definir100Selecionada(${i})">x100</button>
           ${ingredientesHtml}
${subtotal.toLocaleString()} <img src="${berryGif}" alt="Berry" width="25" height="25" style="transform: translateY(-1px);" />
       <button class="remover-item" onclick="removerReceitaSelecionada(${i})">🗑️</button>
     `;
   } else {

itemDiv.innerHTML = `

Selecione uma receita

`;

   }
   container.appendChild(itemDiv);
 }

}

function alterarQuantidadeSelecionada(index, alteracao) {

 const receita = receitasSelecionadas[index];
 if (!receita) return;
 receita.quantidade += alteracao;
 if (receita.quantidade < 1) receita.quantidade = 1;
 renderizarSelecao();

}

function atualizarQuantidadeManualSelecionada(index, event) {

 const valor = parseInt(event.target.value);
 if (valor && valor >= 1) {
   receitasSelecionadas[index].quantidade = valor;
   renderizarSelecao();
 }

}

function definir100Selecionada(index) {

 if (receitasSelecionadas[index]) {
   receitasSelecionadas[index].quantidade = 100;
   renderizarSelecao();
 }

}

function removerReceitaSelecionada(index) {

 receitasSelecionadas[index] = null;
 renderizarSelecao();

}

function formatarTempo(minutosDecimal) {

 const minutosInt = Math.floor(minutosDecimal);
 const segundos = Math.round((minutosDecimal % 1) * 60);
 if (minutosInt < 1) {
   return `${segundos}seg`;
 } else if (segundos === 0) {
   return `${minutosInt}min`;
 } else {
   return `${minutosInt}min ${segundos.toString().padStart(2, '0')}seg`;
 }

}

document.addEventListener('DOMContentLoaded', () => {

 renderizarSelecao();

});

// CSS document.head.insertAdjacentHTML('beforeend', ` <style>

 @import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&display=swap');

body, html {

 font-family: 'Noto Sans', Arial, Helvetica, sans-serif;

}

 .receitas-container {
   display: flex;
   flex-wrap: wrap;
   gap: 18px;
   margin-bottom: 24px;
   justify-content: center;
   background: #f6f7fa;
   border-radius: 10px;
   padding: 10px 0;
 }
 .nome-item, .subtotal{
   user-select: none;
 }
 
 .receita-card {
   width: 150px;           /* aumente a largura */
   text-align: center;
   border: 1.5px solid #e0e0e0;
   border-radius: 12px;
   padding: 12px 8px;
   background: #fff;
   box-shadow: 0 2px 8px rgba(180,180,180,0.10);
   transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
   user-select: none;
   position: relative;
 }
 .receita-card:hover {
   transform: translateY(-4px) scale(1.06);
   box-shadow: 0 8px 24px rgba(180,180,180,0.18);
   background: #f2f2f2;
 }
 .modal-overlay {
   position: fixed;
   top: 0; left: 0; right: 0; bottom: 0;
   background-color: rgba(80, 80, 80, 0.18);
   display: flex;
   justify-content: center;
   align-items: center;
   z-index: 1000;
   opacity: 0;
   visibility: hidden;
   transition: all 0.3s ease;
 }
 .modal-overlay.active {
   opacity: 1;
   visibility: visible;
 }
 .modal-content {
   background: #fff;
   padding: 22px;
   border-radius: 10px;
   width: 320px;
   position: relative;
   box-shadow: 0 4px 16px rgba(120,120,120,0.18);
 }
 .close-modal {
   position: absolute;
   top: 10px;
   right: 10px;
   font-size: 20px;
   cursor: pointer;
   background: none;
   border: none;
   color: #888;
 }
 .info-btn {
   position: absolute;
   top: 5px;
   right: 5px;
   background: #e0e0e0;
   color: #333;
   border: none;
   border-radius: 50%;
   width: 22px;
   height: 22px;
   font-size: 13px;
   cursor: pointer;
   display: flex;
   justify-content: center;
   align-items: center;
   transition: background 0.2s;
 }
 .info-btn:hover {
   background: #bdbdbd;
 }
 .receita-nome {
   font-weight: bold;
   margin: 4px 0;
   min-height: 3em;
   max-height: 3em;
   line-height: 1.5em;
   display: -webkit-box;
   -webkit-line-clamp: 2;
   -webkit-box-orient: vertical;
   align-items: center;
   justify-content: center;
   text-align: center;
   font-size: 80%;         /* pode aumentar ou diminuir conforme preferir */
   color: #222;
   overflow: hidden;
   text-overflow: ellipsis;
   word-break: break-word;
 }
 .nome-item{
   font-weight: bold;
   color: #222;
 }
 .ingredientes{
   display: grid;
   grid-template-columns: repeat(2, 1fr);
   gap: 8px;
   margin-top: 5px;
   margin-bottom: 10px;
 }
 .ingredientes div {
   background-color: #f3f3f3;
   border: 1px solid #e0e0e0;
   border-radius: 4px;
   padding: 5px 7px 5px 32px; /* espaço à esquerda para a imagem */
   font-size: 13px;
   text-align: left;
   color: #444;
   white-space: normal;
   overflow: hidden;
   text-overflow: unset;
   overflow-wrap: break-word;
   align-content: center;
   position: relative;
   min-height: 32px;
   display: flex;
   align-items: center;
 }
 /* Espaço reservado para a imagem do ingrediente */

.ingrediente-img {

 width: 24px;
 height: 24px;
 object-fit: contain;
 margin-right: 6px;
 margin-left: -24px;
 flex-shrink: 0;
 background: transparent;
 display: inline-block;

}

 .receita-preco {
   margin-bottom: 2px;
   color: #555;
 }
 
 .item-carrinho {
   display: flex;
   gap: 12px;
   padding: 12px;
   border: 1.5px solid #e0e0e0;
   border-radius: 12px;
   margin-bottom: 12px;
   width: 44.5%;
   margin-inline: 1%;
   flex-direction: column;
   align-items: center;
   background: #fafbfc;
   box-shadow: 0 2px 8px rgba(180,180,180,0.08);
   height: fit-content;
   min-height: 97%;
   transition: box-shadow 0.18s, background 0.18s;
 }
 .item-carrinho:hover {
   background: #f2f2f2;
   box-shadow: 0 8px 24px rgba(180,180,180,0.13);
 }
 .info-carrinho {
   flex: 1;
   justify-items: center;
 }
 
 .controle-quantidade {
   display: flex;
   align-items: center;
   gap: 4px;
   margin-top: 2%;
   margin-bottom: 5%;
 }
 
 .controle-quantidade input {
   width: 44px;
   text-align: center;
   padding: 2px;
   border: 1px solid #bbb;
   border-radius: 4px;
   background: #f7f7f7;
   color: #333;
 }
 
 .controle-quantidade button {
   width: 24px;
   height: 24px;
   background: #e0e0e0;
   border: none;
   border-radius: 4px;
   color: #222;
   cursor: pointer;
   transition: background 0.2s;
 }
 .controle-quantidade button:hover {
   background: #bdbdbd;
 }
 
 .btn-100 {
   width: auto !important;
   padding: 0 4px;
   margin-left: 4px;
   font-size: 12px;
   background: #d1d5db !important;
   color: #222;
 }
 
 .remover-item {
   background: none;
   border: none;
   cursor: pointer;
   font-size: 16px;
   color: #888;
   transition: color 0.2s;
 }
 .remover-item:hover {
   color: #d32f2f;
 }
 
 .acao-carrinho {
   padding: 8px 16px;
   background-color: #4393ff;
   color: white;
   border: none;
   border-radius: 4px;
   cursor: pointer;
 }
 
 .acao-carrinho:hover {
   background-color: #3275c7;
 }
 #carrinho-container {
   display: flex;
   flex-direction: row;
   flex-wrap: nowrap;
   justify-content: center;
   width: 69%;
 }
 .receita-card.highlighted {
   background-color: #e8f5e9;
 }
 .detalhe-receita ul {
   padding-left: 20px;
 }
 .detalhe-receita li {
   margin-bottom: 3px;
 }
 .detalhe-receita {
   width: 16%;
   justify-items: anchor-center;
 }
 .receitas-wrapper{
   display: flex;
   flex-direction: column;
   width: 32.5%;
   position: static;
   max-height: 620px;
   overflow-y: auto;
   overflow-x: hidden;
   border: 1.5px solid #e0e0e0;
   padding: 10px;
   border-radius: 12px;
   background: #fafbfc;
 }
 .full-receitas {
   display: flex;
   flex-direction: row;
   flex-wrap: nowrap;
   background: #f6f7fa;
 }
 @media screen and (max-width: 1366px) {
   .item-carrinho {
     width: 45%;
   }
   .receitas-wrapper{
     display: flex;
     flex-direction: column;
     width: 35.5vw;
   }
 }
 .atributes {
   display: grid;
   grid-template-columns: repeat(2, 1fr);
   gap: 8px;
   margin-top: 5px;
   margin-bottom: 10px;
   width: 80%;
   justify-items: center;
 }
 .texto-centrado {
   text-align: center;
   grid-column: 1 / -1;
 }
 @media (max-width: 768px) {
   .item-carrinho {
     width: 43%;
   }
 }
 @media only screen and (min-width: 1280px) and (max-width: 1280px) and (min-height: 1024px) and (max-height: 1024px) {
   .item-carrinho {
     width: 32%;
   }
 }

</style> `);

// Carregar as receitas ao iniciar document.addEventListener('DOMContentLoaded', cargarReceitas); </script>