/* Punto de Venta — POS-SAAS-0A.3
   Objetivos táctiles de 56 px (--touch-xl) en agregar, cantidad y cobrar.
   · ≥ 900 px   catálogo + pedido lado a lado
   · < 900 px   catálogo a todo el ancho; pedido como panel lateral          */

.main--pos { padding: var(--s-5) var(--s-6); }
.main--pos > * { max-width: none; }

.pos {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: var(--s-5);
  align-items: start;
}

/* ─────────────────────────── Catálogo ─────────────────────────── */

.pos__catalog { display: grid; gap: var(--s-4); min-width: 0; }
.pos__toolbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 5;
  display: grid;
  gap: var(--s-3);
  margin: calc(-1 * var(--s-5)) calc(-1 * var(--s-2)) 0;
  padding: var(--s-5) var(--s-2) var(--s-3);
  background: var(--c-bg);
}

.pos-cats { display: flex; gap: var(--s-2); overflow-x: auto; padding: 4px 4px 6px; margin: -4px; scrollbar-width: thin; }
.pos-cat {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--touch-xl);
  padding: 0 var(--s-5);
  border: 1.5px solid var(--c-line-strong);
  border-radius: var(--r-pill);
  background: var(--c-surface);
  color: var(--c-ink);
  font-weight: 600;
  font-size: var(--fs-lg);
  white-space: nowrap;
  flex: none;
}
.pos-cat .icon { width: 20px; height: 20px; color: var(--c-ink-2); }
.pos-cat:hover { border-color: var(--c-ink); }
.pos-cat.is-selected { background: var(--c-petrol); border-color: var(--c-petrol); color: var(--c-on-petrol); font-weight: 700; }
.pos-cat.is-selected .icon { color: var(--c-on-petrol); }

.pos-search { position: relative; }
.pos-search__icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--c-ink-2); pointer-events: none; }
.pos-search__input { min-height: var(--touch-lg); padding-left: 48px; font-size: var(--fs-lg); border-radius: var(--r-lg); }

.pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: var(--s-3);
}

.product {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--s-2);
  min-height: 148px;
  padding: var(--s-4);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  box-shadow: var(--shadow-1);
  color: var(--c-ink);
  text-align: left;
  transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.product:hover:not(.is-unavailable) { border-color: var(--c-interact-strong); box-shadow: var(--shadow-2); }
.product:active:not(.is-unavailable) { transform: scale(.98); }
.product__icon {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--c-surface-2);
  color: var(--c-petrol);
}
.product__icon .icon { width: 22px; height: 22px; }
.product__name { font-size: var(--fs-lg); font-weight: 700; line-height: 1.25; }
.product__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); flex-wrap: wrap; }
.product__price { font-size: var(--fs-lg); font-weight: 700; }
.product__add {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--c-primary-strong);
  color: var(--c-on-primary);
}
.product__add .icon { width: 20px; height: 20px; stroke-width: 2.5; }

/* Agotado: se muestra (no se oculta) con fondo gris y estado «Agotado hoy». */
.product.is-unavailable { background: var(--c-bg); box-shadow: none; border-style: dashed; cursor: not-allowed; }
.product.is-unavailable .product__icon { background: var(--c-surface-2); color: var(--c-ink-2); }
.product.is-unavailable .product__price { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--c-ink-2); }

.product.is-flash { animation: flash 420ms var(--ease); }
@keyframes flash { 0% { box-shadow: 0 0 0 0 var(--c-primary); } 50% { box-shadow: 0 0 0 4px var(--c-primary-soft); border-color: var(--c-primary); } }

.pos-empty { grid-column: 1 / -1; display: grid; justify-items: center; gap: var(--s-2); padding: var(--s-10); color: var(--c-ink-2); text-align: center; }
.pos-empty .icon { width: 32px; height: 32px; }

/* ─────────────────────────── Pedido actual ─────────────────────────── */

.cart {
  position: sticky;
  top: calc(var(--topbar-h) + var(--s-5));
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--topbar-h) - var(--s-5) * 2);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.cart__head { display: grid; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-line); }
.cart__title-row { display: flex; align-items: center; gap: var(--s-3); }
.cart__title { font-size: var(--fs-xl); }
.cart__title:focus-visible { box-shadow: var(--focus-ring); }
.cart__count { color: var(--c-ink-2); font-size: var(--fs-sm); font-weight: 600; }
.cart__close { display: none; margin-left: auto; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--c-surface-2); border-radius: var(--r-md); }
.segmented__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--touch);
  border: 0; border-radius: 9px;
  background: transparent; color: var(--c-ink); font-weight: 600;
}
.segmented__btn .icon { color: var(--c-ink-2); }
.segmented__btn:hover { background: var(--c-surface); }
.segmented__btn.is-selected { background: var(--c-surface); font-weight: 700; box-shadow: var(--shadow-1), inset 0 0 0 1.5px var(--c-petrol); }
.segmented__btn.is-selected .icon { color: var(--c-petrol); }

.table-field { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); font-weight: 600; font-size: var(--fs-sm); color: var(--c-ink-2); }
.table-field__input { width: 96px; text-align: center; font-size: var(--fs-lg); font-weight: 700; }

.cart__body { flex: 1; overflow-y: auto; min-height: 120px; }
.lines { list-style: none; }
.line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s-2) var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--c-line);
}
.line__info { display: grid; gap: 2px; min-width: 0; }
.line__name { font-weight: 700; font-size: var(--fs-lg); line-height: 1.25; }
.line__mods { color: var(--c-ink-2); font-size: var(--fs-sm); }
.line__note, .co-line__note { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--c-accent-ink); background: var(--c-accent-soft); border-radius: var(--r-sm); padding: 2px 8px; justify-self: start; }
.line__note .icon, .co-line__note .icon { width: 14px; height: 14px; }
.line__total { font-weight: 700; font-size: var(--fs-lg); }
.line__controls { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--s-2); }
.line__edit { min-height: var(--touch); padding: 0 var(--s-3); }
.line__remove { margin-left: auto; color: var(--c-ink-2); }

.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--c-line-strong); border-radius: var(--r-md); overflow: hidden; }
.stepper__btn {
  display: grid; place-items: center;
  width: var(--touch-xl); height: var(--touch-xl);
  border: 0; background: var(--c-surface); color: var(--c-ink);
}
.stepper__btn:hover { background: var(--c-surface-2); }
.stepper__btn .icon { width: 22px; height: 22px; stroke-width: 2.5; }
.stepper__qty { min-width: 40px; text-align: center; font-size: var(--fs-lg); font-weight: 700; }

.cart-empty { display: grid; justify-items: center; gap: var(--s-2); padding: var(--s-10) var(--s-6); color: var(--c-ink-2); text-align: center; }
.cart-empty .icon { width: 36px; height: 36px; stroke-width: 1.5; }

.cart__foot { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); padding: var(--s-4) var(--s-5) var(--s-5); border-top: 1px solid var(--c-line); background: var(--c-surface); }
.cart__actions { display: flex; gap: var(--s-2); }
.cart__pay { flex: 1; min-width: 0; justify-content: space-between; gap: var(--s-3); padding: 0 var(--s-5); font-size: var(--fs-xl); }
.cart__pay[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.totals { display: grid; gap: var(--s-1); }
.totals__row { display: flex; justify-content: space-between; gap: var(--s-3); color: var(--c-ink-2); }
.totals__row--grand { color: var(--c-ink); font-size: var(--fs-xl); font-weight: 700; padding-top: var(--s-2); border-top: 1px dashed var(--c-line-strong); }

.cart-bar { display: none; }

/* ─────────────────────── Tablet horizontal (≈ 1024) ─────────────────────── */

@media (max-width: 1180px) {
  .main--pos { padding: var(--s-4); }
  .pos { grid-template-columns: minmax(0, 1fr) 330px; gap: var(--s-4); }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .pos-cat { padding: 0 var(--s-4); font-size: var(--fs-md); }
  .line { padding: var(--s-3) var(--s-4); }
  .cart__head, .cart__foot { padding-inline: var(--s-4); }
  .cart__pay { font-size: var(--fs-lg); padding: 0 var(--s-4); }
  .cart__actions .btn--ghost { padding: 0 var(--s-3); }
}

/* ─────────────────── Tablet vertical: pedido en panel lateral ─────────────────── */

@media (max-width: 899px) {
  .pos { grid-template-columns: minmax(0, 1fr); padding-bottom: 88px; }
  .cart {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    z-index: 45;
    width: min(420px, 100vw);
    max-height: none;
    border-radius: 0;
    transform: translateX(102%);
    visibility: hidden;
    transition: transform var(--t-fast) var(--ease), visibility 0s linear var(--t-fast);
    box-shadow: var(--shadow-3);
  }
  .cart-open .cart { transform: none; visibility: visible; transition: transform var(--t-fast) var(--ease); }
  .cart__close { display: inline-flex; }
  .cart-bar {
    position: fixed;
    left: var(--s-4);
    right: var(--s-4);
    bottom: var(--s-4);
    z-index: 40;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-height: var(--touch-xl);
    padding: 0 var(--s-5);
    border: 0;
    border-radius: var(--r-lg);
    background: var(--c-primary-strong);
    color: var(--c-on-primary);
    font-weight: 700;
    font-size: var(--fs-lg);
    box-shadow: var(--shadow-3);
  }
  .cart-bar__text { flex: 1; text-align: left; }
  .cart-open .cart-bar { visibility: hidden; }
}

/* ── 0D.1 · Líneas que ya no se pueden cobrar (producto desactivado, agotado u opción inactiva) ── */
.cart-alert {
  display: flex; align-items: flex-start; gap: var(--s-2); margin: 0 0 var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md); border: 1px solid var(--c-danger);
  background: var(--c-danger-soft); color: var(--c-danger); font-weight: 600;
}
.cart-alert .icon { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.line--issue { box-shadow: inset 4px 0 0 var(--c-danger); }
.line__issue { display: grid; gap: 4px; justify-items: start; margin-top: 4px; }
.line__issue-text { font-size: var(--fs-sm); color: var(--c-danger); font-weight: 600; }
.line--issue .stepper__btn[aria-disabled="true"] { opacity: .45; }
.cart__body > .cart-alert { margin: var(--s-3) var(--s-4) 0; }
