/**
 * Cart bar + sheet, shared by POS and Waiter so one table reads the same on
 * either screen. The page keeps its own cart markup; this only positions it.
 */

/* ── Bottom bar ───────────────────────────────────────────────────────── */
.cart-bar[hidden] {
  display: none;
}

.cart-bar {
  position: fixed;
  left: 50%;
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  width: min(34rem, calc(100vw - 1.5rem));
  min-height: 3.25rem;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--zy-emerald-dark, #0b3d35);
  color: var(--zy-ivory, #fbfaf5);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 28px rgb(11 61 53 / 32%);
}

.cart-bar:hover {
  filter: brightness(1.06);
}

.cart-bar-main {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
}

.cart-bar-count {
  font-size: 0.95rem;
  font-weight: 700;
}

.cart-bar-total {
  font-size: 0.9rem;
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
}

.cart-bar-cta {
  flex: none;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: underline;
}

/* Room for the bar. It floats over the page, so whatever is scrolling behind
   it needs to end above it — otherwise the last row of item cards is covered
   and looks cut off. Set only while the bar is actually on screen. */
body.has-cart-bar .p-main,
body.has-cart-bar .w-main {
  padding-bottom: calc(5rem + env(safe-area-inset-bottom));
}

/* ── Sheet ────────────────────────────────────────────────────────────── */
.cart-sheet-backdrop[hidden] {
  display: none;
}

.cart-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 61;
  background: rgb(15 23 20 / 45%);
}

.cart-sheet[hidden] {
  display: none;
}

.cart-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 62;
  display: flex;
  flex-direction: column;
  width: min(34rem, 100vw);
  /* Never taller than the screen: a long order scrolls inside the sheet
     instead of pushing Confirm past the bottom of the page. */
  max-height: min(80vh, 42rem);
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0;
  background: var(--zy-white, #fff);
  box-shadow: 0 -12px 40px rgb(0 0 0 / 22%);
}

.cart-sheet > h2 {
  margin: 0 2rem 0.5rem 0;
  font-size: 1.05rem;
}

/* The list is the only part that scrolls, so the total and Confirm stay put. */
.cart-sheet > ul {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  margin: 0;
}

.cart-sheet-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--zy-border, #e2e8f0);
  border-radius: 50%;
  background: var(--zy-white, #fff);
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

/* The page behind must not scroll while the sheet is up. */
body.cart-sheet-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: no-preference) {
  .cart-sheet {
    animation: cart-sheet-in 0.18s ease-out;
  }

  @keyframes cart-sheet-in {
    from {
      transform: translate(-50%, 12%);
      opacity: 0.6;
    }
    to {
      transform: translate(-50%, 0);
      opacity: 1;
    }
  }
}

/* One line in the open cart: name, quantity stepper, and an explicit Remove —
   decrementing to zero works but is a trick, not an affordance. */
.cart-sheet > ul > li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--zy-border, #eee);
}

.cart-sheet > ul > li > :first-child {
  flex: 1 1 8rem;
  min-width: 0;
}

.cart-line-remove {
  flex: none;
  min-height: 2rem;
  padding: 0 0.6rem;
  border: 1px solid var(--zy-border, #e2e8f0);
  border-radius: 8px;
  background: var(--zy-white, #fff);
  color: var(--zy-error, #b91c1c);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.cart-line-remove:hover {
  background: #fee2e2;
}
