/* SincroPOS — tema oscuro táctil */
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273549;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #0ea5e9;
  --accent-dark: #0284c7;
  --green: #22c55e;
  --green-dark: #16a34a;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
input, textarea, select { user-select: text; }

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--text);
  background: var(--panel-2);
  transition: filter .1s, transform .05s;
}
button:active { transform: scale(.97); filter: brightness(1.15); }
button:disabled { opacity: .4; pointer-events: none; }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

.btn { padding: 14px 20px; font-size: 16px; font-weight: 600; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-green { background: var(--green-dark); color: #fff; }
.btn-red { background: transparent; border: 1px solid var(--red); color: var(--red); }
.btn-ghost { background: transparent; border: 1px solid var(--border); }

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at top, #1e3a5f 0%, var(--bg) 60%);
}
.login-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 20px; padding: 40px; width: 380px; max-width: 92vw;
  display: flex; flex-direction: column; gap: 16px;
}
.login-card h1 { font-size: 26px; text-align: center; }
.login-card h1 span { color: var(--accent); }
.login-card .error { color: var(--red); font-size: 14px; text-align: center; min-height: 18px; }

/* ---------- Layout caja ---------- */
.caja {
  display: grid;
  grid-template-rows: 60px 1fr;
  height: 100vh;
  overflow: hidden;
}
.topbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  padding: 0 14px;
}
.topbar .brand { font-weight: 700; font-size: 18px; white-space: nowrap; }
.topbar .brand span { color: var(--accent); }
.topbar .spacer { flex: 1; }
.chip {
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 999px; font-size: 14px; white-space: nowrap;
}
.chip.ok { border-color: var(--green); color: var(--green); }
.chip.warn { border-color: var(--amber); color: var(--amber); }
.badge {
  background: var(--red); color: #fff; border-radius: 999px;
  font-size: 12px; padding: 1px 8px; margin-left: 6px; font-weight: 700;
}

.main {
  display: grid;
  grid-template-columns: 1fr 470px;
  overflow: hidden;
}
/* En pantallas chicas (tablet) el catálogo necesita el espacio */
@media (max-width: 1100px) { .main { grid-template-columns: 1fr 370px; } }

/* ---------- Panel catálogo ---------- */
.catalogo { display: flex; flex-direction: column; overflow: hidden; padding: 12px; gap: 10px; }
.cat-header { display: flex; align-items: center; gap: 10px; }
.cat-header h2 { font-size: 18px; flex: 1; text-align: center; }
.btn-volver { padding: 12px 22px; font-size: 16px; background: var(--amber); color: #111; font-weight: 700; }
.grid-botones {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  overflow-y: auto;
  align-content: start;
  padding-bottom: 20px;
}
.btn-cat, .btn-prod {
  min-height: 86px; padding: 10px; font-size: 16px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  text-transform: uppercase;
}
.btn-cat { border-left: 5px solid var(--accent); font-size: 17px; }
.btn-prod .precio { color: var(--accent); font-size: 15px; font-weight: 600; }

/* ---------- Panel pedido ---------- */
.pedido {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border-left: 1px solid var(--border);
}
/* La cabecera se mantiene lo más baja posible: cada píxel que gasta aquí es
   una línea menos de pedido visible, que es lo que el cajero necesita leer. */
.pedido-head { padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.pedido-head .fila { display: flex; gap: 8px; align-items: center; }
.pedido-head input { padding: 9px 12px; }
.pedido-num { font-weight: 700; color: var(--amber); white-space: nowrap; font-size: 14px; }
.btn-mini {
  flex: 0 0 auto; width: 44px; height: 40px; font-size: 18px;
  border: 1px solid var(--border); border-radius: 10px;
}
.btn-mini.activo { background: var(--accent); color: #fff; border-color: var(--accent); }

.fila-puestos { display: flex; gap: 8px; align-items: flex-start; }
.puestos { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.puesto-chip {
  min-width: 50px; height: 42px; border-radius: 10px; font-size: 16px; font-weight: 700;
  border: 1px solid var(--border);
}
.puesto-chip.activo { background: var(--accent); color: #fff; border-color: var(--accent); }

.btn-canal {
  flex: 0 0 auto; padding: 0 12px; height: 42px; font-size: 15px; font-weight: 700;
  background: transparent; border: 2px dashed var(--border); color: var(--muted);
  white-space: nowrap;
}
.btn-canal.activo {
  background: var(--amber); color: #111; border: 2px solid var(--amber); border-style: solid;
}

/* Lista del pedido: letra grande (el cajero la lee de lejos para repetir lo
   que pidió el cliente) pero filas bajas, para que quepan ~10-12 renglones. */
.items { flex: 1; overflow-y: auto; padding: 0 6px; scrollbar-width: thin; }
.items::-webkit-scrollbar { width: 10px; }
.items::-webkit-scrollbar-thumb { background: var(--panel-2); border-radius: 8px; }
.item-row {
  display: grid; grid-template-columns: 38px 1fr auto auto; gap: 8px;
  align-items: center; padding: 5px 4px;
  border-bottom: 1px solid var(--border);
}
.item-row.sin-puestos { grid-template-columns: 1fr auto auto; }

.menu-vacio {
  grid-column: 1 / -1; text-align: center; padding: 48px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.menu-vacio p { font-size: 17px; }
.menu-vacio .btn { min-height: 54px; padding: 0 28px; }
.item-row .p-badge {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; text-align: center; padding: 6px 0; font-weight: 700; font-size: 13px;
}
.item-row .nombre { font-size: 17px; font-weight: 700; line-height: 1.15; }
.item-row .nombre .dom { color: var(--amber); font-weight: 700; }
.item-row .cant { display: flex; align-items: center; gap: 4px; }
.item-row .cant button {
  width: 34px; height: 34px; font-size: 18px; font-weight: 700; border-radius: 9px;
}
.item-row .total { font-weight: 700; text-align: right; min-width: 74px; font-size: 16px; }
.item-row .del { color: var(--red); background: transparent; font-size: 17px; width: 32px; height: 34px; }
.item-row.pendiente { background: rgba(14,165,233,.07); }
/* Barra verde = ya salió para la cocina (borrarlo pide confirmación) */
.item-row.comandado { box-shadow: inset 3px 0 0 var(--green); }
.items .vacio { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 15px; }

.pedido-footer { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.total-grande { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.total-grande > span:first-of-type { flex: 1; font-weight: 600; }
.total-grande .valor { font-size: 32px; font-weight: 800; color: var(--green); }
.btn-limpiar {
  flex: 0 0 auto; width: 38px; height: 38px; font-size: 16px; border-radius: 10px;
  background: transparent; border: 1px solid var(--red); color: var(--red);
}
.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acciones .btn { min-height: 56px; font-size: 17px; }
.acciones .full { grid-column: 1 / -1; }

/* ---------- Modales ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  width: 560px; max-width: 94vw; max-height: 92vh; overflow-y: auto;
  padding: 20px; display: flex; flex-direction: column; gap: 14px;
}
.modal h3 { font-size: 20px; }
.modal .fila { display: flex; gap: 10px; align-items: center; }
.modal .fila > * { flex: 1; }
.modal-close { position: sticky; float: right; background: transparent; font-size: 22px; color: var(--muted); }

.medios-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-medio { min-height: 56px; font-size: 16px; font-weight: 700; border: 1px solid var(--border); }
.btn-medio.activo { background: var(--accent); color: #fff; }
.billetes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.billetes button { min-height: 48px; font-weight: 700; }
.cambio-linea { display: flex; justify-content: space-between; font-size: 18px; font-weight: 700; }
.cambio-linea .ok { color: var(--green); }
.cambio-linea .falta { color: var(--red); }

.lista-abiertos { display: flex; flex-direction: column; gap: 8px; }
.pedido-abierto {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  text-align: left; padding: 14px; border: 1px solid var(--border);
}
.pedido-abierto .num { color: var(--amber); font-weight: 800; font-size: 17px; }
.pedido-abierto .tot { font-weight: 700; color: var(--green); }

table.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tabla th, table.tabla td { padding: 8px; border-bottom: 1px solid var(--border); text-align: left; }
table.tabla td.num, table.tabla th.num { text-align: right; }

/* ---------- Impresión 80mm ---------- */
#print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area {
    display: block !important;
    position: absolute; left: 0; top: 0;
    width: 72mm;
    color: #000; background: #fff;
    font-family: 'Courier New', monospace;
    font-size: 11px;
  }
  @page { margin: 2mm; size: 80mm auto; }
}
#print-area .t-center { text-align: center; }
#print-area .t-right { text-align: right; }
#print-area .t-bold { font-weight: bold; }
#print-area .t-grande { font-size: 14px; font-weight: bold; }
#print-area hr { border: none; border-top: 1px dashed #000; margin: 4px 0; }
#print-area table { width: 100%; border-collapse: collapse; font-size: 11px; }
#print-area td { padding: 1px 0; vertical-align: top; }
#print-area .puesto-titulo { font-weight: bold; margin-top: 4px; }

/* ---------- Comanda de cocina: grande y en NEGRILLA ---------- */
#print-area .comanda { font-weight: bold; }
#print-area .comanda .cmd-titulo { text-align: center; font-size: 17px; font-weight: bold; }
#print-area .comanda .cmd-canal {
  text-align: center; font-size: 16px; font-weight: bold;
  border: 2px solid #000; padding: 3px; margin: 5px 0;
}
#print-area .comanda .cmd-adicion { text-align: center; font-size: 15px; font-weight: bold; margin: 4px 0; }
/* El localizador (mesa / nombre / referencia): lo más visible de la comanda */
#print-area .comanda .cmd-localizador {
  text-align: center; font-size: 30px; font-weight: bold; line-height: 1.1;
  border: 3px solid #000; padding: 8px 4px; margin: 7px 0; word-break: break-word;
}
#print-area .comanda .cmd-meta { font-size: 11px; font-weight: normal; margin: 2px 0; }
#print-area .comanda .cmd-domicilio {
  font-size: 14px; font-weight: bold; text-align: center;
  border: 2px solid #000; padding: 5px; margin: 5px 0;
}
#print-area .comanda .cmd-sep { border-top: 2px solid #000; margin: 6px 0; }
#print-area .comanda .cmd-puesto {
  font-size: 15px; font-weight: bold; margin: 8px 0 3px;
  border-bottom: 2px solid #000; padding-bottom: 2px;
}
#print-area .comanda .cmd-items { font-size: 20px; font-weight: bold; }
#print-area .comanda .cmd-items td { padding: 3px 0; line-height: 1.25; }
#print-area .comanda .cmd-items .cmd-cant {
  width: 40px; font-size: 22px; font-weight: bold; vertical-align: top;
}
#print-area .comanda .cmd-items .cmd-nom { padding-left: 6px; }
