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

De Wiki Gla
Ir para navegação Ir para pesquisar
Linha 1: Linha 1:
<h3>🛒 Carrinho de Compras</h3>
<div id="carrinho-container"></div>
<div id="carrinho-container"></div>
<div id="carrinho-total" style="font-weight: bold; margin-top: 10px;"></div>
<div style="margin-top: 20px; display: flex; gap: 10px;">
  <button id="esvaziar-carrinho" class="acao-carrinho">Esvaziar Carrinho</button>
  <button id="mostrar-total" class="acao-carrinho">Mostrar Total</button>
</div>
<div id="resumo-total" style="margin-top: 20px;"></div>


<script>
<script>
const carrinho = {};
let receitasSelecionadas = {
  0: null,
  1: null
};
let receitas = {};
let receitas = {};
const berryGif = "https://wiki.gla.com.br/images/thumb/d/d1/Berrynewgif.gif/32px-Berrynewgif.gif";
const berryGif = "https://wiki.gla.com.br/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
// Função para carregar as receitas a partir do JSON
Linha 70: Linha 92:
         data-lvl="${receita.lvl}"
         data-lvl="${receita.lvl}"
         data-tempo="${receita.tempo}">i</button>
         data-tempo="${receita.tempo}">i</button>
       <img src="${receita.img}" width="64" height="64" />
       <img src="${receita.img}" width="48" height="48" />
       <div class="receita-nome">${receita.nome}</div>
       <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>
       <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="adicionarAoCarrinho('${receita.id}')"></button>
       <button class="add-to-cart-btn" onclick="selecionarReceita('${receita.id}')">Selecionar</button>
     `;
     `;
     container.appendChild(card);
     container.appendChild(card);
Linha 109: Linha 131:
     setTimeout(() => modal.remove(), 300);
     setTimeout(() => modal.remove(), 300);
   }
   }
}
// Funções do carrinho
function adicionarAoCarrinho(id) {
  const receita = encontrarReceita(id);
  if (!receita) return;
  if (!carrinho[id]) {
    carrinho[id] = { ...receita, quantidade: 1 };
  } else {
    carrinho[id].quantidade++;
  }
  const receitaCard = document.querySelector(`[data-id="${id}"]`);
  if (receitaCard) {
    receitaCard.style.backgroundColor = 'lightgreen';
  }
  renderizarCarrinho();
}
}


Linha 136: Linha 141:
}
}


function alterarQuantidade(id, alteracao) {
function renderizarSelecao() {
   if (alteracao === 100) {
   const container = document.getElementById('carrinho-container');
    carrinho[id].quantidade = 100;
   container.innerHTML = '';
  } else {
    carrinho[id].quantidade += alteracao;
   }
  if (carrinho[id].quantidade <= 0) {
    carrinho[id].quantidade = 1;
  }
  renderizarCarrinho();
}


function esvaziarCarrinho() {
   let totalSlots = 2;
   for (const id in carrinho) {
    delete carrinho[id];
    const receitaCard = document.querySelector(`[data-id="${id}"]`);
    if (receitaCard) {
      receitaCard.style.backgroundColor = '';
    }
  }
  renderizarCarrinho();
  const detalhesContainer = document.getElementById('detalhes-carrinho');
  if (detalhesContainer) {
    detalhesContainer.innerHTML = '';
  }
}


function mostrarTotal() {
  for (let i = 0; i < totalSlots; i++) {
  let detalhesContainer = document.getElementById('detalhes-carrinho');
    const receita = receitasSelecionadas[i];
  const resumoTotal = document.getElementById('resumo-total');


  if (!detalhesContainer) {
     const itemDiv = document.createElement('div');
     detalhesContainer = document.createElement('div');
     itemDiv.className = 'item-carrinho';
     detalhesContainer.id = 'detalhes-carrinho';
    detalhesContainer.style.marginTop = '20px';
    resumoTotal.appendChild(detalhesContainer);
  } else {
    detalhesContainer.innerHTML = '';
  }


  detalhesContainer.innerHTML += '<h3>📦 Ingredientes Totais Necessários:</h3>';
    if (receita) {
      const subtotal = receita.preco * receita.quantidade;
      tempo = formatarTempo(receita.tempo);


  const ingredientesContainer = document.createElement('div');
      const ingredientesHtml = receita.ingredientes.map(([nome, qtd]) => {
  ingredientesContainer.style.display = 'flex';
        const totalIngrediente = qtd * receita.quantidade;
  ingredientesContainer.style.flexWrap = 'wrap';
        return `<div>${nome}: ${totalIngrediente}</div>`;
  ingredientesContainer.style.gap = '10px';
      }).join('');


  for (const id in carrinho) {
      itemDiv.innerHTML = `
     const item = carrinho[id];
        <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>`;
    }


     if (!item.ingredientes || item.ingredientes.length === 0) continue;
     container.appendChild(itemDiv);
 
    const ingredientesMultiplicados = {};
    item.ingredientes.forEach(([nome, quantidade]) => {
      if (!ingredientesMultiplicados[nome]) ingredientesMultiplicados[nome] = 0;
      ingredientesMultiplicados[nome] += quantidade * item.quantidade;
    });
 
    const receitaDiv = document.createElement('div');
    receitaDiv.className = 'detalhe-receita';
    receitaDiv.style.border = '1px solid #ccc';
    receitaDiv.style.padding = '10px';
    receitaDiv.style.borderRadius = '8px';
    receitaDiv.style.backgroundColor = '#fff';
    receitaDiv.style.width = '250px';
 
    receitaDiv.innerHTML = `
      <h4>${item.quantidade}x ${item.nome}</h4>
      <img src="${item.img}" width="64" height="64" style="display: block; margin-bottom: 10px;" />
      <strong>🥣 Ingredientes:</strong>
      <div class="ingredientes-grid">
        ${Object.entries(ingredientesMultiplicados).map(([nome, qtd]) => `
          <div class="ingrediente-item">${qtd}x ${nome}</div>
        `).join('')}
      </div>
      <div><strong>Total da Receita:</strong> ${(item.preco * item.quantidade).toLocaleString()} <img src="${berryGif}" alt="Berry" width="25" height="25" style="transform: translateY(-1px);"/></div>
    `;
 
    ingredientesContainer.appendChild(receitaDiv);
   }
   }
  detalhesContainer.appendChild(ingredientesContainer);
}
}


function calcularTotal() {
function alterarQuantidadeSelecionada(index, alteracao) {
   return Object.values(carrinho).reduce((sum, item) => sum + (item.preco * item.quantidade), 0);
   const receita = receitasSelecionadas[index];
  if (!receita) return;
  receita.quantidade += alteracao;
  if (receita.quantidade < 1) receita.quantidade = 1;
  renderizarSelecao();
}
}


function atualizarQuantidadeManual(id, event) {
function atualizarQuantidadeManualSelecionada(index, event) {
   const novoValor = parseInt(event.target.value);
   const valor = parseInt(event.target.value);
   if (novoValor <= 0) {
   if (valor && valor >= 1) {
    carrinho[id].quantidade = 1;
     receitasSelecionadas[index].quantidade = valor;
  }
     renderizarSelecao();
  if (!isNaN(novoValor) && novoValor >= 1) {
     carrinho[id].quantidade = novoValor;
     renderizarCarrinho();
   }
   }
}
}


function renderizarCarrinho() {
function definir100Selecionada(index) {
   const container = document.getElementById('carrinho-container');
   if (receitasSelecionadas[index]) {
  container.innerHTML = '';
     receitasSelecionadas[index].quantidade = 100;
  let total = 0;
     renderizarSelecao();
 
  for (const id in carrinho) {
     const item = carrinho[id];
    const subtotal = item.preco * item.quantidade;
    total += subtotal;
 
    const itemDiv = document.createElement('div');
    itemDiv.className = 'item-carrinho';
    itemDiv.innerHTML = `
      <img src="${item.img}" width="40" height="40" />
      <div class="info-carrinho">
        <div class="nome-item">${item.nome}</div>
        <div class="controle-quantidade">
          <button onclick="alterarQuantidade('${id}', -1)">−</button>
          <input type="number" value="${item.quantidade}" min="1"
                onchange="atualizarQuantidadeManual('${id}', event)">
          <button onclick="alterarQuantidade('${id}', 1)">+</button>
          <button class="btn-100" onclick="alterarQuantidade('${id}', 100)">x100</button>
        </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="removerDoCarrinho('${id}')">🗑️</button>
    `;
     container.appendChild(itemDiv);
   }
   }
}


  document.getElementById('carrinho-total').innerHTML = total > 0
function removerReceitaSelecionada(index) {
    ? `Total: ${total.toLocaleString()} <img src="${berryGif}" alt="Berry" width="25" height="25" style="transform: translateY(-1px);" />`
  receitasSelecionadas[index] = null;
    : '';
  renderizarSelecao();
}
}


function removerDoCarrinho(id) {
function formatarTempo(minutosDecimal) {
   delete carrinho[id];
   const minutosInt = Math.floor(minutosDecimal);
   const receitaCard = document.querySelector(`[data-id="${id}"]`);
   const segundos = Math.round((minutosDecimal % 1) * 60);
   if (receitaCard) {
 
     receitaCard.style.backgroundColor = '';
  if (minutosInt < 1) {
    return `${segundos}seg`;
   } else if (segundos === 0) {
     return `${minutosInt}min`;
  } else {
    return `${minutosInt}min ${segundos.toString().padStart(2, '0')}seg`;
   }
   }
  renderizarCarrinho();
}
}


// Botões
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('esvaziar-carrinho').addEventListener('click', esvaziarCarrinho);
  renderizarSelecao();
document.getElementById('mostrar-total').addEventListener('click', mostrarTotal);
});
 


// CSS
// CSS
Linha 292: Linha 246:
     gap: 16px;
     gap: 16px;
     margin-bottom: 24px;
     margin-bottom: 24px;
    justify-content: center;
   }
   }
   .nome-item, .subtotal{
   .nome-item, .subtotal{
Linha 298: Linha 253:
    
    
   .receita-card {
   .receita-card {
     width: 150px;
     width: 96px;
     text-align: center;
     text-align: center;
     border: 1px solid #ccc;
     border: 1px solid #ccc;
Linha 304: Linha 259:
     padding: 8px;
     padding: 8px;
     background-color: #fff;
     background-color: #fff;
     box-shadow: 2px 2px 4px rgba(0,0,0,0.1);
     box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
     transition: transform 0.2s;
     transition: transform 0.2s;
     user-select: none;
     user-select: none;
Linha 373: Linha 328:
     font-weight: bold;
     font-weight: bold;
     margin: 4px 0;
     margin: 4px 0;
     min-height: 3em; /* força ocupar duas linhas mesmo se o texto for curto */
     min-height: 3em;
     line-height: 1.5em;
     line-height: 1.5em;
     display: flex;
     display: flex;
Linha 379: Linha 334:
     justify-content: center;
     justify-content: center;
     text-align: center;
     text-align: center;
    font-size: 88%;
  }
  .nome-item{
    font-weight: bold;
  }
  .ingredientes{
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Fuerza 2 columnas */
    gap: 8px;
    margin-top: 5px;
    margin-bottom: 10px;
  }
  .ingredientes div {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 14px;
    text-align: center;
    white-space: normal;
    overflow: hidden;
    text-overflow: unset;
    overflow-wrap: break-word;
    align-content: center;
   }
   }


   .receita-preco {
   .receita-preco {
     margin-bottom: 6px;
     margin-bottom: 2px;
   }
   }
    
    
   .item-carrinho {
   .item-carrinho {
     display: flex;
     display: flex;
    align-items: center;
     gap: 12px;
     gap: 12px;
     padding: 8px;
     padding: 8px;
Linha 393: Linha 373:
     border-radius: 8px;
     border-radius: 8px;
     margin-bottom: 8px;
     margin-bottom: 8px;
     width: 20.5%;
     width: 44.5%;
     margin-right: 1%;
     margin-inline: 1%;
    flex-direction: column;
    align-items: center;
    height: fit-content;
    min-height: 97%;
   }
   }
    
    
   .info-carrinho {
   .info-carrinho {
     flex: 1;
     flex: 1;
    justify-items: center;
   }
   }
    
    
Linha 405: Linha 390:
     align-items: center;
     align-items: center;
     gap: 4px;
     gap: 4px;
     margin-top: 4px;
     margin-top: 2%;
    margin-bottom: 5%;
   }
   }
    
    
Linha 431: Linha 417:
     cursor: pointer;
     cursor: pointer;
     font-size: 16px;
     font-size: 16px;
  }
  .ingredientes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Fuerza 2 columnas */
    gap: 8px;
    margin-top: 5px;
    margin-bottom: 10px;
  }
  .ingrediente-item {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 14px;
    text-align: center;
    white-space: normal;
    overflow: hidden;
    text-overflow: unset;
    overflow-wrap: break-word;
    align-content: center;
   }
   }
    
    
Linha 470: Linha 435:
     display: flex;
     display: flex;
     flex-direction: row;
     flex-direction: row;
     flex-wrap: wrap;
     flex-wrap: nowrap;
    justify-content: center;
    width: 69%;
   }
   }


Linha 488: Linha 455:
     width: 16%;
     width: 16%;
     justify-items: anchor-center;
     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: 1px solid #ccc;
    padding: 10px;
    border-radius: 8px;
  }
  .full-receitas {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
   }
   }


   @media screen and (max-width: 1366px) {
   @media screen and (max-width: 1366px) {
     .item-carrinho {
     .item-carrinho {
       width: 29.3%;
       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;
   }
   }



Edição das 01h43min de 12 de abril de 2025

<script> let receitasSelecionadas = {

 0: null,
 1: null

}; let receitas = {}; const berryGif = "https://wiki.gla.com.br/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);
     const ingredientesHtml = receita.ingredientes.map(([nome, qtd]) => {
       const totalIngrediente = qtd * receita.quantidade;

return `

${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>

 .receitas-container {
   display: flex;
   flex-wrap: wrap;
   gap: 16px;
   margin-bottom: 24px;
   justify-content: center;
 }
 .nome-item, .subtotal{
   user-select: none;
 }
 
 .receita-card {
   width: 96px;
   text-align: center;
   border: 1px solid #ccc;
   border-radius: 8px;
   padding: 8px;
   background-color: #fff;
   box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
   transition: transform 0.2s;
   user-select: none;
   position: relative;
 }
 .modal-overlay {
   position: fixed;
   top: 0;
   left: 0;
   right: 0;
   bottom: 0;
   background-color: rgba(0, 0, 0, 0.5);
   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-color: white;
   padding: 20px;
   border-radius: 8px;
   width: 300px;
   position: relative;
   box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
 }
 .close-modal {
   position: absolute;
   top: 10px;
   right: 10px;
   font-size: 20px;
   cursor: pointer;
   background: none;
   border: none;
 }
 .info-btn {
   position: absolute;
   top: 5px;
   right: 5px;
   background: #4393ff;
   color: white;
   border: none;
   border-radius: 50%;
   width: 20px;
   height: 20px;
   font-size: 12px;
   cursor: pointer;
   display: flex;
   justify-content: center;
   align-items: center;
 }
 .receita-card:hover {
   transform: scale(1.05);
 }
 .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: 88%;
 }
 .nome-item{
   font-weight: bold;
 }
 .ingredientes{
   display: grid;
   grid-template-columns: repeat(2, 1fr); /* Fuerza 2 columnas */
   gap: 8px;
   margin-top: 5px;
   margin-bottom: 10px;
 }
 .ingredientes div {
   background-color: #f9f9f9;
   border: 1px solid #ddd;
   border-radius: 4px;
   padding: 6px 8px;
   font-size: 14px;
   text-align: center;
   white-space: normal;
   overflow: hidden;
   text-overflow: unset;
   overflow-wrap: break-word;
   align-content: center;
 }
 .receita-preco {
   margin-bottom: 2px;
 }
 
 .item-carrinho {
   display: flex;
   gap: 12px;
   padding: 8px;
   border: 1px solid #ccc;
   border-radius: 8px;
   margin-bottom: 8px;
   width: 44.5%;
   margin-inline: 1%;
   flex-direction: column;
   align-items: center;
   height: fit-content;
   min-height: 97%;
 }
 
 .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: 50px;
   text-align: center;
   padding: 2px;
 }
 
 .controle-quantidade button {
   width: 24px;
   height: 24px;
 }
 
 .btn-100 {
   width: auto !important;
   padding: 0 4px;
   margin-left: 4px;
   font-size: 12px;
 }
 
 .remover-item {
   background: none;
   border: none;
   cursor: pointer;
   font-size: 16px;
 }
 
 .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: lightgreen;
 }
 .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: 1px solid #ccc;
   padding: 10px;
   border-radius: 8px;
 }
 .full-receitas {
   display: flex;
   flex-direction: row;
   flex-wrap: nowrap;
 }
 @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>