/* Checkout modal — desktop + mobile */

html.checkout-modal-open,
body.checkout-modal-open {
  overflow: hidden;
  overscroll-behavior: none;
}

body.checkout-modal-open #whatsapp-float-widget {
  display: none !important;
}

#checkoutModalBackdrop {
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

#checkoutModalBackdrop.is-open {
  display: flex;
}

#checkoutModalBackdrop .checkout-modal {
  max-width: 900px;
  width: 100%;
  max-height: min(95dvh, 900px);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  overflow: hidden;
  align-items: stretch;
  border: 1px solid var(--border, #d4d4d4);
  background: #ffffff;
}

#checkoutModalBackdrop .modal-main {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#checkoutModalBackdrop .modal-side {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#checkoutModalBackdrop .modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#checkoutModalBackdrop .modal-header h3 {
  flex: 1;
  min-width: 0;
  line-height: 1.2;
}

#checkoutModalBackdrop .modal-header .modal-close {
  width: 36px;
  height: 36px;
  min-width: 36px;
  margin-top: 0;
  flex-shrink: 0;
}

#checkoutModalBackdrop .two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

#checkoutModalBackdrop input,
#checkoutModalBackdrop textarea,
#checkoutModalBackdrop select {
  font-size: 16px;
  max-width: 100%;
}

#checkoutModalBackdrop .order-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

#checkoutModalBackdrop .order-summary-row span:first-child {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

#checkoutModalBackdrop .order-summary-row span:last-child {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Payment + confirmation rows */
.payment-option {
  width: 100%;
  padding: 12px;
  border-radius: 0;
  border: 1px solid #000000;
  background: #ffffff;
  display: grid;
  grid-template-columns: 18px 88px minmax(0, 1fr);
  align-items: start;
  gap: 8px 10px;
  cursor: pointer;
}

.payment-option:hover {
  border-color: #000000;
  background: #fafafa;
}

.payment-option input[type="radio"] {
  width: 16px;
  height: 16px;
  margin-top: 4px;
  grid-column: 1;
  grid-row: 1 / span 2;
}

.payment-option-icon {
  grid-column: 2;
  grid-row: 1;
  width: 88px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.payment-option-icon img {
  height: 18px;
  width: auto;
  display: block;
  object-fit: contain;
}

.payment-option-body {
  grid-column: 3;
  grid-row: 1 / span 2;
  min-width: 0;
  font-size: 0.85rem;
  line-height: 1.45;
}

.payment-option-body strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.confirmation-row {
  width: 100%;
  padding: 10px 12px;
  border-radius: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.02);
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  cursor: pointer;
}

.confirmation-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 3px;
}

#checkoutModalBackdrop .modal-main .btn-primary {
  min-height: 48px;
  width: 100%;
  margin-top: 10px;
}

/* ── Tablet / mobile ── */
@media (max-width: 800px) {
  #checkoutModalBackdrop {
    padding: 0;
    align-items: stretch;
  }

  #checkoutModalBackdrop .checkout-modal {
    display: flex;
    flex-direction: column;
    grid-template-columns: unset;
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    animation: none;
  }

  /* Summary first on mobile */
  #checkoutModalBackdrop .modal-side {
    order: -1;
    flex: 0 0 auto;
    max-height: none;
    overflow: visible;
    padding: 14px 16px;
    gap: 10px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.15);
  }

  #checkoutModalBackdrop .order-summary {
    max-height: 140px;
  }

  /* Hide verbose steps + duplicate total block on small screens */
  #checkoutModalBackdrop .modal-side .steps,
  #checkoutModalBackdrop .modal-side > div:last-child > p,
  #checkoutModalBackdrop .modal-side > div:last-child {
    display: none;
  }

  #checkoutModalBackdrop .modal-main {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding: 0 16px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  #checkoutModalBackdrop .modal-header {
    margin: 0 -16px 12px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid #e5e7eb;
  }

  #checkoutModalBackdrop .modal-header h3 {
    font-size: 1.1rem;
    letter-spacing: 0.02em;
    text-transform: none;
  }

  #checkoutModalBackdrop .two-col {
    grid-template-columns: 1fr;
  }

  #checkoutModalBackdrop > .checkout-modal > .modal-main > p {
    font-size: 0.8rem;
    line-height: 1.5;
  }
}

@media (max-width: 540px) {
  .payment-option {
    grid-template-columns: 18px minmax(0, 1fr);
    padding: 10px;
  }

  .payment-option-icon {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    height: auto;
    margin-bottom: 2px;
  }

  .payment-option-body {
    grid-column: 2;
    grid-row: 2;
    font-size: 0.8rem;
  }

  .payment-option input[type="radio"] {
    grid-row: 1 / span 2;
  }

  #checkoutModalBackdrop .modal-side {
    padding: 12px 14px;
  }

  #checkoutModalBackdrop .side-heading {
    font-size: 0.9rem;
  }

  #checkoutModalBackdrop .payid-value {
    font-size: 1.1rem;
  }
}

/* Dark theme overrides */
html[data-theme="dark"] #checkoutModalBackdrop .modal-header {
  background: #111111;
  border-bottom-color: #333333;
}

html[data-theme="dark"] .payment-option {
  background: #1a1a1a;
  border-color: #444444;
}

html[data-theme="dark"] .payment-option:hover {
  background: #222222;
}

html[data-theme="dark"] .confirmation-row {
  background: rgba(255, 255, 255, 0.04);
  border-color: #444444;
}
