/* ===========================================
   APP - casca do Mesas: cabecalho, menu lateral, paineis, barra inferior,
   formularios, modais e toast.
   Reproduz o master.html + os cards do pedido.html do D2Mesas (que usavam
   Tailwind 2 por classe); aqui e CSS proprio, sem o Tailwind de 2,9 MB.
   =========================================== */

.app { min-height: 100vh; min-height: 100svh; background: var(--bg-primary); }

/* ---------------- cabecalho ---------------- */
.topo {
  position: sticky; top: 0; z-index: 30;
  height: 48px;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top, 0px);
  box-sizing: content-box;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--color-header);
  color: #fff;
  font-size: 14px; font-weight: 700;
}
.topo-esq, .topo-dir { display: flex; align-items: center; gap: 10px; }
.topo-menu { font-size: 24px; line-height: 1; cursor: pointer; user-select: none; }
#headertitle { text-transform: uppercase; letter-spacing: .3px; }

.theme-toggle-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
}
.theme-toggle-btn:hover { background: rgba(255,255,255,.15); }

.conn {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: rgba(0,0,0,.25); color: #fff;
}
.conn.online { display: none; }
.conn.offline { background: #b91c1c; }

/* ---------------- menu lateral ---------------- */
.menu-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,.4);
  display: none;
}
.menu-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  width: 256px;
  background: #dbeafe;
  box-shadow: 0 10px 25px rgba(0,0,0,.35);
  transform: translateX(-100%);
  transition: transform .2s ease-out;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
}
html.menu-aberto .menu-drawer { transform: translateX(0); }
html.menu-aberto .menu-overlay { display: block; }

.menu-topo { display: flex; align-items: flex-start; justify-content: space-between; padding: 32px 16px 8px; }
.menu-logo { height: 80px; width: auto; object-fit: contain; margin: 0 auto; }
.menu-fechar { font-size: 28px; line-height: 1; color: #4b5563; cursor: pointer; }
.menu-nav { margin-top: 16px; padding: 0 16px; display: flex; flex-direction: column; gap: 4px; }
.menu-link {
  display: flex; align-items: center; gap: 4px; width: 100%;
  padding: 10px 0; text-align: left;
  color: var(--color-gray-darker); font-weight: 600; font-size: 15px;
}
.menu-link:hover { color: var(--color-primary); }
.menu-link-icon { width: 28px; display: flex; justify-content: center; }
[data-theme="light"] .menu-drawer { background: #ffffff; }

/* ---------------- paineis ---------------- */
.conteudo { position: relative; }
.painel { min-height: calc(100svh - 48px); }
.painel.com-barra { padding-bottom: calc(var(--barra-altura) + 16px + env(safe-area-inset-bottom, 0px)); }
.painel-cinza { background: var(--bg-tertiary); }

.painel-home { display: flex; justify-content: center; padding-top: 40px; }
.logo-fundo { width: 170px; height: auto; margin: 0 auto 24px; }
.logo-login { margin-top: 24px; margin-bottom: 56px; }

/* html.has-token: ha login lembrado, o runtime ainda esta conferindo */
html.has-token #pnl-login { display: none !important; }

.painel-login { display: flex; flex-direction: column; align-items: center; padding: 40px 16px; }
.form-coluna { width: 100%; max-width: 300px; display: flex; flex-direction: column; }
.form-coluna label { color: var(--text-primary); font-weight: 600; margin-bottom: 4px; }
.campo {
  width: 100%;
  padding: 9px 12px; margin-bottom: 16px;
  font-size: 16px;
  color: var(--text-primary);
  background: var(--campo-bg);
  border: 1px solid var(--campo-borda);
  border-radius: 6px;
  outline: none;
}
.campo:focus { border-color: #3b82f6; box-shadow: 0 0 0 1px rgba(59,130,246,.4); }
.btn-primario {
  width: 100%; margin-top: 8px;
  padding: 12px 16px; border-radius: 6px;
  background: #1d4ed8; color: #fff; font-weight: 600; font-size: 14px;
}
.btn-primario:hover { background: #1e40af; }
.btn-primario:disabled { opacity: .6; }
.cfg-info { margin: -8px 0 12px; font-size: 13px; color: var(--text-secondary); }

.lista-vazia { display: flex; justify-content: center; align-items: center; min-height: calc(100svh - 220px); }
.lista-vazia img { width: 256px; opacity: .8; }

.aviso-ilustrativo { text-align: center; color: var(--text-primary); margin: 16px 0; }

/* ---------------- barra inferior (as secoes fixed bottom do original) ---------------- */
.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  min-height: var(--barra-altura);
  padding: 10px 4px calc(10px + env(safe-area-inset-bottom, 0px));
  color: #fff;
  background-color: #111;
  background-image: url('../img/fundo.png');
  background-repeat: repeat;
}
.barra.barra-inicio { justify-content: flex-start; }
.barra > button {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: #fff;
}
.barra.barra-inicio > button { flex: 0 0 16.66%; }
.barra > button img { width: 30px; height: 30px; }
.barra > button img.seta { width: 15px; height: 15px; margin: 7px 0 8px; }
.barra > button span { font-size: 12px; line-height: 1.1; text-align: center; }
.barra > button:active { opacity: .7; }
.barra > button:disabled { opacity: .4; }
.so-largo { display: none !important; }
@media (min-width: 640px) { .so-largo { display: flex !important; } }

/* ---------------- modais ---------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9000;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}
.modal-overlay.is-open { display: flex; animation: modalFade .2s ease; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlide { from { opacity: 0; transform: translateY(-20px) scale(.97); } to { opacity: 1; transform: none; } }

.modal-caixa {
  width: 350px; max-width: calc(100vw - 20px);
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border-color); border-radius: 12px;
  overflow: hidden; box-shadow: var(--shadow-xl);
  animation: modalSlide .25s ease;
}
.modal-topo { padding: 8px 12px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; }
.modal-titulo { flex: 1; font-size: 16px; font-weight: 700; }
.modal-x { font-size: 20px; color: var(--text-muted); padding: 4px 8px; line-height: 1; }
.modal-x:hover { color: var(--color-primary); }
.modal-corpo { padding: 16px 20px; }
.modal-rodape { padding: 8px 12px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 8px; }
.modal-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.modal-input {
  width: 100%; padding: 10px; font-size: 16px;
  color: var(--text-primary); background: var(--bg-card);
  border: 1.5px solid var(--border-color); border-radius: var(--radius-sm); outline: none;
}
.modal-input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(0,102,204,.15); }
.modal-textarea { resize: vertical; min-height: 90px; font-size: 14px; }
.modal-feedback { color: var(--color-danger); font-size: 12px; margin-top: 4px; min-height: 1em; }
.btn-confirmar { background: var(--color-primary); color: #fff; padding: 8px 18px; border-radius: var(--radius-sm); font-size: 14px; }
.btn-confirmar:hover { background: #0052a3; }
.btn-cancelar {
  background: var(--bg-secondary); color: var(--text-secondary);
  border: 1px solid var(--border-color); padding: 8px 18px; border-radius: var(--radius-sm); font-size: 14px;
}
.modal-pergunta { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 24px 20px; }
.modal-pergunta i { font-size: 40px; color: var(--color-warning); }
.modal-pergunta p { margin: 0; font-size: 17px; font-weight: 600; }

.btn-opcao {
  display: block; width: 100%;
  padding: 12px; margin-bottom: 10px;
  border: 1.5px solid; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  transition: background-color var(--transition-fast);
}
.btn-opcao:last-child { margin-bottom: 0; }
.opcao-cancelar { border-color: var(--color-danger); color: var(--color-danger); }
.opcao-cancelar:hover { background: var(--color-danger); color: #fff; }
.opcao-comandar { border-color: var(--color-success); color: var(--color-success); }
.opcao-comandar:hover { background: var(--color-success); color: #fff; }
.opcao-continuar { border-color: var(--color-info); color: var(--color-info); }
.opcao-continuar:hover { background: var(--color-info); color: #fff; }

/* ---------------- toast ---------------- */
#toast-container {
  position: fixed; top: calc(56px + env(safe-area-inset-top, 0px)); right: 12px; left: 12px;
  z-index: 9500; display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: none;
}
.toast-item {
  max-width: 420px; padding: 10px 14px; border-radius: 8px;
  color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
  background: #334155;
  animation: modalSlide .2s ease;
}
.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info { background: #2563eb; }
