/* ==========================================================================
   KDS Crocodilos - tela de cozinha
   Alvo: TV 1080p vista a 2-4 metros. Fontes grandes, alto contraste,
   nada que dependa de hover (nao existe mouse na cozinha).
   CSS proposital sem variaveis aninhadas nem :has(), para rodar tambem
   nos navegadores mais antigos de Smart TV (Chromium 47+).
   ========================================================================== */

:root {
  --bg:          #0d1117;
  --bg-col:      #141a23;
  --bg-card:     #1c2430;
  --bg-card-alt: #222c3a;
  --line:        #2c3746;

  --text:        #eef2f7;
  --text-dim:    #93a1b5;

  --new:    #38bdf8;
  --prep:   #fbbf24;
  --ready:  #4ade80;

  --t-ok:   #4ade80;
  --t-warn: #fbbf24;
  --t-late: #f87171;

  --ifood:   #ea1d2c;
  --anotaai: #25d366;
  --sim:     #64748b;
}

* { box-sizing: border-box; }

/* Regra de autor com display: flex vence o [hidden] da folha do navegador,
   entao o atributo hidden precisa ser reforcado aqui. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Barra superior ---------- */

/* Barra enxuta: cada pixel aqui e pixel a menos para os pedidos. */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  background: #0a0e14;
  border-bottom: 2px solid var(--line);
}

.brand { display: flex; align-items: baseline; }

.brand-mark {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--ready);
}

.brand-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dim);
  margin-left: 10px;
}

/* Espacamento por margem, e nao por gap: flex gap so existe do Chromium 84
   em diante e TVs de 2020-2021 ainda rodam engine anterior a isso. */
.counters { display: flex; }
.counter + .counter { margin-left: 28px; }

.counter {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.counter b {
  display: inline-block;
  min-width: 34px;
  margin-left: 6px;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 20px;
  text-align: center;
  color: #0d1117;
}

.counter-prep b  { background: var(--prep); }
.counter-ready b { background: var(--ready); }

.topbar-right { display: flex; align-items: center; }
.topbar-right > * + * { margin-left: 14px; }

.clock {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.conn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  background: #14532d;
  color: var(--ready);
}

.conn[data-state="off"] {
  background: #7f1d1d;
  color: #fecaca;
}

.btn-sim, .btn-sound {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-sound { font-size: 18px; line-height: 1; }
.btn-sound[aria-pressed="true"] { color: var(--ready); border-color: var(--ready); }

/* ---------- Aviso de queda de conexao ---------- */

.offline-banner {
  padding: 10px;
  background: #7f1d1d;
  color: #fee2e2;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 1px;
}

/* ---------- Quadro de colunas ---------- */

.board {
  display: flex;
  height: calc(100% - 56px);
  padding: 10px;
}

.col + .col { margin-left: 10px; }

.col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: 10px;
  background: var(--bg-col);
  overflow: hidden;
}

/* A cozinha olha "em preparo" o tempo todo; "prontos" e so conferencia na
   saida. Dai a divisao 2:1 em vez de colunas iguais. */
.col-prep  { flex: 2 1 0; }
.col-ready { flex: 1 1 0; }

/* Cards lado a lado na coluna larga, para caber mais pedido sem rolagem.
   Grid gap (Chromium 57+) e seguro aqui; flex gap (84+) e que nao seria. */
.col-body-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 10px;
  align-content: start;
  /* Sem isto o grid estica todo card ate a altura do mais alto da linha,
     criando faixas vazias embaixo dos pedidos curtos. */
  align-items: start;
}

.col-body-grid .card { margin-bottom: 0; }

.col-title {
  margin: 0;
  padding: 12px 16px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  text-align: center;
  color: #0d1117;
}

.col-prep  .col-title { background: var(--prep); }
.col-ready .col-title { background: var(--ready); }

.col-body {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Barra de rolagem visivel, porque o operador pode usar tela de toque */
.col-body::-webkit-scrollbar { width: 10px; }
.col-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }

/* ---------- Card de pedido ---------- */

.card {
  margin-bottom: 12px;
  border-radius: 10px;
  border-left: 8px solid var(--sim);
  background: var(--bg-card);
  overflow: hidden;
}

.card[data-channel="ifood"]   { border-left-color: var(--ifood); }
.card[data-channel="anotaai"] { border-left-color: var(--anotaai); }

.card[data-late="1"] {
  box-shadow: 0 0 0 3px var(--t-late);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-card-alt);
}

.card-id {
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.card-head-right { display: flex; align-items: center; }
.card-head-right > * + * { margin-left: 10px; }

.badge {
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #0d1117;
  background: var(--sim);
}

.badge-ifood   { background: var(--ifood); color: #fff; }
.badge-anotaai { background: var(--anotaai); }
.badge-takeout { background: #a78bfa; }
.badge-sched   { background: #f472b6; }

/* Sem a coluna "Novos", este selo e o que sinaliza pedido recem-chegado.
   Pisca por 2 minutos e some sozinho. */
.badge-novo {
  background: var(--new);
  animation: pulsa-novo 1.1s ease-in-out infinite;
}

@keyframes pulsa-novo {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.card[data-novo="1"] { box-shadow: 0 0 0 3px var(--new); }

/* Atraso manda mais que novidade: se os dois valerem, o card fica vermelho. */
.card[data-late="1"][data-novo="1"] { box-shadow: 0 0 0 3px var(--t-late); }

.timer {
  min-width: 68px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: #0d1117;
  background: var(--t-ok);
}

.timer[data-level="warn"] { background: var(--t-warn); }
.timer[data-level="late"] { background: var(--t-late); }

/* Uma linha so, cortada com reticencias: o endereco quebrando em duas ou tres
   linhas roubava altura de todo card, e quem cozinha nao usa esse dado. */
.card-meta {
  padding: 8px 14px;
  font-size: 15px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta .customer { font-weight: 700; color: var(--text); }

/* ---------- Itens ---------- */

.items { padding: 6px 14px 10px; }

.item {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.item:last-child { border-bottom: 0; }

.item-line { display: flex; align-items: baseline; }
.item-line > * + * { margin-left: 10px; }

.item-qty {
  min-width: 42px;
  padding: 2px 0;
  border-radius: 5px;
  background: var(--line);
  font-size: 20px;
  font-weight: 800;
  text-align: center;
}

.item-name {
  flex: 1;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.25;
}

.opts {
  margin: 4px 0 0 52px;
  padding: 0;
  list-style: none;
}

.opt {
  font-size: 16px;
  color: var(--text-dim);
  line-height: 1.4;
}

.opt::before { content: "+ "; color: var(--ready); font-weight: 700; }

.opt-group { color: #64748b; }

/* Observacao precisa saltar aos olhos: e a causa mais comum de retrabalho */
.note {
  margin: 6px 0 0 52px;
  padding: 5px 10px;
  border-left: 4px solid var(--prep);
  border-radius: 4px;
  background: rgba(251, 191, 36, 0.12);
  font-size: 16px;
  font-weight: 700;
  color: #fde68a;
}

.note-critical {
  border-left-color: var(--t-late);
  background: rgba(248, 113, 113, 0.18);
  color: #fecaca;
}

.order-note {
  margin: 0 14px 10px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.12);
  border-left: 4px solid var(--new);
  font-size: 16px;
  font-weight: 600;
  color: #bae6fd;
}

/* ---------- Rodape do card ---------- */

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-card-alt);
}

.card-foot > * + * { margin-left: 10px; }

.pay { font-size: 14px; color: var(--text-dim); }
.pay b { color: var(--text); font-size: 16px; }
.pay .unpaid { color: var(--t-warn); font-weight: 800; }

.btn-advance {
  padding: 10px 20px;
  border: 0;
  border-radius: 8px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #0d1117;
  cursor: pointer;
}

.btn-advance[data-to="PREPARING"] { background: var(--prep); }
.btn-advance[data-to="READY"]     { background: var(--ready); }
.btn-advance[data-to="DONE"]      { background: var(--text-dim); }

.btn-advance:active { transform: translateY(1px); }

/* ---------- Estado vazio ---------- */

.empty-state {
  position: fixed;
  top: 56px;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  pointer-events: none;
}

.empty-icon { font-size: 80px; opacity: 0.5; }
.empty-state p { font-size: 26px; font-weight: 600; }

/* ---------- Telas menores (tablet de apoio, notebook) ---------- */

@media (max-width: 1100px) {
  .counters { display: none; }
  .card-id  { font-size: 26px; }
  .item-name { font-size: 19px; }
}

@media (max-width: 760px) {
  .board { flex-direction: column; height: auto; overflow-y: auto; }
  html, body { overflow: auto; }
}

/* ---------- TV: tipografia maior a partir de 1080p ----------
   A TV fica a 2-4 metros da bancada, entao o corpo de texto que serve num
   monitor de mesa fica pequeno demais aqui. */

@media (min-width: 1600px) {
  .col-title  { font-size: 24px; padding: 10px 16px; }

  .card-id    { font-size: 40px; }
  .timer      { font-size: 28px; min-width: 88px; }
  .badge      { font-size: 15px; padding: 4px 11px; }

  .card-meta  { font-size: 19px; }
  .order-note { font-size: 20px; }

  .item-qty   { font-size: 27px; min-width: 60px; }
  .item-name  { font-size: 28px; }
  .opts       { margin-left: 70px; }
  .opt        { font-size: 21px; }
  .note       { font-size: 21px; margin-left: 70px; }

  .pay        { font-size: 18px; }
  .pay b      { font-size: 21px; }

  .btn-advance { font-size: 22px; padding: 13px 30px; }
}
