/* Punto de venta: catálogo, carrito, historial y comprobante. Usa las variables de styles.css. */

/* El atributo hidden debe ganar a los display de .field, .btn, etc. */
[hidden] { display: none !important; }

.pos { display: grid; gap: 20px; align-items: start; }
@media (min-width: 960px) { .pos { grid-template-columns: 1fr 380px; } }

/* Catálogo */
.catalog { display: grid; gap: 14px; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 0.88rem;
  border: 1px solid var(--line-strong); background: transparent; color: var(--muted); transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.chip:hover { border-color: var(--cyan); color: var(--text); }
.chip[aria-pressed='true'] { background: var(--surface-2); color: var(--text); border-color: var(--cyan); }
.product-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); }
/* Espacio para la barra «Ver carrito»; la guía inicial se ubica por encima de ella */
@media (max-width: 959px) { #panel-vender { padding-bottom: 88px; } body .tour { bottom: 84px; } }
.pcard {
  display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: linear-gradient(180deg, rgba(16, 32, 74, 0.55), rgba(11, 22, 48, 0.8));
  transition: transform 0.25s var(--ease), border-color 0.25s;
}
.pcard:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.pcard .code { font-size: 0.75rem; }
.pcard h3 { font-size: 0.98rem; line-height: 1.3; flex: 1; }
.pcard .price { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pcard .avail { font-size: 0.8rem; color: var(--muted); }
.pcard .avail.zero { color: var(--danger); }
.pcard .btn { width: 100%; margin-top: 4px; }
.pcard .btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; border-color: var(--line); }
.pcard.added { animation: added 0.5s var(--ease); }
@keyframes added { 40% { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2); } }

/* Carrito */
.cart { display: grid; gap: 14px; scroll-margin-top: 76px; }
.cart:hover { transform: none; }
@media (min-width: 960px) { .cart { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; } }
.cart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cart-head h2 { font-size: 1.15rem; }
.cart-empty { color: var(--muted); font-size: 0.92rem; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 12px; text-align: center; }
.cart-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cart-line {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(5, 11, 26, 0.5);
  animation: row-in 0.35s var(--ease);
}
.cart-line .ln-name { font-weight: 650; font-size: 0.92rem; overflow-wrap: anywhere; }
.cart-line .ln-unit { display: block; font-weight: 400; font-size: 0.78rem; color: var(--muted); }
.cart-line .ln-sub { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.qty button { width: 40px; height: 40px; border: 0; background: rgba(16, 32, 74, 0.6); color: var(--text); font-size: 1.1rem; font-weight: 700; cursor: pointer; }
.qty button:hover { background: var(--surface-2); }
.qty button:disabled { opacity: 0.4; cursor: not-allowed; }
.qty input { width: 56px; min-height: 40px; border: 0; border-radius: 0; text-align: center; padding: 6px 4px; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ln-remove { justify-self: end; background: none; border: 0; color: var(--danger); font-weight: 600; font-size: 0.85rem; min-height: 40px; padding: 0 4px; cursor: pointer; }
.ln-remove:hover { text-decoration: underline; }

.checkout { display: grid; gap: 12px; }
.checkout[hidden] { display: none; }
.totals-box { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; padding: 12px 14px; border-radius: 12px; background: rgba(5, 11, 26, 0.6); border: 1px solid var(--line); }
.totals-box dt { color: var(--muted); }
.totals-box dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.totals-box .grand { font-size: 1.25rem; font-weight: 800; color: var(--text); padding-top: 6px; border-top: 1px solid var(--line); }
.totals-box dd.grand { color: var(--cyan); }
.change { font-size: 0.95rem; color: var(--muted); }
.change b { color: var(--ok); font-variant-numeric: tabular-nums; }
.change[hidden] { display: none; }
.btn-block { width: 100%; min-height: 50px; font-size: 1rem; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.field small { font-weight: 400; }

/* Barra de carrito (solo celular, cuando el carrito no está a la vista) */
.cart-bar {
  position: fixed; z-index: 30; left: 16px; right: 16px; bottom: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 52px; padding: 10px 18px; border-radius: 999px; border: 0; cursor: pointer; font-weight: 700;
  background: linear-gradient(135deg, var(--blue), var(--blue-deep)); color: #fff; box-shadow: 0 16px 40px -12px rgba(47, 107, 255, 0.8);
  animation: toast-in 0.3s var(--ease);
}
.cart-bar b { font-variant-numeric: tabular-nums; }
@media (min-width: 960px) { .cart-bar { display: none !important; } }
.cart-bar[hidden] { display: none; }

/* Historial */
.sales { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.sale {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(11, 22, 48, 0.7);
}
.sale-no { font-weight: 800; font-family: Consolas, 'Cascadia Mono', monospace; color: var(--cyan); }
.sale-meta { grid-column: 1; font-size: 0.82rem; color: var(--muted); overflow-wrap: anywhere; }
.sale-total { grid-row: 1; grid-column: 2; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.sale .btn { grid-column: 2; grid-row: 2 / span 2; justify-self: end; }
@media (max-width: 479px) { .sale .btn { grid-column: 1 / -1; grid-row: auto; justify-self: stretch; margin-top: 6px; } }

/* Diálogo de confirmación de venta */
.sale-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.92rem; }
.sale-list li { display: flex; justify-content: space-between; gap: 12px; }
.sale-list li span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Comprobante: formato tipo ticket, fondo claro también en pantalla */
dialog.receipt-dlg { width: min(400px, calc(100% - 24px)); background: var(--surface); padding: 16px; }
.receipt {
  position: relative; overflow: hidden; padding: 20px 18px; border-radius: 10px;
  background: #fff; color: #111; font-family: Consolas, 'Cascadia Mono', 'Courier New', monospace; font-size: 0.86rem; line-height: 1.45;
}
.receipt::before {
  content: 'DEMOSTRACIÓN'; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-28deg);
  font-family: var(--font); font-size: 3rem; font-weight: 900; letter-spacing: 0.08em; color: rgba(0, 0, 0, 0.07); white-space: nowrap; pointer-events: none;
}
.receipt h2 { font-family: var(--font); font-size: 1.15rem; text-align: center; letter-spacing: 0.08em; }
.receipt .r-center { text-align: center; }
.receipt .r-demo {
  margin: 8px 0; padding: 4px; text-align: center; font-family: var(--font); font-weight: 900; letter-spacing: 0.12em;
  border: 2px solid #111;
}
.receipt hr { border: 0; border-top: 1px dashed #555; margin: 10px 0; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt th { text-align: left; font-weight: 700; border-bottom: 1px solid #111; padding: 2px 0; }
.receipt td { padding: 3px 0; vertical-align: top; }
.receipt .num { text-align: right; white-space: nowrap; padding-left: 8px; }
.receipt .r-total td { font-weight: 800; font-size: 1.05rem; border-top: 1px solid #111; padding-top: 6px; }
.receipt .r-legal { margin-top: 10px; font-size: 0.75rem; text-align: center; }
.receipt-actions { margin-top: 14px; }

/* Impresión del comprobante: solo el ticket */
@media print {
  body.printing-receipt > *:not(#dlg-receipt) { display: none !important; }
  body.printing-receipt { background: #fff; }
  body.printing-receipt dialog.receipt-dlg[open] {
    position: static; display: block; width: 80mm; max-width: 100%; margin: 0 auto; padding: 0;
    border: 0; box-shadow: none; background: #fff; animation: none;
  }
  body.printing-receipt dialog.receipt-dlg::backdrop { display: none; }
  body.printing-receipt .receipt-actions { display: none; }
  body.printing-receipt .receipt { padding: 0; border-radius: 0; }
  body.printing-receipt .receipt::before { color: rgba(0, 0, 0, 0.12); }
}
