/* Comandas — interfaz simple para caja/cocina */
* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, Segoe UI, sans-serif;
  margin: 0;
  padding: 1rem;
  background: #f0f0f0;
  color: #111;
  line-height: 1.4;
}

h1 {
  font-size: 1.35rem;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
  border-bottom: 1px solid #ccc;
  padding-bottom: 0.35rem;
}

section {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1rem;
  max-width: 720px;
}

.section-comanda {
  max-width: 460px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  gap: 0.2rem;
}

input[type="text"],
input[type="number"],
select {
  padding: 0.4rem 0.5rem;
  border: 1px solid #999;
  border-radius: 3px;
  min-width: 8rem;
}

button {
  padding: 0.45rem 0.85rem;
  border: 1px solid #333;
  background: #eee;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.9rem;
}

button:hover {
  background: #ddd;
}

button.primary {
  background: #333;
  color: #fff;
  border-color: #222;
}

button.primary:hover {
  background: #444;
}

button.danger {
  border-color: #800;
  color: #800;
}

button.danger:hover {
  background: #fee;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  border: 1px solid #ccc;
  padding: 0.4rem 0.5rem;
  text-align: left;
}

th {
  background: #e8e8e8;
}

.num {
  text-align: right;
}

.actions {
  white-space: nowrap;
}

.actions button {
  margin-right: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.msg {
  font-size: 0.85rem;
  margin-top: 0.5rem;
  color: #600;
}

.msg.ok {
  color: #060;
}

.total-bar {
  font-weight: bold;
  font-size: 1.1rem;
  margin-top: 0.75rem;
  padding: 0.5rem;
  background: #e8e8e8;
  border: 1px solid #ccc;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.logo-preview {
  display: block;
  width: 260px;
  max-width: 100%;
  height: auto;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  padding: 0.35rem;
  object-fit: contain;
}

.logo-help {
  font-size: 0.85rem;
  color: #444;
  margin: 0 0 0.75rem;
}

.logo-panel {
  transition: background 0.15s ease, border-color 0.15s ease;
}

.logo-panel.logo-drag {
  background: #f5f9ff;
  outline: 2px dashed #336;
  outline-offset: 2px;
}

.logo-row {
  margin-bottom: 0.5rem;
}

#msg {
  max-width: 720px;
}

.order-ticket-host {
  margin-bottom: 0.75rem;
}

/* Vista comanda = mismo estilo que el ticket impreso, más grande (solo pantalla) */
.screen-ticket {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  background: #fff;
  color: #000;
  border: 2px solid #222;
  border-radius: 14px;
  padding: 14px 12px;
  font-family: "Arial Narrow", Arial, Helvetica, sans-serif;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.screen-ticket-top {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
}

.screen-ticket-logo {
  width: auto;
  height: 1.8cm;
  min-height: 1.5cm;
  max-width: 70%;
  flex-shrink: 0;
  object-fit: contain;
}

.screen-ticket-code {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-left: auto;
}

.screen-ticket-code .circle {
  width: 44px;
  height: 44px;
  border: 2px solid #222;
  border-radius: 50%;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

.screen-ticket-table {
  margin-top: 12px;
  border: 2px solid #222;
  border-radius: 10px;
  overflow: hidden;
}

.screen-ticket-row {
  display: grid;
  grid-template-columns: 108px 1fr 72px;
  border-bottom: 1px solid #444;
  min-height: 40px;
}

.screen-ticket-row:last-child {
  border-bottom: none;
}

.screen-ticket-head {
  background: #ececec;
  font-size: 11px;
  font-weight: 700;
  min-height: 32px;
}

.screen-ticket-row > span {
  border-right: 1px solid #444;
  padding: 8px 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
}

.screen-ticket-row > span:last-child {
  border-right: none;
}

.screen-cant {
  justify-content: center;
  gap: 4px;
}

.screen-name {
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.screen-precio {
  justify-content: flex-end;
  font-weight: 600;
}

.screen-qty-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 700;
  border-radius: 6px;
  flex-shrink: 0;
}

.screen-qty-num {
  min-width: 1.25rem;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
}

.screen-ticket-total {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.screen-ticket-total-label {
  font-weight: 700;
  font-size: 22px;
}

.screen-ticket-total-box {
  min-width: 100px;
  min-height: 44px;
  border: 2px solid #222;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
}

.order-print-bar {
  justify-content: center;
  margin-top: 0.75rem;
  align-items: center;
}

.order-print-bar .primary {
  min-width: 200px;
  padding: 0.6rem 1rem;
  font-size: 1rem;
}

#print-area {
  display: none;
}

#print-area .ticket-paper {
  width: 80mm;
  background: #fff;
  color: #000;
  border: 1px solid #222;
  border-radius: 12px;
  padding: 10px;
  font-family: "Arial Narrow", Arial, sans-serif;
  break-inside: avoid;
  page-break-inside: avoid;
}

#print-area .ticket-copy {
  break-inside: avoid;
  page-break-inside: avoid;
}

#print-area .ticket-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

#print-area .ticket-logo {
  width: 52mm;
  max-width: 100%;
  max-height: 18mm;
  height: auto;
  object-fit: contain;
}

#print-area .ticket-code {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
}

#print-area .ticket-code .circle {
  width: 18mm;
  height: 18mm;
  border: 1.5px solid #222;
  border-radius: 50%;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

#print-area .ticket-table {
  margin-top: 8px;
  border: 1.2px solid #222;
  border-radius: 10px;
  overflow: hidden;
}

#print-area .ticket-row {
  display: grid;
  grid-template-columns: 14mm 1fr 20mm;
  border-bottom: 1px solid #444;
  min-height: 7.5mm;
}

#print-area .ticket-row:last-child {
  border-bottom: none;
}

#print-area .ticket-head {
  background: #ececec;
  font-size: 10px;
  font-weight: 700;
  min-height: 6mm;
}

#print-area .ticket-row > span {
  border-right: 1px solid #444;
  padding: 1.6mm 1.3mm;
  font-size: 10.5px;
  display: flex;
  align-items: center;
}

#print-area .ticket-row > span:last-child {
  border-right: none;
}

#print-area .ticket-cant {
  justify-content: center;
}

#print-area .ticket-precio {
  justify-content: flex-end;
}

#print-area .ticket-total-wrap {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

#print-area .ticket-total-label {
  font-weight: 700;
  font-size: 24px;
}

#print-area .ticket-total-box {
  min-width: 28mm;
  min-height: 12mm;
  border: 1.5px solid #222;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}

@media print {
  @page {
    size: 80mm auto;
    margin: 0;
  }

  body {
    margin: 0;
    padding: 0;
    background: #fff;
  }

  body * {
    visibility: hidden;
  }

  #print-area,
  #print-area * {
    visibility: visible;
  }

  #print-area {
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    width: 80mm;
    margin: 0;
    padding: 0;
  }

  #print-area .ticket-paper {
    border: none;
    border-radius: 0;
    width: 80mm;
  }

  #print-area .ticket-copy {
    break-after: page;
    page-break-after: always;
  }

  #print-area .ticket-copy:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}
