/* KDS Vettore Pizzaria
   Cores da marca (manual de identidade): Laranja #ff5a19, Mostarda #feb500, Preto #000.
   Tipografia: Montserrat (usada no manual; Souvenir/Marguerite ficam restritas ao logo). */
:root {
  --brand-orange: #ff5a19;
  --brand-mustard: #feb500;
  --brand-black: #000;

  --bg: #0d0b0a;
  --panel: #191513;
  --panel-2: #241f1c;
  --line: #352e29;
  --text: #f7f2ec;
  --muted: #a39a92;

  --stage1: var(--brand-mustard);   /* montagem */
  --stage2: var(--brand-orange);    /* forno / finalização */
  --takeout: #19c2b0;               /* retirada: cor fora da paleta para destacar */
  --scheduled: #6d7cff;
  --ok: #33c47a;                    /* pronto / sincronizado */
  --warn: var(--brand-mustard);     /* pedido demorando */
  --late: #e8283f;                  /* pedido atrasado */
  --alter: #c77dff;                 /* pedido alterado */
  --info: #4c9bff;
  --note-bg: #3b2c08;
  --note-text: #ffd36b;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 500 16px/1.35 "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
.tabs button, .sync, .icon-btn { white-space: nowrap; }

/* ---------- Topo ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 16px; background: var(--brand-black);
  border-bottom: 3px solid var(--brand-orange);
  box-shadow: 0 3px 0 var(--brand-mustard);
  margin-bottom: 3px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand img { height: 56px; width: auto; display: block; margin: -4px 0; }
.brand-tag {
  font-size: 12px; font-weight: 800; letter-spacing: 2px; color: var(--brand-black);
  background: var(--brand-mustard); border-radius: 4px; padding: 2px 6px;
}
.counts { color: var(--muted); font-size: 14px; }
.counts b { color: var(--text); font-weight: 800; }
.spacer { flex: 1; }
.sync, .icon-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 600;
}
.sync .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.sync.ok .dot { background: var(--ok); }
.sync.error { border-color: var(--late); }
.sync.error .dot { background: var(--late); animation: blink 1s infinite; }
.icon-btn.on { border-color: var(--brand-mustard); color: var(--brand-mustard); }
.clock { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 22px; min-width: 64px; text-align: right; }

.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tabs button { background: none; border: 0; border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 700; color: var(--muted); }
.tabs button.active { background: var(--brand-orange); color: #fff; }

.failures {
  background: #3b1016; color: #ffb3bc; border-bottom: 1px solid var(--late);
  padding: 8px 16px; font-size: 14px;
}
.failures button { background: none; border: 1px solid currentColor; border-radius: 6px; padding: 2px 8px; margin-left: 8px; }

/* ---------- Quadro de pedidos ---------- */
.board {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 1fr 1fr;
}
.board.single { grid-template-columns: 1fr; }
.column { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.column + .column { border-left: 2px solid var(--line); }
.column-title {
  margin: 0; padding: 10px 16px; font-size: 15px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase;
  background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.column-title::before {
  content: ""; width: 0; height: 0; flex: none;
  border-left: 10px solid currentColor; border-top: 7px solid transparent; border-bottom: 7px solid transparent;
}
.column-title.s1 { color: var(--stage1); }
.column-title.s2 { color: var(--stage2); }
.column-title span { color: #000; border-radius: 999px; padding: 0 10px; font-size: 13px; }
.column-title.s1 span { background: var(--stage1); }
.column-title.s2 span { background: var(--stage2); }
.grid {
  flex: 1; overflow-y: auto; padding: 16px;
  display: grid; gap: 16px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  grid-auto-rows: max-content; /* nunca espremer os cards: a coluna rola */
}
.empty {
  grid-column: 1 / -1; text-align: center; color: var(--muted);
  font-size: 18px; font-weight: 600; padding: 60px 16px;
}

/* ---------- Card ---------- */
.card {
  display: flex; flex-direction: column;
  background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius);
  overflow: hidden; min-height: 200px;
}
.card.started { border-color: var(--stage1); }
.card.stage2 { border-color: var(--stage2); }
.card.new { animation: pop .6s ease-out; }
.card.late { animation: late-pulse 1.6s ease-in-out infinite; }

.card-head { padding: 10px 14px; background: var(--panel-2); color: var(--text); }
.card.type-takeout .card-head { background: var(--takeout); color: #031a17; }
.card.scheduled .card-head { background: var(--scheduled); color: #fff; }
.head-row { display: flex; align-items: center; gap: 10px; }
.num { font-size: 30px; font-weight: 900; letter-spacing: -.5px; }
.type {
  font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
  border: 2px solid currentColor; border-radius: 6px; padding: 1px 6px;
}
.card.type-takeout .type { background: #031a17; color: var(--takeout); border-color: #031a17; }
.elapsed {
  margin-left: auto; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums;
  border-radius: 8px; padding: 2px 8px; background: rgba(0, 0, 0, .25);
}
.card.warn .elapsed { background: var(--warn); color: #000; }
.card.late .elapsed { background: var(--late); color: #fff; }
.sub { font-size: 13px; font-weight: 600; opacity: .85; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }

.state {
  font-size: 12px; font-weight: 700; padding: 6px 14px; letter-spacing: .2px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); color: var(--muted);
}
.state.started { color: var(--stage1); }
.state.oven { color: var(--stage2); }
.state.pending { color: var(--info); }
.state.error { color: var(--late); }

.items { list-style: none; margin: 0; padding: 10px 14px; flex: 1; }
.items > li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.items > li:last-child { border-bottom: 0; }
.item-name { font-size: 18px; font-weight: 800; }
.qty { color: var(--brand-orange); font-weight: 900; margin-right: 4px; }
.opts { margin: 4px 0 0 0; padding: 0; list-style: none; font-size: 15px; font-weight: 600; }
.opts li { padding: 1px 0; }
.opts .grp { color: var(--muted); font-size: 13px; font-weight: 500; }
.sub-items { list-style: none; margin: 4px 0 0 14px; padding: 0; border-left: 2px solid var(--line); padding-left: 10px; }
.note {
  margin-top: 6px; background: var(--note-bg); color: var(--note-text);
  border-radius: 6px; padding: 4px 8px; font-weight: 700; font-size: 14px;
}
.order-note { margin: 0 14px 10px; }

.actions { padding: 10px 14px 14px; }
.btn {
  width: 100%; border: 0; border-radius: 10px; padding: 16px;
  font-size: 20px; font-weight: 900; letter-spacing: 1.5px; text-transform: uppercase;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn-start { background: var(--brand-mustard); color: #000; }
.btn-oven { background: var(--brand-orange); color: #fff; }
.btn-ready { background: var(--ok); color: #03170b; }
.link-btn {
  display: block; margin: 8px auto 0; background: none; border: 0;
  color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: underline;
}

/* ---------- Barra de prontos ---------- */
.ready-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--brand-black); border-top: 2px solid var(--ok);
}
.ready-title { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.ready-list { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--ok); border-radius: 999px;
  padding: 4px 6px 4px 12px; font-weight: 800;
}
.chip.error { border-color: var(--late); }
.chip .cd { font-variant-numeric: tabular-nums; color: var(--ok); }
.chip.error .cd { color: var(--late); }
.chip button {
  background: var(--line); border: 0; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700;
}

/* ---------- Avisos ---------- */
.toasts { position: fixed; right: 16px; bottom: 72px; display: flex; flex-direction: column; gap: 8px; z-index: 10; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  background: var(--panel-2); border-left: 5px solid var(--info); border-radius: 8px;
  padding: 12px 14px; font-weight: 700; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.toast.ok { border-left-color: var(--brand-mustard); }
.toast.error { border-left-color: var(--late); }
.toast.alert { border-left-color: var(--alter); }

/* ---------- Pedido alterado / reaberto ---------- */
.card.altered { border-color: var(--alter); box-shadow: 0 0 0 2px var(--alter) inset; }
.badges { display: flex; gap: 6px; padding: 8px 14px 0; flex-wrap: wrap; }
.badge {
  font-size: 12px; font-weight: 900; letter-spacing: .6px;
  border-radius: 6px; padding: 3px 8px;
}
.badge.altered { background: var(--alter); color: #1d0b2e; animation: blink 1.2s 5; }
.badge.reopened { background: var(--info); color: #fff; }
.changes-title {
  margin: 10px 14px 0; font-size: 11px; font-weight: 900; letter-spacing: .8px;
  text-transform: uppercase; color: var(--alter);
}
.changes-empty { margin: 6px 14px 10px; color: var(--muted); font-style: italic; }
.new-tag {
  background: var(--alter); color: #1d0b2e; font-size: 10px; font-weight: 900;
  border-radius: 4px; padding: 1px 5px; margin-right: 6px; vertical-align: middle;
}
.removed { margin: 0 14px 10px; }
.removed .changes-title { margin: 0 0 4px; color: var(--late); }
.removed ul { list-style: none; margin: 0; padding: 0; }
.removed li { text-decoration: line-through; color: #ff9aa6; font-weight: 700; padding: 2px 0; }
.removed li span { font-weight: 500; }
.full-order { margin: 0 14px 10px; color: var(--muted); }
.full-order summary { cursor: pointer; font-size: 13px; font-weight: 600; padding: 4px 0; }
.full-order .items { padding: 0 0 0 4px; opacity: .75; }

/* ---------- Login ---------- */
.login-page {
  align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 90, 25, .18), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(254, 181, 0, .14), transparent 45%),
    var(--bg);
}
.login-box {
  width: min(380px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--brand-orange);
  border-radius: var(--radius); padding: 28px 24px;
}
.login-logo { width: 190px; max-width: 70%; margin: 0 auto 6px; display: block; }
.login-sub { text-align: center; color: var(--brand-mustard); font-size: 12px; font-weight: 800; letter-spacing: 3px; margin: 0 0 8px; }
.login-box label { color: var(--muted); font-size: 13px; font-weight: 700; }
.login-box input[type=password] {
  font: inherit; font-size: 28px; font-weight: 700; letter-spacing: 8px; text-align: center;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
}
.login-box input[type=password]:focus { outline: 2px solid var(--brand-mustard); outline-offset: 1px; }
.login-error { margin: 0; color: var(--late); font-weight: 700; text-align: center; }

@keyframes blink { 50% { opacity: .3; } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes late-pulse { 50% { border-color: var(--late); } }

@media (max-width: 1100px) {
  .topbar { flex-wrap: wrap; }
  .counts { order: 5; width: 100%; }
}
@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; overflow-y: auto; }
  .column { min-height: auto; }
  .column + .column { border-left: 0; border-top: 2px solid var(--line); }
  .grid { overflow: visible; padding: 12px; grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .brand img { height: 38px; }
  .tabs { order: 4; }
}
