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

De Wiki Gla
Ir para navegação Ir para pesquisar
Linha 49: Linha 49:
async function cargarReceitas() {
async function cargarReceitas() {
   try {
   try {
     const response = await fetch('https://wiki.gla.com.br/index.php?title=Receitas.json&action=raw');
     const response = await fetch('receitas.json');
     const data = await response.json();
     const data = await response.json();
      
      
Linha 77: Linha 77:
     renderizarReceitas();
     renderizarReceitas();
   } catch (error) {
   } catch (error) {
     console.error('Erro ao carregar as receitas:', error);
     console.error('Error al cargar las receitas:', error);
     alert('Não foi possível carregar as receitas locais.');
     alert('No se pudieron cargar las receitas. Por favor, inténtalo más tarde.');
   }
   }
}
}
Linha 165: Linha 165:
     if (receita) {
     if (receita) {
       const subtotal = receita.preco * receita.quantidade;
       const subtotal = receita.preco * receita.quantidade;
       const tempoTotal = formatarTempo(receita.tempo * receita.quantidade);  
       tempo = formatarTempo(receita.tempo * receita.quantidade);


       const ingredientesHtml = receita.ingredientes.map(([nome, qtd]) => {
       const ingredientesHtml = receita.ingredientes.map(([nome, qtd]) => {
         const totalIngrediente = qtd * receita.quantidade;
         const totalIngrediente = qtd * receita.quantidade;
         return `<div>${nome}: ${totalIngrediente}</div>`;
         return `<div><img class="ingrediente-img" src="URL_DA_IMAGEM" alt="${nome}"/>${nome}: ${totalIngrediente}</div>`;
       }).join('');
       }).join('');


Linha 178: Linha 178:
           <div class="atributes">
           <div class="atributes">
             <div class="">Level: ${receita.lvl}</div>
             <div class="">Level: ${receita.lvl}</div>
             <div class="">Time: ${tempoTotal}</div>
             <div class="">Time: ${tempo}</div>
             <p class="texto-centrado">${receita.descricao}</p>
             <p class="texto-centrado">${receita.descricao}</p>
           </div>
           </div>
Linha 243: Linha 243:
   }
   }
}
}


document.addEventListener('DOMContentLoaded', () => {
document.addEventListener('DOMContentLoaded', () => {
Linha 249: Linha 248:
});
});


// Carregar as receitas ao iniciar
// CSS
document.addEventListener('DOMContentLoaded', cargarReceitas);
 
// CSS moderno e agradável
document.head.insertAdjacentHTML('beforeend', `
document.head.insertAdjacentHTML('beforeend', `
<style>
<style>
   body {
   @import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&display=swap');
    background: #f6f8fa;
    font-family: 'Segoe UI', Arial, sans-serif;
    color: #222;
    margin: 0;
    padding: 0;
  }


  .full-receitas {
body, html {
    display: flex;
   font-family: 'Noto Sans', Arial, Helvetica, sans-serif;
    flex-direction: row;
}
    align-items: stretch;
    gap: 32px;
    min-height: 100vh;
   }
 
  .receitas-wrapper {
    flex: 1 1 0;
    overflow-y: auto;
  }
 
  #carrinho-container {
    flex: 1 1 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 20px;
    background: #f8fbff;
    border-radius: 16px;
    padding: 24px 18px;
  }


   .receitas-container {
   .receitas-container {
Linha 292: Linha 261:
     flex-wrap: wrap;
     flex-wrap: wrap;
     gap: 18px;
     gap: 18px;
     margin-bottom: 32px;
     margin-bottom: 24px;
     justify-content: center;
     justify-content: center;
    background: #f6f7fa;
    border-radius: 10px;
    padding: 10px 0;
  }
  .nome-item, .subtotal{
    user-select: none;
   }
   }
 
 
   .receita-card {
   .receita-card {
     width: 110px;
     width: 110px;
     text-align: center;
     text-align: center;
     border: 1.5px solid rgba(0,0,0,0.13); /* igual ao carrinho */
     border: 1.5px solid #e0e0e0;
     border-radius: 12px;
     border-radius: 12px;
     padding: 18px 12px; /* igual ao carrinho */
     padding: 12px 8px;
     background: #fff;   /* igual ao carrinho */
     background: #fff;
     box-shadow: 0 2px 8px rgba(67,147,255,0.08); /* igual ao carrinho */
     box-shadow: 0 2px 8px rgba(180,180,180,0.10);
     transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
     transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
     user-select: none;
     user-select: none;
     position: relative;
     position: relative;
     cursor: pointer;
  }
  .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;
     display: flex;
     flex-direction: column;
     justify-content: center;
     align-items: center;
     align-items: center;
     min-width: 180px; /* para ficar mais larga como o carrinho */
     z-index: 1000;
     min-height: 180px;
    opacity: 0;
     justify-content: center;
    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);
   }
   }
   .receita-card:hover {
 
     transform: translateY(-4px) scale(1.06);
   .close-modal {
     box-shadow: 0 8px 24px rgba(67,147,255,0.13); /* igual ao carrinho hover */
    position: absolute;
     background: #eaf3ff;
    top: 10px;
     right: 10px;
    font-size: 20px;
     cursor: pointer;
     background: none;
    border: none;
    color: #888;
   }
   }


   .info-btn {
   .info-btn {
     position: absolute;
     position: absolute;
     top: 7px;
     top: 5px;
     right: 7px;
     right: 5px;
     background: #4393ff;
     background: #e0e0e0;
     color: white;
     color: #333;
     border: none;
     border: none;
     border-radius: 50%;
     border-radius: 50%;
Linha 336: Linha 342:
     justify-content: center;
     justify-content: center;
     align-items: center;
     align-items: center;
    box-shadow: 0 1px 4px rgba(67,147,255,0.13);
     transition: background 0.2s;
     transition: background 0.2s;
   }
   }
   .info-btn:hover {
   .info-btn:hover {
     background: #2566b3;
     background: #bdbdbd;
   }
   }


   .receita-nome {
   .receita-nome {
     font-weight: 600;
     font-weight: bold;
     margin: 8px 0 4px 0;
     margin: 4px 0;
     min-height: 2.5em;
     min-height: 3em;
     line-height: 1.3em;
     line-height: 1.5em;
     display: flex;
     display: flex;
     align-items: center;
     align-items: center;
     justify-content: center;
     justify-content: center;
     text-align: center;
     text-align: center;
     font-size: 95%;
     font-size: 92%;
     color: #2566b3;
     color: #222;
  }
  .nome-item{
    font-weight: bold;
    color: #222;
   }
   }


   .receita-preco {
   .ingredientes{
     margin-bottom: 4px;
    display: grid;
     font-size: 15px;
    grid-template-columns: repeat(2, 1fr);
     color: #4393ff;
    gap: 8px;
     font-weight: 500;
    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;
     display: flex;
     align-items: center;
     align-items: center;
    justify-content: center;
    gap: 2px;
   }
   }


   .add-to-cart-btn {
   /* Espaço reservado para a imagem do ingrediente */
    background: linear-gradient(90deg, #4393ff 60%, #2566b3 100%);
.ingrediente-img {
    color: #fff;
  width: 24px;
    border: none;
  height: 24px;
    border-radius: 6px;
  object-fit: contain;
    padding: 5px 0;
  margin-right: 6px;
    width: 100%;
  margin-left: -24px;
    font-size: 14px;
  flex-shrink: 0;
    font-weight: 500;
  background: transparent;
     margin-top: 6px;
  display: inline-block;
     cursor: pointer;
}
    transition: background 0.2s, transform 0.1s;
 
    box-shadow: 0 1px 4px rgba(67,147,255,0.10);
  .receita-preco {
     margin-bottom: 2px;
     color: #555;
   }
   }
   .add-to-cart-btn:hover {
    
    background: linear-gradient(90deg, #2566b3 60%, #4393ff 100%);
    transform: scale(1.04);
  }
 
   .item-carrinho {
   .item-carrinho {
     flex: 1 1 45%;
     display: flex;
    max-width: 48%;
     gap: 12px;
     min-width: 300px;
     padding: 12px;
     width: 100%;
     border: 1.5px solid #e0e0e0;
    margin-bottom: 0;
    background: #fff;
     border: 1.5px solid rgba(0,0,0,0.13); /* borda preta suave */
     border-radius: 12px;
     border-radius: 12px;
     padding: 18px 12px;
     margin-bottom: 12px;
     display: flex;
     width: 44.5%;
    margin-inline: 1%;
     flex-direction: column;
     flex-direction: column;
     align-items: center;
     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 {
   .item-carrinho:not(:empty):hover {
    background: #f2f2f2;
     box-shadow: 0 8px 24px rgba(67,147,255,0.13);
     box-shadow: 0 8px 24px rgba(180,180,180,0.13);
   }
   }


   .info-carrinho {
   .info-carrinho {
     flex: 1;
     flex: 1;
    width: 100%;
     justify-items: center;
     justify-items: center;
   }
   }
 
    
   .nome-item {
    font-weight: 700;
    color: #2566b3;
    font-size: 1.08em;
    margin-bottom: 2px;
  }
 
  .atributes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 5px;
    margin-bottom: 10px;
    width: 90%;
    justify-items: center;
    font-size: 14px;
    color: #555;
  }
  .texto-centrado {
    text-align: center;
    grid-column: 1 / -1;
    font-size: 13px;
    color: #444;
    margin-top: 4px;
  }
 
   .controle-quantidade {
   .controle-quantidade {
     display: flex;
     display: flex;
     align-items: center;
     align-items: center;
     gap: 6px;
     gap: 4px;
     margin-top: 2%;
     margin-top: 2%;
     margin-bottom: 5%;
     margin-bottom: 5%;
   }
   }
 
   .controle-quantidade input {
   .controle-quantidade input {
     width: 48px;
     width: 44px;
     text-align: center;
     text-align: center;
     padding: 2px;
     padding: 2px;
     border: 1px solid #d0d8e0;
     border: 1px solid #bbb;
     border-radius: 4px;
     border-radius: 4px;
     font-size: 15px;
     background: #f7f7f7;
     background: #f8fbff;
     color: #333;
   }
   }
 
   .controle-quantidade button {
   .controle-quantidade button {
     width: 26px;
     width: 24px;
     height: 26px;
     height: 24px;
    background: #e0e0e0;
     border: none;
     border: none;
     border-radius: 4px;
     border-radius: 4px;
    background: #eaf3ff;
     color: #222;
     color: #2566b3;
    font-size: 16px;
     cursor: pointer;
     cursor: pointer;
     transition: background 0.15s;
     transition: background 0.2s;
   }
   }
   .controle-quantidade button:hover {
   .controle-quantidade button:hover {
     background: #4393ff;
     background: #bdbdbd;
    color: #fff;
   }
   }
 
   .btn-100 {
   .btn-100 {
     width: auto !important;
     width: auto !important;
     padding: 0 8px;
     padding: 0 4px;
     margin-left: 4px;
     margin-left: 4px;
     font-size: 13px;
     font-size: 12px;
     background: #4393ff;
     background: #d1d5db !important;
     color: #fff;
     color: #222;
    border-radius: 4px;
    font-weight: 500;
    transition: background 0.15s;
   }
   }
   .btn-100:hover {
    
    background: #2566b3;
  }
 
   .remover-item {
   .remover-item {
     background: none;
     background: none;
     border: none;
     border: none;
     cursor: pointer;
     cursor: pointer;
     font-size: 20px;
     font-size: 16px;
     color: #e74c3c;
     color: #888;
    margin-top: 6px;
     transition: color 0.2s;
     transition: color 0.15s;
   }
   }
   .remover-item:hover {
   .remover-item:hover {
     color: #b71c1c;
     color: #d32f2f;
   }
   }
 
 
   .ingredientes {
   .acao-carrinho {
     display: grid;
     padding: 8px 16px;
    grid-template-columns: repeat(2, 1fr);
     background-color: #4393ff;
    gap: 8px;
     color: white;
     margin-top: 5px;
     border: none;
    margin-bottom: 10px;
     width: 90%;
  }
  .ingredientes div {
    background-color: #f8fbff;
     border: 1px solid #d0d8e0;
     border-radius: 4px;
     border-radius: 4px;
     padding: 6px 8px;
     cursor: pointer;
    font-size: 14px;
    text-align: center;
    color: #2566b3;
    font-weight: 500;
    white-space: normal;
    overflow: hidden;
    text-overflow: unset;
    overflow-wrap: break-word;
    align-content: center;
   }
   }
 
 
   .subtotal {
   .acao-carrinho:hover {
    font-size: 15px;
     background-color: #3275c7;
     font-weight: 600;
    color: #4393ff;
    display: flex;
    align-items: center;
    gap: 2px;
    user-select: none;
   }
   }


   #carrinho-container {
   #carrinho-container {
    flex: 1 1 0;
     display: flex;
     display: flex;
     flex-direction: row;
     flex-direction: row;
     flex-wrap: wrap;
     flex-wrap: nowrap;
     align-items: stretch;
     justify-content: center;
     gap: 20px;
     width: 69%;
     background: #f8fbff;
  }
    border-radius: 16px;
 
     padding: 24px 18px;
  .receita-card.highlighted {
     background-color: #e8f5e9;
  }
 
  .detalhe-receita ul {
     padding-left: 20px;
   }
   }


  /* Modal */
   .detalhe-receita li {
   .modal-overlay {
     margin-bottom: 3px;
     position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(67,147,255, 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;
   .detalhe-receita {
     visibility: visible;
     width: 16%;
     justify-items: anchor-center;
   }
   }
   .modal-content {
 
     background-color: #fff;
   .receitas-wrapper{
     padding: 28px 24px 18px 24px;
     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;
     border-radius: 12px;
     width: 340px;
     background: #fafbfc;
    position: relative;
    box-shadow: 0 8px 32px rgba(67,147,255,0.18);
    font-size: 16px;
    color: #2566b3;
   }
   }
   .close-modal {
 
     position: absolute;
   .full-receitas {
     top: 12px;
     display: flex;
     right: 12px;
     flex-direction: row;
    font-size: 22px;
     flex-wrap: nowrap;
    cursor: pointer;
     background: #f6f7fa;
     background: none;
    border: none;
    color: #4393ff;
    transition: color 0.15s;
  }
  .close-modal:hover {
    color: #e74c3c;
   }
   }


  /* Responsividade */
   @media screen and (max-width: 1366px) {
   @media (max-width: 1100px) {
    .full-receitas {
      flex-direction: column;
      align-items: center;
      gap: 24px;
    }
    .receitas-wrapper, #carrinho-container {
      width: 95vw;
      max-width: 420px;
      margin: 0 auto;
    }
    #carrinho-container {
      flex: 1 1 100%;
      width: 100%;
      margin-left: 0;
    }
     .item-carrinho {
     .item-carrinho {
       width: 100%;
       width: 45%;
      min-width: unset;
      max-width: unset;
     }
     }
  }
     .receitas-wrapper{
  @media (max-width: 900px) {
      display: flex;
     .full-receitas {
       flex-direction: column;
       flex-direction: column;
      align-items: stretch;
       width: 35.5vw;
      gap: 18px;
      padding: 12px 0;
    }
    .receitas-wrapper, #carrinho-container {
       width: 98vw;
      max-width: 100%;
      margin: 0 auto;
      border-radius: 10px;
      padding: 12px 4px;
    }
    #carrinho-container {
      margin-left: 0;
      min-height: unset;
    }
    .item-carrinho {
      width: 100%;
      min-width: unset;
      max-width: unset;
      margin-bottom: 14px;
      padding: 12px 6px;
    }
    .receita-card {
      width: 95vw;
      max-width: 320px;
      margin: 0 auto;
     }
     }
   }
   }
   @media (max-width: 700px) {
   .atributes {
     .full-receitas {
    display: grid;
      flex-direction: column;
     grid-template-columns: repeat(2, 1fr);
      gap: 12px;
    gap: 8px;
      padding: 4vw 0;
    margin-top: 5px;
      min-height: unset;
     margin-bottom: 10px;
     }
    width: 80%;
    .receitas-wrapper, #carrinho-container {
    justify-items: center;
      width: 100vw;
  }
      max-width: 100vw;
  .texto-centrado {
      min-width: 0;
    text-align: center;
      margin: 0;
    grid-column: 1 / -1;
      border-radius: 0;
  }
      padding: 8px 2vw;
 
      box-sizing: border-box;
  @media (max-width: 768px) {
    }
    .receita-card {
      width: 100%;
      max-width: 100vw;
      min-width: 0;
      margin: 0 0 12px 0;
      padding: 10px 2px 8px 2px;
    }
     .item-carrinho {
     .item-carrinho {
       width: 100%;
       width: 43%;
      max-width: 100vw;
      min-width: 0;
      margin-bottom: 12px;
      padding: 8px 2px;
      min-height: 100px;
    }
    .ingredientes {
      grid-template-columns: 1fr;
      gap: 4px;
      width: 100%;
    }
    .modal-content {
      width: 98vw;
      min-width: unset;
      padding: 12px 4px 8px 4px;
      border-radius: 8px;
     }
     }
   }
   }
   @media (max-width: 600px) {
 
    .receitas-wrapper, #carrinho-container {
   @media only screen and (min-width: 1280px) and (max-width: 1280px) and (min-height: 1024px) and (max-height: 1024px) {
      padding: 6px 2px;
      border-radius: 6px;
    }
    .receita-card {
      width: 98vw;
      max-width: 98vw;
      padding: 10px 2px 8px 2px;
    }
    .modal-content {
      width: 98vw;
      min-width: unset;
      padding: 12px 4px 8px 4px;
    }
     .item-carrinho {
     .item-carrinho {
       padding: 8px 2px;
       width: 32%;
      min-height: 120px;
     }
     }
    .ingredientes {
      grid-template-columns: 1fr;
      gap: 4px;
      width: 100%;
    }
  }
  .item-carrinho .placeholder {
    color: #2566b3;
    opacity: 0.85;
    font-size: 1.15em;
    font-weight: 500;
    text-align: center;
    margin: auto 0;
    padding: 40px 0;
    width: 100%;
    border: 2px dashed #4393ff;
    border-radius: 14px;
    background: #f8fbff;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(67,147,255,0.06);
    transition: background 0.2s, border 0.2s;
   }
   }
</style>
</style>
`);
`);
// Carregar as receitas ao iniciar
document.addEventListener('DOMContentLoaded', cargarReceitas);
</script>
</script>

Edição das 18h46min 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('receitas.json');
   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: 110px;
   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;
   line-height: 1.5em;
   display: flex;
   align-items: center;
   justify-content: center;
   text-align: center;
   font-size: 92%;
   color: #222;
 }
 .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>