/* QR Order — POS shell overrides */

.qr-order-page .pos-app {
  min-height: 100vh;
  min-height: 100dvh;
}

.qr-cart-toggle {
  position: relative;
}

.qr-cart-badge {
  position: absolute;
  top: -0.15rem;
  right: -0.15rem;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
  color: #fff;
  background: #dc2626;
  border-radius: 999px;
}

.qr-loading-state,
.qr-error-wrap,
.qr-success-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

/* Author display:flex must not defeat the HTML hidden attribute */
.qr-loading-state[hidden],
.qr-error-wrap[hidden],
.qr-success-wrap[hidden],
.pos-body[hidden],
.qr-cart-backdrop[hidden],
.pos-modal-backdrop[hidden],
.pos-more-modal[hidden],
.qr-toast-error[hidden] {
  display: none !important;
}

.qr-order-page.is-success .qr-loading-state,
.qr-order-page.is-success .pos-body {
  display: none !important;
}

.qr-order-page.is-success .qr-success-wrap {
  display: flex !important;
}

.qr-spinner {
  width: 2.25rem;
  height: 2.25rem;
  margin: 0 auto 0.85rem;
  border: 3px solid #d1d5db;
  border-top-color: #374151;
  border-radius: 50%;
  animation: qr-spin 0.7s linear infinite;
}

@keyframes qr-spin {
  to { transform: rotate(360deg); }
}

.qr-loading-state p {
  margin: 0;
  color: var(--pos-muted);
  font-weight: 600;
  text-align: center;
}

.qr-error-card,
.qr-success-card {
  width: min(420px, 100%);
  background: var(--pos-surface);
  border-radius: var(--pos-radius);
  box-shadow: var(--pos-shadow);
  padding: 1.75rem 1.5rem;
  text-align: center;
}

.qr-error-card h2,
.qr-success-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.qr-error-card p,
.qr-success-card p {
  margin: 0;
  color: var(--pos-muted);
  line-height: 1.45;
}

.qr-success-icon {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1rem;
  border-radius: 999px;
  background: #eaf7ef;
  color: #166534;
  display: grid;
  place-items: center;
}

.qr-success-icon svg {
  width: 1.75rem;
  height: 1.75rem;
}

.qr-success-draft {
  margin: 1.25rem 0;
  padding: 0.85rem;
  background: #f3f4f6;
  border-radius: var(--pos-radius-sm);
}

.qr-success-draft span {
  display: block;
  font-size: 0.8rem;
  color: var(--pos-muted);
  margin-bottom: 0.2rem;
}

.qr-success-draft strong {
  font-size: 1.35rem;
}

.qr-toast-error {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 1200;
  max-width: min(420px, calc(100% - 2rem));
  background: #fce8e8;
  color: #b91c1c;
  border: 1px solid #f9d4d4;
  border-radius: var(--pos-radius-sm);
  padding: 0.75rem 1rem;
  font-weight: 600;
  box-shadow: var(--pos-shadow);
}

.qr-cart-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 2;
}

.pos-cart-card--items {
  position: relative;
}

.pos-product-option-section {
  margin-bottom: 1rem;
}

.pos-product-option-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--pos-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.pos-product-option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.pos-product-option-card {
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius-sm);
  background: #fff;
  padding: 0.7rem 0.75rem;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.pos-product-option-card.is-selected {
  border-color: var(--pos-tab-active);
  background: #f3f4f6;
  box-shadow: inset 0 0 0 1px var(--pos-tab-active);
}

.pos-product-option-name {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
}

.pos-product-option-price {
  display: block;
  margin-top: 0.2rem;
  color: var(--pos-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

/* Mobile: cart as slide-over drawer */
@media (max-width: 1024px) and (orientation: portrait) {
  .qr-order-page .pos-body {
    flex-direction: column;
  }

  .qr-order-page .pos-cart {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(100%, 400px);
    max-width: 100%;
    z-index: 1100;
    transform: translateX(105%);
    transition: transform 0.22s ease;
    background: var(--pos-page-bg);
    padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem max(0.75rem, env(safe-area-inset-bottom));
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
  }

  .qr-order-page.qr-cart-open .pos-cart {
    transform: translateX(0);
  }

  .qr-order-page .qr-cart-close {
    display: inline-flex !important;
  }

  .qr-order-page .pos-body-catalogue {
    flex: 1 1 auto;
    min-height: 0;
  }

  .qr-cart-backdrop[hidden] {
    display: none !important;
  }

  .qr-order-page.qr-cart-open .qr-cart-backdrop {
    display: block !important;
  }
}

/* Ensure product modal sits above cart drawer on mobile */
.pos-modal-backdrop.is-open {
  z-index: 1200;
}

.pos-more-modal.pos-product-modal.is-open {
  z-index: 1210;
}
