/* Checkout page – mobile-first phone UI */

/* Use theme variables from style.css when available */
.checkout-page {
  --checkout-bg: var(--color-bg, #f8f9fa);
  --checkout-surface: var(--color-surface, #fff);
  --checkout-text: var(--color-text, #212529);
  --checkout-primary: var(--color-primary, #0d6efd);
  --checkout-border: var(--border-color, #e9ecef);
  --checkout-radius: 12px;
  --checkout-touch: 48px;
  --checkout-safe-bottom: env(safe-area-inset-bottom, 0);
  --checkout-safe-top: env(safe-area-inset-top, 0);
}

.checkout-page {
  background: var(--checkout-bg);
  color: var(--checkout-text);
  min-height: 100vh;
  padding-bottom: 100px; /* space for sticky bar on mobile */
}

/* ----- Mobile header ----- */
.checkout-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--checkout-surface);
  border-bottom: 1px solid var(--checkout-border);
  padding: 12px 0;
  padding-top: calc(12px + var(--checkout-safe-top));
  margin-bottom: 1rem;
}

.checkout-header .checkout-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.checkout-header .checkout-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--checkout-primary);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 6px 0;
  min-height: var(--checkout-touch);
  margin: -6px 0;
  justify-content: flex-start;
}

.checkout-header .checkout-back:active {
  opacity: 0.8;
}

/* ----- Main content ----- */
.checkout-page .container {
  --checkout-gutter: 16px;
  max-width: 100%;
  padding-left: var(--checkout-gutter);
  padding-right: var(--checkout-gutter);
}

@media (min-width: 768px) {
  .checkout-page .container {
    --checkout-gutter: 24px;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (min-width: 992px) {
  .checkout-page .container {
    max-width: 960px;
  }
}

.checkout-page .mt-5 {
  margin-top: 1rem !important;
}

@media (min-width: 768px) {
  .checkout-page .mt-5 {
    margin-top: 2rem !important;
  }
}

/* ----- Section cards (mobile) ----- */
.checkout-section {
  background: var(--checkout-surface);
  border-radius: var(--checkout-radius);
  border: 1px solid var(--checkout-border);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.checkout-section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--checkout-text);
}

/* ----- Form inputs (touch-friendly, no zoom on iOS) ----- */
.checkout-page .form-label {
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--checkout-text);
}

.checkout-page .form-control {
  font-size: 16px !important; /* prevents iOS zoom on focus */
  min-height: var(--checkout-touch);
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--checkout-border);
  background: var(--checkout-surface);
  color: var(--checkout-text);
}

.checkout-page .form-control::placeholder {
  color: var(--checkout-text);
  opacity: 0.5;
}

.checkout-page .form-control:focus {
  border-color: var(--checkout-primary);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb, 13, 110, 253), 0.2);
}

.checkout-page .mb-3 {
  margin-bottom: 1.25rem !important;
}

/* ----- Payment method options (card-style, large tap target) ----- */
.checkout-payment-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkout-page .form-check.d-none {
  display: none !important;
}

.checkout-page .form-check:not(.d-none) {
  display: flex !important;
  align-items: center;
  min-height: var(--checkout-touch);
  margin: 0 !important;
  padding: 0 14px;
  background: var(--checkout-bg);
  border: 2px solid var(--checkout-border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.checkout-page .form-check:not(.d-none):has(input:checked) {
  border-color: var(--checkout-primary);
  background: rgba(var(--color-primary-rgb, 13, 110, 253), 0.08);
}

.checkout-page .form-check:not(.d-none):active {
  background: rgba(var(--color-primary-rgb, 13, 110, 253), 0.12);
}

.checkout-page .form-check-input {
  width: 22px !important;
  height: 22px !important;
  margin: 0 12px 0 0 !important;
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 0 !important;
}

.checkout-page .form-check-label {
  flex: 1;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  padding: 14px 0;
  margin: 0 !important;
}

.checkout-page .form-check input[disabled] ~ .form-check-label {
  opacity: 0.7;
}

/* M-Pesa phone wrapper */
.checkout-page #mpesa-phone-wrapper .form-control {
  font-size: 16px !important;
  min-height: var(--checkout-touch);
}

/* ----- Order summary (compact on mobile) ----- */
.checkout-summary-card {
  background: var(--checkout-surface);
  border-radius: var(--checkout-radius);
  border: 1px solid var(--checkout-border);
  overflow: hidden;
  margin-bottom: 1rem;
}

.checkout-summary-card .list-group-item {
  padding: 12px 1rem;
  font-size: 0.9375rem;
  border-color: var(--checkout-border);
  background: var(--checkout-surface);
  color: var(--checkout-text);
}

.checkout-summary-card #order-summary-list {
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.checkout-summary-card .d-flex.justify-content-between.list-group-item:last-child {
  font-size: 1.0625rem;
  font-weight: 600;
  padding: 14px 1rem;
  background: var(--checkout-bg);
}

/* ----- Sticky bottom bar (mobile only) ----- */
.checkout-sticky-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--checkout-surface);
  border-top: 1px solid var(--checkout-border);
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--checkout-safe-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

.checkout-sticky-bar .checkout-sticky-total {
  font-size: 1rem;
  font-weight: 600;
  color: var(--checkout-text);
}

.checkout-sticky-bar .checkout-sticky-total span {
  font-size: 1.125rem;
  color: var(--checkout-primary);
}

.checkout-sticky-bar #submit-payment-sticky {
  flex: 1;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  padding: 12px 20px;
  background: var(--checkout-primary) !important;
  color: #fff !important;
}

.checkout-sticky-bar #submit-payment-sticky:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Hide in-page submit on mobile (we use sticky bar) */
.checkout-form-actions {
  margin-top: 1rem;
}

@media (max-width: 767px) {
  .checkout-form-actions .btn#submit-payment {
    display: none !important;
  }
}

@media (min-width: 768px) {
  .checkout-sticky-bar {
    display: none !important;
  }

  .checkout-form-actions .btn#submit-payment {
    display: inline-block !important;
  }
}

/* ----- Message area ----- */
#payment-message {
  font-size: 0.9375rem;
  padding: 12px 14px;
  border-radius: 10px;
  margin-top: 1rem;
}

/* ----- Desktop: restore two-column layout ----- */
@media (min-width: 768px) {
  .checkout-page {
    padding-bottom: 2rem;
  }

  .checkout-header {
    position: relative;
    margin: 0;
    padding: 0 0 1rem;
    border: none;
    padding-top: 0;
  }

  .checkout-section {
    padding: 1.5rem;
  }

  .checkout-section-title {
    font-size: 1.125rem;
  }

  .checkout-payment-options .form-check:not(.d-none):hover {
    background: rgba(var(--color-primary-rgb, 13, 110, 253), 0.05);
  }
}

/* Row/column order: on mobile, summary first then form */
@media (max-width: 767px) {
  .checkout-row {
    display: flex;
    flex-direction: column;
  }

  .checkout-col-summary {
    order: 0;
  }

  .checkout-col-form {
    order: 1;
  }
}
