/* =============================================================================
   CHECKOUT PAGE — Premium Consumer Checkout
   Inspired by Apple, Glossier, Aesop checkout flows.
   Minimal chrome. Logo-only header. Elegant form fields. Refined card surfaces.
   All tokens from base.css. No hardcoded fonts.
   ============================================================================= */

/* ── Checkout-specific header (replaces site nav) ───────────────────────── */
.checkout-header {
  padding: 24px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}

.checkout-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.checkout-header-logo img {
  display: block;
  height: 32px;
  width: auto;
}

.checkout-header-secure {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-muted);
  letter-spacing: 0.04em;
}

.checkout-header-secure svg {
  width: 14px;
  height: 14px;
}

/* ── Layout: two-column grid ────────────────────────────────────────────── */
.checkout-page {
  background: #fafaf9;
  min-height: 100vh;
}

.checkout-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 56px;
  align-items: start;
  padding-top: 40px;
  padding-bottom: 80px;
}

/* ── Left column — form ─────────────────────────────────────────────────── */
.checkout-main {
  min-width: 0;
}

.checkout-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  margin-bottom: 20px;
  transition: color 0.2s;
}

.checkout-back:hover {
  color: var(--color-ink);
}

.checkout-back svg {
  width: 14px;
  height: 14px;
}

.checkout-heading {
  font-size: clamp(32px, 3.5vw, 44px);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--color-ink);
  margin: 0 0 36px 0;
}

.checkout-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-muted);
  margin-bottom: 16px;
  display: block;
}

/* ── Product line item card ─────────────────────────────────────────────── */
.checkout-product-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.checkout-product-card:hover {
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.checkout-product-img {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: contain;
  flex-shrink: 0;
  background: #f5f5f3;
  padding: 6px;
}

.checkout-product-info {
  flex: 1;
  min-width: 0;
}

.checkout-product-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--color-ink);
  color: #fff;
  padding: 3px 7px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.checkout-product-badge--recommended {
  background: var(--color-accent);
  color: #fff;
}

.checkout-product-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-ink);
  line-height: 1.3;
  margin: 0;
}

.checkout-product-desc {
  font-size: 13px;
  color: var(--color-text);
  margin-top: 2px;
  line-height: 1.45;
}

.checkout-product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-muted);
  letter-spacing: 0.01em;
}

.checkout-product-meta span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.checkout-product-meta svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.checkout-product-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.checkout-product-price {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-ink);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.checkout-product-line-total {
  font-size: 12px;
  color: var(--color-muted);
}

/* ── Quantity stepper ───────────────────────────────────────────────────── */
.checkout-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.checkout-stepper button {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  color: var(--color-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

.checkout-stepper button:hover {
  background: rgba(0, 0, 0, 0.04);
}

.checkout-stepper button:disabled {
  opacity: 0.25;
  cursor: default;
}

.checkout-stepper-val {
  width: 32px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-ink);
  border-left: 1px solid rgba(0, 0, 0, 0.12);
  border-right: 1px solid rgba(0, 0, 0, 0.12);
  line-height: 32px;
  background: #fafaf9;
}

/* ── Cross-sell card ────────────────────────────────────────────────────── */
.checkout-crosssell {
  background: transparent;
  border-radius: 16px;
  border: 1.5px dashed rgba(0, 0, 0, 0.15);
  padding: 20px;
  margin-top: 8px;
  margin-bottom: 36px;
  transition: border-color 0.2s;
}

.checkout-crosssell:hover {
  border-color: rgba(0, 0, 0, 0.25);
}

.checkout-crosssell.is-active {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.06);
  border-style: solid;
}

.checkout-crosssell-inner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.checkout-crosssell-content {
  flex: 1;
  min-width: 0;
}

.checkout-crosssell-eyebrow {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-accent);
  margin-bottom: 4px;
  display: block;
}

.checkout-crosssell-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-ink);
  line-height: 1.3;
  margin: 0;
}

.checkout-crosssell-desc {
  font-size: 13px;
  color: var(--color-text);
  margin-top: 4px;
  line-height: 1.45;
}

.checkout-crosssell-price {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-ink);
  white-space: nowrap;
}

.checkout-crosssell-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.checkout-crosssell-line-total {
  font-size: 12px;
  color: var(--color-muted);
}

/* ── Section divider ────────────────────────────────────────────────────── */
.checkout-divider {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  margin: 28px 0;
}

/* ── Form fields ────────────────────────────────────────────────────────── */
.checkout-field-group {
  margin-bottom: 28px;
}

/* ── Stripe Element containers ──────────────────────────────────────────── */
.stripe-element-container {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  min-height: 60px;
}

.checkout-payment-message {
  color: #dc2626;
  font-size: 13px;
  margin-top: 8px;
  min-height: 0;
}

.checkout-payment-message:empty {
  display: none;
}

/* ── Promo code section ─────────────────────────────────────────────────── */
.checkout-promo-section {
  margin: 0;
}

.checkout-promo-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-accent, #593159);
  cursor: pointer;
  padding: 0;
  transition: opacity 0.2s;
}

.checkout-promo-toggle:hover {
  opacity: 0.7;
}

.checkout-promo-input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.checkout-promo-input-row input {
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  border: 1.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  outline: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: border-color 0.2s;
}

.checkout-promo-input-row input:focus {
  border-color: var(--color-accent, #593159);
}

.checkout-promo-apply-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border: 1.5px solid var(--color-accent, #593159);
  border-radius: 10px;
  background: transparent;
  color: var(--color-accent, #593159);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.checkout-promo-apply-btn:hover {
  background: var(--color-accent, #593159);
  color: #fff;
}

.checkout-promo-apply-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.checkout-promo-feedback {
  font-size: 12px;
  margin-top: 6px;
  min-height: 16px;
}

.checkout-promo-feedback.is-error {
  color: #dc2626;
}

.checkout-promo-feedback.is-success {
  color: #16a34a;
}

.checkout-promo-applied {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.promo-applied-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(22, 163, 106, 0.08);
  color: #16a34a;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  letter-spacing: 0.03em;
}

.promo-remove-btn {
  background: none;
  border: none;
  font-size: 16px;
  color: #16a34a;
  cursor: pointer;
  padding: 0 0 0 4px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.promo-remove-btn:hover {
  opacity: 1;
}

.promo-applied-discount {
  font-size: 14px;
  font-weight: 600;
  color: #16a34a;
}

.checkout-discount-amount {
  color: #16a34a !important;
  font-weight: 600;
}


.checkout-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkout-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.checkout-field:last-child {
  margin-bottom: 0;
}

.checkout-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-ink);
}

.checkout-field label .field-optional {
  font-weight: 400;
  color: var(--color-muted);
}

.checkout-field input,
.checkout-field select {
  height: 46px;
  padding: 0 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  font-family: 'Satoshi', sans-serif;
  font-size: 15px;
  color: var(--color-ink);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.checkout-field select {
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.checkout-field input:focus,
.checkout-field select:focus {
  border-color: var(--color-ink);
  box-shadow: 0 0 0 3px rgba(10, 14, 23, 0.06);
}

.checkout-field input::placeholder {
  color: rgba(0, 0, 0, 0.3);
}

.checkout-field input.is-invalid {
  border-color: #c0392b;
}

.checkout-field .field-error {
  font-size: 12px;
  color: #c0392b;
  display: none;
}

.checkout-field input.is-invalid ~ .field-error {
  display: block;
}

/* ── Right column — order summary (sticky) ──────────────────────────────── */
.checkout-sidebar {
  position: sticky;
  top: 88px;
}

.checkout-summary-card {
  background: #fff;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 28px 24px;
}

.checkout-summary-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-ink);
  margin: 0 0 20px 0;
  letter-spacing: -0.01em;
}

.checkout-summary-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  font-size: 14px;
  color: var(--color-text);
}

.checkout-summary-line-name {
  flex: 1;
  min-width: 0;
  padding-right: 12px;
}

.checkout-summary-line-qty {
  font-size: 13px;
  color: var(--color-muted);
  margin-left: 3px;
}

.checkout-summary-line-price {
  font-weight: 600;
  color: var(--color-ink);
  white-space: nowrap;
}

.checkout-summary-divider {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  margin: 14px 0;
}

.checkout-summary-subtotal {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--color-text);
  padding: 4px 0;
}

.checkout-summary-shipping {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--color-text);
  padding: 4px 0;
}

.checkout-summary-shipping-free {
  color: #27ae60;
  font-weight: 500;
}

.checkout-summary-total {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-ink);
  padding: 10px 0 0;
  letter-spacing: -0.01em;
}

/* ── Pay button ─────────────────────────────────────────────────────────── */
.checkout-pay-btn {
  display: block;
  width: 100%;
  padding: 15px 24px;
  margin-top: 20px;
  font-family: 'Satoshi', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--color-accent);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  text-align: center;
}

.checkout-pay-btn:hover {
  background: #4a264a;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(89, 49, 89, 0.25);
}

.checkout-pay-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.checkout-pay-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.checkout-pay-btn .btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 0 auto;
}

.checkout-pay-btn.is-loading .btn-label { display: none; }
.checkout-pay-btn.is-loading .btn-spinner { display: block; }

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

/* ── Trust micro-copy below pay button ──────────────────────────────────── */
.checkout-trust-micro {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  margin-top: 14px;
  padding: 0;
  list-style: none;
}

.checkout-trust-micro li {
  font-size: 11px;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.checkout-trust-micro svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* ── Acceptance links ───────────────────────────────────────────────────── */
.checkout-legal {
  margin-top: 14px;
  font-size: 11px;
  color: var(--color-muted);
  text-align: center;
  line-height: 1.6;
}

.checkout-legal a {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Error banner ───────────────────────────────────────────────────────── */
.checkout-error {
  background: #fdf0ef;
  border: 1px solid rgba(192, 57, 43, 0.2);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 14px;
  color: #c0392b;
  display: none;
}

.checkout-error.is-visible {
  display: block;
}

/* ── Mobile summary (hidden on desktop, visible on mobile) ──────────────── */
.checkout-mobile-summary {
  display: none;
}

/* ── Sticky mobile pay bar (hidden on desktop) ──────────────────────────── */
.checkout-mobile-pay-bar {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .checkout-layout {
    grid-template-columns: 1fr 360px;
    gap: 36px;
  }
}

@media (max-width: 768px) {
  .checkout-layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding-top: 20px;
    padding-bottom: 100px; /* space for sticky pay bar */
  }

  /* Sidebar stays BELOW the form — no more order: -1 */
  .checkout-sidebar {
    position: static;
    margin-top: 28px;
  }

  /* Hide sidebar CTA, trust, legal on mobile — sticky bar replaces these */
  .checkout-sidebar .checkout-pay-btn,
  .checkout-sidebar .checkout-trust-micro,
  .checkout-sidebar .checkout-legal {
    display: none;
  }

  /* Hide 'Your Order' label on mobile — product card IS the order */
  .checkout-section-label--order {
    display: none;
  }

  /* Hide mobile summary bar — product card already shows price */
  .checkout-mobile-summary {
    display: none;
    padding: 14px 16px;
    margin-bottom: 20px;
    cursor: pointer;
    transition: border-color 0.2s;
  }

  .checkout-mobile-summary:hover {
    border-color: rgba(0, 0, 0, 0.12);
  }

  .checkout-mobile-summary-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .checkout-mobile-summary-left .summary-item-count {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
  }

  .checkout-mobile-summary-right {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-ink);
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 12px;
  }

  .checkout-mobile-summary-toggle {
    width: 20px;
    height: 20px;
    color: var(--color-muted);
    flex-shrink: 0;
    transition: transform 0.2s;
  }

  .checkout-mobile-summary-toggle.is-expanded {
    transform: rotate(180deg);
  }

  /* Form field rows stack on mobile */
  .checkout-field-row {
    grid-template-columns: 1fr;
  }

  /* Product card wrapping */
  .checkout-product-card {
    flex-wrap: wrap;
  }

  .checkout-product-right {
    flex-direction: row;
    align-items: center;
    width: 100%;
    justify-content: space-between;
    margin-top: 4px;
  }

  /* Cross-sell wrapping */
  .checkout-crosssell-inner {
    flex-wrap: wrap;
  }

  .checkout-crosssell-right {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    margin-top: 4px;
  }

  /* Mobile pay bar loading state */
  .checkout-mobile-pay-btn .btn-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 0 auto;
  }
  .checkout-mobile-pay-btn.is-loading .btn-label { display: none; }
  .checkout-mobile-pay-btn.is-loading .btn-spinner { display: block; }

  /* Sticky mobile pay bar — always accessible CTA */
  .checkout-mobile-pay-bar {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    padding: 12px var(--container-pad) calc(12px + env(safe-area-inset-bottom));
  }

  .checkout-mobile-pay-bar-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: var(--container-max);
    margin: 0 auto;
  }

  .checkout-mobile-pay-total {
    flex-shrink: 0;
    min-width: 0;
  }

  .checkout-mobile-pay-total-label {
    font-size: 11px;
    color: var(--color-muted);
    font-weight: 500;
    letter-spacing: 0.04em;
    display: block;
    line-height: 1;
  }

  .checkout-mobile-pay-total-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-ink);
    letter-spacing: -0.01em;
    display: block;
    line-height: 1.3;
  }

  .checkout-mobile-pay-btn {
    flex: 1;
    display: block;
    padding: 14px 24px;
    font-family: 'Satoshi', sans-serif;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #fff;
    background: var(--color-accent);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
  }

  .checkout-mobile-pay-btn:hover {
    background: #4a264a;
  }

  .checkout-mobile-pay-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

@media (max-width: 480px) {
  .checkout-summary-card {
    padding: 20px 16px;
  }

  .checkout-product-card {
    padding: 16px;
  }

  .checkout-header {
    padding: 16px 0;
  }

  .checkout-heading {
    font-size: 28px;
    margin-bottom: 28px;
  }
}

