:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --borda: #e3e7ed;
  --texto: #1b2430;
  --muted: #6b7585;
  --primaria: #2457d6;
  --primaria-escura: #1b44aa;
  --verde: #0f9d58;
  --verde-escuro: #0b7a43;
  --vermelho: #c93a3a;
  --raio: 12px;
  --sombra: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--texto);
  padding: 20px;
  line-height: 1.4;
}
button, input { font-family: inherit; }

/* Cabeçalho */
header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 14px 20px; margin-bottom: 16px; box-shadow: var(--sombra);
}
header > div { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h1 { font-size: 1.25rem; font-weight: 700; }
.admin-link {
  color: var(--texto); text-decoration: none; border: 1px solid var(--borda);
  padding: 7px 14px; border-radius: 8px; background: #fff; font-size: 0.92rem; font-weight: 600;
}
.admin-link:hover { background: #f3f6fd; border-color: #c9d3ea; }

.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; background: #eef0f4; color: var(--muted);
}
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.aberto { background: #e6f6ee; color: var(--verde-escuro); }
.pill.fechado { background: #fdeceb; color: var(--vermelho); }

.instrucao { margin-bottom: 14px; color: var(--muted); }

.aviso-caixa {
  background: #fff6dc; border: 1px solid #f3dd97; color: #7a5a00;
  padding: 12px 16px; border-radius: 10px; margin-bottom: 16px;
}

/* Layout: bebidas à esquerda, pedido à direita */
.layout { display: grid; grid-template-columns: 1fr 350px; gap: 16px; align-items: start; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.bebida-btn {
  position: relative; min-height: 96px;
  background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px;
  cursor: pointer; display: flex; flex-direction: column; gap: 10px; text-align: left;
  font-size: 1rem; color: var(--texto); box-shadow: var(--sombra);
  transition: transform 0.08s, border-color 0.12s, box-shadow 0.12s;
}
.bebida-btn:hover:not(:disabled) { border-color: var(--primaria); box-shadow: 0 2px 10px rgba(36, 87, 214, 0.16); }
.bebida-btn:active:not(:disabled) { transform: scale(0.98); }
.bebida-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.bebida-btn .nome { font-weight: 600; font-size: 1.02rem; padding-right: 26px; }
.bebida-btn .preco { color: var(--verde-escuro); font-weight: 700; font-size: 1.2rem; margin-top: auto; }
.bebida-btn .badge {
  position: absolute; top: 10px; right: 10px; min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 12px; background: var(--primaria); color: #fff; font-size: 0.85rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* Painel do pedido */
.carrinho {
  background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 18px;
  position: sticky; top: 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--sombra);
}
.carrinho h2 { font-size: 1.1rem; }
.carrinho-vazio { color: var(--muted); font-size: 0.95rem; padding: 6px 0; }
.carrinho-item { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; border-bottom: 1px solid #eef0f4; }
.carrinho-nome { display: flex; flex-direction: column; }
.carrinho-nome span { font-weight: 600; }
.carrinho-nome small { color: var(--muted); }
.carrinho-qtd-controle { display: flex; align-items: center; gap: 6px; }
.carrinho-qtd-controle input {
  width: 58px; padding: 7px; text-align: center; border: 1px solid var(--borda); border-radius: 8px; font-size: 1rem;
}
.qtd-btn {
  width: 38px; height: 38px; font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--texto);
  border: 1px solid var(--borda); border-radius: 8px; background: #f8f9fb;
}
.qtd-btn:hover { background: #eef3ff; border-color: #c9d3ea; }
.qtd-btn.remover { margin-left: auto; color: var(--vermelho); }
.carrinho-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 4px; }
.carrinho-total span { color: var(--muted); }
.carrinho-total strong { font-size: 1.5rem; color: var(--verde-escuro); }

.btn-principal {
  padding: 14px; font-size: 1.05rem; font-weight: 700; cursor: pointer;
  border: none; border-radius: 10px; background: var(--primaria); color: #fff;
}
.btn-principal:hover:not(:disabled) { background: var(--primaria-escura); }
.btn-principal:disabled { background: #b4c2e3; cursor: not-allowed; }
.btn-secundario {
  padding: 10px; cursor: pointer; border: 1px solid var(--borda); border-radius: 10px; background: #fff; color: var(--texto);
}
.btn-secundario:hover { background: #f3f6fd; }
.btn-link { background: none; border: none; color: var(--primaria); cursor: pointer; text-decoration: underline; padding: 4px; }

@media (max-width: 800px) {
  body { padding: 12px; }
  .layout { grid-template-columns: 1fr; }
  .carrinho { position: static; }
}

.hidden { display: none !important; }

/* Modal de forma de pagamento */
.modal {
  position: fixed; inset: 0; background: rgba(16, 24, 40, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-conteudo {
  background: #fff; border-radius: 14px; padding: 24px; width: 90%; max-width: 410px;
  text-align: center; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  max-height: 92vh; overflow-y: auto;
}
#modal-formas, #modal-dinheiro { display: flex; flex-direction: column; gap: 10px; }
#modal-dinheiro label { font-weight: 600; text-align: left; }
#valor-recebido {
  width: 100%; padding: 12px; font-size: 1.5rem; text-align: center; font-weight: 700;
  border: 2px solid var(--borda); border-radius: 10px;
}
#valor-recebido:focus { outline: 3px solid rgba(36, 87, 214, 0.2); border-color: var(--primaria); }
.atalhos-valor { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.atalhos-valor button {
  padding: 10px 14px; border: 1px solid var(--borda); border-radius: 8px; background: #f8f9fb;
  cursor: pointer; font-weight: 600; font-size: 0.95rem; color: var(--texto);
}
.atalhos-valor button:hover { background: #eef3ff; border-color: var(--primaria); }
.troco-box {
  display: flex; justify-content: space-between; align-items: baseline;
  background: #e6f6ee; border-radius: 10px; padding: 12px 16px;
}
.troco-box span { color: var(--verde-escuro); font-weight: 600; }
.troco-box strong { font-size: 1.9rem; color: var(--verde-escuro); }
.troco-box.invalido { background: #eef0f4; }
.troco-box.invalido span, .troco-box.invalido strong { color: var(--muted); }
.troco-aviso { color: var(--vermelho); font-weight: 600; }

/* Aviso do troco após concluir a venda em dinheiro */
.aviso-troco {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--verde-escuro); color: #fff; border-radius: var(--raio);
  padding: 14px 20px; margin-bottom: 16px; box-shadow: var(--sombra);
}
.aviso-troco span { display: block; font-size: 0.92rem; opacity: 0.92; }
.aviso-troco strong { display: block; font-size: 1.9rem; line-height: 1.2; }
.aviso-troco button {
  padding: 10px 16px; font-weight: 700; cursor: pointer; border: none; border-radius: 8px;
  background: #fff; color: var(--verde-escuro); font-size: 0.95rem;
}
.aviso-troco button:hover { background: #e6f6ee; }
.modal-resumo { text-align: left; color: var(--texto); max-height: 160px; overflow-y: auto; background: #f8f9fb; border-radius: 8px; padding: 10px 12px; }
.modal-preco { font-weight: 700; font-size: 1.15rem; color: var(--verde-escuro); margin-bottom: 4px; }
.modal-botoes { display: flex; flex-direction: column; gap: 8px; }
.modal-botoes button {
  padding: 13px; font-size: 1rem; font-weight: 600; border: 1px solid var(--borda); border-radius: 10px;
  background: #f8f9fb; cursor: pointer; color: var(--texto);
}
.modal-botoes button:hover { background: #eef3ff; border-color: var(--primaria); }
.modal-cancelar { margin-top: 4px; background: none; border: none; color: var(--muted); cursor: pointer; }

/* Área de impressão fica escondida na tela normal */
.ficha-print { display: none; }

/* ------------------------------------------------------------ */
/* Impressão térmica                                             */
/* Padrão: bobina de 80mm. Para 58mm, troque "width: 80mm"       */
/* por "width: 58mm" abaixo e ajuste as fontes se necessário.    */
/* Cada ficha ocupa uma "página": assim a impressora térmica     */
/* corta (ou separa) uma ficha por vez.                          */
/* ------------------------------------------------------------ */
@media print {
  html, body { background: #fff; padding: 0; margin: 0; }
  body > *:not(#ficha-print) { display: none !important; }

  .ficha-print { display: block; width: 80mm; /* ajuste para 58mm se sua bobina for menor */ }

  .ficha-content {
    padding: 4mm; text-align: center;
    break-after: page; page-break-after: always;
  }
  .ficha-content:last-child { break-after: auto; page-break-after: auto; }

  .ficha-content h2 { font-size: 14pt; margin-bottom: 4mm; }
  .ficha-item { font-size: 16pt; font-weight: bold; margin-bottom: 2mm; }
  .ficha-preco { font-size: 14pt; margin-bottom: 2mm; }
  .ficha-pagamento { font-size: 11pt; margin-bottom: 2mm; }
  .ficha-data { font-size: 10pt; margin-bottom: 2mm; }
  .ficha-numero { font-size: 10pt; border-top: 1px dashed #000; padding-top: 2mm; }

  @page { margin: 0; }
}
