/* Modal & Apple Pay–Inspired Sheet Styles (sheets.md, materials.md, liquid-glass.md) */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 19, 0.52);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* Modal Dialog / Sheet Container with Apple Spring Physics */
.modal-dialog {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(17, 28, 22, 0.08);
  border-radius: var(--radius-xl);
  max-width: 440px;
  width: 100%;
  box-shadow: 0 24px 60px -12px rgba(7, 25, 16, 0.25), 0 4px 16px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transform: translateY(30px) scale(0.92);
  transition: transform 0.42s var(--spring-bounce), opacity 0.28s ease;
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.modal-backdrop.show .modal-dialog {
  transform: translateY(0) scale(1);
}

/* Mobile True Bottom Sheet Presentation (sheets.md › Mobile iOS) */
@media (max-width: 540px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-dialog {
    max-width: 100%;
    border-radius: 28px 28px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
    max-height: 92vh;
    overflow-y: auto;
    transition: transform 0.44s var(--spring-bounce);
  }

  .modal-backdrop.show .modal-dialog {
    transform: translateY(0);
  }
}

/* Sheet Top Grabber Handle */
.sheet-grabber {
  width: 36px;
  height: 4.5px;
  border-radius: 999px;
  background: rgba(60, 60, 67, 0.25);
  margin: 0.75rem auto 0;
  flex-shrink: 0;
}

/* Modal Header */
.modal-header {
  padding: 0.85rem 1.4rem 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  letter-spacing: -0.015em;
}

/* Apple Circular Close Button */
.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: rgba(118, 118, 128, 0.12);
  transition: transform 0.24s var(--spring-snappy), background 0.18s ease, color 0.18s ease;
  flex-shrink: 0;
  will-change: transform;
}

.modal-close-btn:hover {
  background: rgba(118, 118, 128, 0.22);
  color: var(--text-main);
  transform: scale(1.12) rotate(90deg);
}

.modal-close-btn:active {
  transform: scale(0.9);
}

.modal-body {
  padding: 0.5rem 1.4rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.modal-footer {
  padding: 0.75rem 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  border-top: 1px solid rgba(17, 28, 22, 0.06);
}

/* ─── Apple Pay–Style Canvas & Status Ring ─── */
.apple-pay-brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand-primary);
  letter-spacing: -0.015em;
}

.apple-pay-brand-pill svg {
  width: 14px;
  height: 14px;
  color: var(--brand-accent-text, #065F46);
}

.apple-pay-stage {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  position: relative;
}

/* Concentric Status Ring & Icon */
.apple-pay-ring-wrap {
  position: relative;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.35rem 0 0.25rem;
}

.apple-pay-spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3.5px solid rgba(5, 223, 114, 0.22);
  border-top-color: var(--brand-accent);
  border-right-color: var(--brand-primary);
  animation: applePaySpin 0.9s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
  box-shadow: 0 0 16px var(--brand-accent-glow-subtle);
}

.apple-pay-stage.is-approved .apple-pay-spinner-ring {
  animation: none;
  border-color: var(--brand-accent);
  background: var(--brand-accent-gradient);
  box-shadow: 0 10px 30px var(--brand-accent-glow);
  transform: scale(1.08);
  animation: springPop 0.45s var(--spring-bounce) forwards;
}

.apple-pay-stage.is-declined .apple-pay-spinner-ring {
  animation: none;
  border-color: #DC2626;
  background: #DC2626;
  box-shadow: 0 8px 24px rgba(220, 38, 38, 0.3);
  transform: scale(1.04);
  animation: shake 0.4s ease-in-out;
}

.apple-pay-center-icon {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-primary);
}

.apple-pay-stage.is-approved .apple-pay-center-icon {
  color: #042E1C;
}

.apple-pay-stage.is-approved .apple-pay-center-icon svg {
  animation: checkmarkBounce 0.55s var(--spring-elastic) forwards;
}

.apple-pay-stage.is-declined .apple-pay-center-icon {
  color: #FFFFFF;
}

@keyframes applePaySpin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.apple-pay-amount-hero {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.ussd-instruction-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  letter-spacing: -0.015em;
}

.apple-pay-status-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
  max-width: 330px;
}

/* Inset Grouped Details Card (iOS Settings/Apple Pay table) */
.ussd-prompt-box {
  background: var(--bg-grouped-inset);
  border: 1px solid rgba(17, 28, 22, 0.06);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.95rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  text-align: left;
  width: 100%;
}

.apple-pay-live-feedback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brand-primary);
  background: var(--brand-surface);
  padding: 0.38rem 0.85rem;
  border-radius: var(--radius-full);
  width: 100%;
  transition: all 0.25s ease;
}

.apple-pay-stage.is-declined .apple-pay-live-feedback {
  color: #991B1B;
  background: #FEF2F2;
}

.apple-pay-stage.is-approved .apple-pay-live-feedback {
  color: #065F46;
  background: #ECFDF5;
}

.ussd-pulse-dot {
  width: 7.5px;
  height: 7.5px;
  background: var(--status-success);
  border-radius: var(--radius-full);
  animation: pulseGlow 1.6s infinite;
  flex-shrink: 0;
}

.countdown-bar {
  width: 100%;
  height: 4px;
  background: rgba(60, 60, 67, 0.12);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.countdown-progress {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--brand-primary) 0%, var(--brand-accent) 100%);
  transition: width 1s linear;
}

/* Inline Checkout Banner for Non-Intrusive Feedback */
.checkout-inline-feedback {
  display: none;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.8rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 0.95rem;
  animation: fadeIn 0.2s ease-out;
}

.checkout-inline-feedback.show {
  display: flex;
}

.checkout-inline-feedback.is-error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #991B1B;
}

.checkout-inline-feedback.is-warning {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  color: #92400E;
}

.checkout-inline-feedback.is-info {
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
  color: #065F46;
}

/* Success Receipt Layout */
.receipt-header-badge {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--brand-accent-gradient);
  color: #042E1C;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  box-shadow: 0 10px 28px var(--brand-accent-glow);
  animation: springPop 0.5s var(--spring-bounce);
}

.receipt-header-badge svg {
  width: 34px;
  height: 34px;
  animation: checkmarkBounce 0.6s var(--spring-elastic);
}

.receipt-status-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.receipt-status-subtitle {
  text-align: center;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.receipt-box {
  background: var(--bg-grouped-inset);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.receipt-row.highlight {
  font-weight: 700;
  color: var(--text-main);
  font-size: 1.05rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(17, 28, 22, 0.08);
}

.receipt-value {
  font-weight: 600;
  color: var(--text-main);
  text-align: right;
}

.btn-secondary {
  width: 100%;
  min-height: 46px;
  padding: 0.75rem 1.25rem;
  background: var(--bg-grouped-inset);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background: #E8EAE8;
}

.btn-secondary:active {
  transform: scale(0.985);
}