/* ==========================================================================
   QRBELL Store — Checkout and order success (spec §23, §25, §93)
   --------------------------------------------------------------------------
   Shared by pages/checkout.html and pages/order-success.html — they are two
   halves of one flow. All selectors namespaced `.co-*`.

   Desktop: form column + order summary rail.
   Mobile:  single column, collapsible summary, sticky Continue / Pay bar.
   ========================================================================== */

/* ==========================================================================
   CHECKOUT SHELL
   The header is stripped back on this page: a customer mid-payment should not
   be offered the nav, the search or the cart.
   ========================================================================== */

.co-topbar {
  background: var(--qb-navy-900);
  border-bottom: 1px solid var(--color-border-invert);
}

.co-topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: var(--header-height-mobile);
}

@media (min-width: 992px) { .co-topbar__inner { height: var(--header-height-desktop); } }

.co-topbar__secure {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-invert-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.co-topbar__secure i { color: var(--color-success); }


/* ==========================================================================
   STEPPER
   ========================================================================== */

.co-progress {
  padding-block: var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}


/* ==========================================================================
   LAYOUT
   ========================================================================== */

.co-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
  padding-block: var(--space-5) var(--space-10);
  align-items: start;
}

@media (min-width: 992px) {
  .co-layout { grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-8); }
}

@media (min-width: 1200px) {
  .co-layout { grid-template-columns: minmax(0, 1fr) 380px; }
}


/* ==========================================================================
   STEP PANEL
   ========================================================================== */

.co-panel {
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.co-panel__head { margin-bottom: var(--space-5); }

.co-panel__title {
  margin: 0 0 var(--space-1);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
}

.co-panel__sub { margin: 0; color: var(--color-text-muted); font-size: var(--text-sm); }

/* Fields are capped rather than filling the panel. A form column that
   stretches past 1000px makes every input look oversized, and a 10-digit
   mobile number does not need 600px of runway. */
.co-fields {
  display: grid;
  gap: var(--space-4);
  max-width: 640px;
}

@media (min-width: 576px) {
  .co-fields--two { grid-template-columns: 1fr 1fr; }
  .co-field--full { grid-column: 1 / -1; }
}

/* Rows sized to their content: mobile number + button, OTP + button. */
.co-row { display: flex; gap: var(--space-2); }
.co-row--mobile { max-width: 400px; }
.co-row--otp    { max-width: 320px; }

/* Desktop control sizing lives once in components.css — see the
   "Compact desktop controls" block there. Only the button beside a field needs
   matching here, since a button is not a form control. */
@media (min-width: 992px) {
  .store-checkout .co-row .qb-btn { min-height: 42px; padding-inline: var(--space-4); }
}

/* The step's Back / Continue (or Pay) actions live in the panel foot at every
   breakpoint. Earlier this row was hidden below lg in favour of a sticky
   action bar; the SPA keeps the actions inline on all sizes, so the row must
   stay visible — otherwise mobile users cannot advance a step or pay. */
.co-panel__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

/* Long labels ("Continue to delivery") must not overflow a 320px screen */
@media (max-width: 400px) {
  .co-panel__foot { flex-wrap: wrap; }
  .co-panel__foot > .qb-btn { flex: 1 1 auto; }
  .co-panel__next { flex-basis: 100%; }
}


/* ==========================================================================
   COMPLETED STEP SUMMARY
   Finished steps collapse to one line with an Edit link, so the page stays
   short on mobile — spec §93.
   ========================================================================== */

.co-done {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
}

.co-done__tick {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  margin-top: 1px;
  background: var(--color-success);
  color: #fff;
  border-radius: var(--radius-circle);
  font-size: 0.7rem;
}

.co-done__body { flex: 1 1 auto; min-width: 0; }
.co-done__label { font-size: var(--text-2xs); color: var(--color-text-faint); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
.co-done__value { font-size: var(--text-sm); line-height: 1.4; }

.co-done__edit {
  flex: 0 0 auto;
  min-height: 32px;
  color: var(--color-accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}


/* ==========================================================================
   SAVED ADDRESSES
   ========================================================================== */

.co-address {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition-base), background-color var(--transition-base);
}
.co-address:hover { border-color: var(--qb-grey-400); }
.co-address.is-selected {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
  box-shadow: inset 0 0 0 1px var(--color-accent);
}

.co-address__body { flex: 1 1 auto; min-width: 0; }
.co-address__label {
  display: inline-block;
  margin-bottom: 2px;
  padding: 1px var(--space-2);
  background: var(--color-surface-alt);
  border-radius: var(--radius-xs);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.co-address__name { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.co-address__text { color: var(--color-text-muted); font-size: var(--text-xs); line-height: 1.45; }


/* ==========================================================================
   PAYMENT METHODS
   ========================================================================== */

.co-methods { display: grid; gap: var(--space-2); }

.co-method {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition-base), background-color var(--transition-base);
}
.co-method:hover { border-color: var(--qb-grey-400); }
.co-method.is-selected {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
  box-shadow: inset 0 0 0 1px var(--color-accent);
}

.co-method__icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-xs);
  font-size: 1.05rem;
  color: var(--color-text-muted);
}
.co-method.is-selected .co-method__icon { background: var(--color-accent); color: #fff; }

.co-method__body { flex: 1 1 auto; min-width: 0; }
.co-method__name { font-size: var(--text-base); font-weight: var(--weight-semibold); }
.co-method__sub  { color: var(--color-text-muted); font-size: var(--text-xs); }
.co-method__fee  { flex: 0 0 auto; color: var(--color-text-muted); font-size: var(--text-xs); white-space: nowrap; }

/* Demo control for reaching the payment-failed state on purpose (§49) */
.co-demo {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-warning-soft);
  border: 1px dashed var(--qb-amber-500);
  border-radius: var(--radius-xs);
}
.co-demo__title { font-size: var(--text-xs); font-weight: var(--weight-bold); color: #92600A; }
.co-demo__text  { margin: 0; font-size: var(--text-2xs); color: #92600A; }


/* ==========================================================================
   ORDER SUMMARY RAIL
   Collapsible on mobile — spec §93 forbids making the customer scroll past
   desktop-style order detail before paying.
   ========================================================================== */

.co-summary {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

@media (min-width: 992px) {
  .co-summary {
    position: sticky;
    top: var(--space-4);
  }
}

.co-summary__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-4);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
.co-summary__toggle i { color: var(--color-text-faint); transition: transform var(--transition-base); }
.co-summary__toggle[aria-expanded="true"] i { transform: rotate(180deg); }

/* Above lg the summary is always open and the toggle is inert decoration */
@media (min-width: 992px) {
  .co-summary__toggle { pointer-events: none; }
  .co-summary__toggle i { display: none; }
}

.co-summary__body { padding: 0 var(--space-4) var(--space-4); }
.co-summary__body[hidden] { display: none; }

.co-line {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.co-line:first-child { padding-top: 0; }

.co-line__media {
  flex: 0 0 auto;
  width: 48px; height: 48px;
  background: var(--qb-grey-100);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  overflow: hidden;
}
.co-line__media img { width: 100%; height: 100%; object-fit: cover; }

.co-line__body { flex: 1 1 auto; min-width: 0; }
.co-line__name { font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: 1.3; }
.co-line__meta { color: var(--color-text-muted); font-size: var(--text-2xs); }
.co-line__price { flex: 0 0 auto; font-size: var(--text-sm); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }

.co-totals { padding-top: var(--space-3); }


/* ==========================================================================
   ORDER SUCCESS
   ========================================================================== */

.os-hero {
  padding-block: var(--space-10);
  text-align: center;
}

.os-tick {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px; height: 64px;
  margin: 0 auto var(--space-4);
  background: var(--color-success-soft);
  color: var(--color-success-strong);
  border-radius: var(--radius-circle);
  font-size: 2rem;
  animation: os-pop var(--duration-slow) var(--ease-out);
}

@keyframes os-pop {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.os-title {
  margin: 0 0 var(--space-2);
  font-size: 1.5rem;
  font-weight: var(--weight-extra);
}

@media (min-width: 768px) { .os-title { font-size: 2rem; } }

.os-sub { margin: 0 auto; max-width: 48ch; color: var(--color-text-muted); font-size: var(--text-md); }

.os-order-id {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
}

.os-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: minmax(0, 1fr);
  padding-bottom: var(--space-10);
}

@media (min-width: 992px) {
  .os-grid { grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-8); align-items: start; }
}

.os-card {
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.os-card__title {
  margin: 0 0 var(--space-4);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
}

.os-facts { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.os-fact__label { display: block; color: var(--color-text-faint); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
.os-fact__value { display: block; font-size: var(--text-base); font-weight: var(--weight-semibold); }

.os-actions { display: grid; gap: var(--space-2); }

@media (min-width: 576px) { .os-actions { grid-template-columns: 1fr 1fr; } }

/* The QR IDs assigned to this order — the reason the customer is here */
.os-qr {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface-alt);
  border-radius: var(--radius-xs);
}
.os-qr__id {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}
.os-qr__hint { color: var(--color-text-muted); font-size: var(--text-2xs); }

.os-next {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-primary-subtle);
  border: 1px solid var(--qb-gold-200);
  border-radius: var(--radius-sm);
}
.os-next i { flex: 0 0 auto; color: var(--qb-gold-700); font-size: 1.2rem; }
.os-next__title { font-size: var(--text-sm); font-weight: var(--weight-bold); }
.os-next__text  { margin: 0; font-size: var(--text-xs); color: var(--color-text-muted); line-height: 1.5; }
