/* KFAST — Mobile Polish (Android + iOS). Aditif, muat paling akhir. */

/* 1. Stop zoom paksa iOS saat tap input */
@media (max-width: 991.98px) {
  input[type="text"], input[type="number"], input[type="email"],
  input[type="password"], input[type="search"], input[type="tel"],
  input[type="url"], select, textarea,
  .form-control, .form-select { font-size: 16px !important; }
}

/* 2. Area tap nyaman (44px = standar Apple HIG) */
@media (max-width: 991.98px) {
  .btn, .form-control, .form-select, .nav-link, .dropdown-item { min-height: 44px; }
  .btn-sm, .btn-xs { min-height: 36px; }
  .btn + .btn { margin-left: 6px; }
}

/* 3. Feedback tekan halus, tanpa kotak biru */
* { -webkit-tap-highlight-color: transparent; }
@media (hover: none) {
  .btn:active, .nav-link:active, .list-group-item-action:active {
    transform: scale(0.97); transition: transform 0.08s ease-out;
  }
}

/* 4. Scroll native + cegah pull-to-refresh tak sengaja */
body, .modal-body, .table-responsive, .offcanvas-body { -webkit-overflow-scrolling: touch; }
.modal-body, .table-responsive, .offcanvas-body { overscroll-behavior: contain; }

/* 5. Safe area iPhone (bottom-nav sudah punya padding sendiri) */
@supports (padding: max(0px)) {
  .modal-footer, .offcanvas-bottom, .fixed-bottom:not(.bottom-nav) {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  @media (max-width: 767px) {
    body { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  }
  @media (orientation: landscape) {
    .container, .container-fluid {
      padding-left: max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
    }
  }
}

/* 6. Teks tidak melompat saat rotasi */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* 7. Angka lebar seragam — saldo tidak bergoyang saat berubah */
.saldo, .price, .amount, td.text-end, .font-numeric { font-variant-numeric: tabular-nums; }

@media (max-width: 767.98px) {
  .table td, .table th { word-break: normal; }
}

/* 8. Hormati preferensi reduce-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
/* kfast loading states */
.kf-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #6b7280;
}
.kf-dots span:not(.kf-dots-text) {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  animation: kf-dot .9s infinite ease-in-out;
}
.kf-dots span:not(.kf-dots-text):nth-child(2) { animation-delay: .15s; }
.kf-dots span:not(.kf-dots-text):nth-child(3) { animation-delay: .3s; }
.kf-dots-text {
  margin-left: 6px;
  font-size: 13px;
  color: #9ca3af;
}
@keyframes kf-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30%           { transform: translateY(-7px); opacity: 1; }
}
.kf-sk {
  background: rgba(0, 0, 0, .09);
  border-radius: 6px;
  animation: kf-sk 1.4s infinite ease-in-out;
}
.kf-sk-row {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 14px 0;
  border-bottom: .5px solid rgba(0, 0, 0, .08);
}
.kf-sk-line { display: flex; justify-content: space-between; gap: 12px; }
@keyframes kf-sk {
  0%, 100% { opacity: 1; }
  50%      { opacity: .4; }
}
.kf-spin {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: kf-spin .7s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}
.btn-outline-primary .kf-spin,
.btn-light .kf-spin {
  border-color: rgba(0, 0, 0, .2);
  border-top-color: currentColor;
}
button[disabled] .kf-spin { opacity: .9; }
@keyframes kf-spin { to { transform: rotate(360deg); } }
@media (prefers-color-scheme: dark) {
  .kf-sk { background: rgba(255, 255, 255, .13); }
  .kf-sk-row { border-bottom-color: rgba(255, 255, 255, .1); }
}
@media (prefers-reduced-motion: reduce) {
  .kf-dots span:not(.kf-dots-text) { animation: none; opacity: .6; }
  .kf-sk   { animation: none; opacity: .7; }
  .kf-spin { animation-duration: 1.6s; }
}

/* spinner sunburst - menggantikan tampilan .spinner-border */
.spinner-border {
  position: relative;
  width: 32px; height: 32px;
  border: 0 !important;
  animation: none !important;
  color: #3b82f6;
}
.spinner-border.spinner-border-sm { width: 18px; height: 18px; color: currentColor; }
.spinner-border > i {
  position: absolute; left: 50%; top: 4%;
  width: 2px; height: 25%;
  margin-left: -1px;
  border-radius: 1px;
  background: currentColor;
  transform-origin: 1px 184%;
  animation: kf-burst 1.1s linear infinite;
  opacity: .15;
}
@keyframes kf-burst { 0% { opacity: 1; } 80%, 100% { opacity: .15; } }
@media (prefers-reduced-motion: reduce) {
  .spinner-border > i { animation: none; opacity: .5; }
}

/* tombol terkunci saat proses */
button:disabled, .btn:disabled, .btn.disabled {
  background: #9ca3af !important;
  background-image: none !important;
  border-color: #9ca3af !important;
  color: #f3f4f6 !important;
  cursor: not-allowed !important;
  opacity: 1 !important;
  box-shadow: none !important;
}

/* ringkas detail pesanan di HP */
@media (max-width: 767px) {
  #detailModal .modal-body { padding: 1rem !important; }
  #detailModal .row { --bs-gutter-y: .5rem !important; }
  #detailModal .rounded-3 { padding: .5rem .75rem !important; }
  #detailModal .form-control { height: auto !important; padding: 0 !important; font-size: 15px !important; background: transparent !important; }
  #detailModal .input-group { align-items: center; }
  #detailModal .copy-btn { padding: .15rem .5rem !important; border: 0 !important; }
  #detailModal small { font-size: 11px !important; margin-bottom: 0 !important; }
}

/* spinner otomatis di tombol yang sedang memproses */
button:disabled::after, .btn:disabled::after {
  content: "";
  display: inline-block;
  width: 14px; height: 14px;
  margin-left: 9px;
  vertical-align: -2px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: kf-spin .7s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  button:disabled::after, .btn:disabled::after { animation-duration: 1.8s; }
}

/* halaman pembayaran lebih tegas */
.payment-amount .fs-3 { font-size: 2rem !important; line-height: 1.1; display: block; margin-top: 4px; }
.payment-amount strong { font-size: 13px; color: #64748b; font-weight: 500; }
#pending-countdown { background: #dc2626; color: #fff !important; padding: 3px 10px; border-radius: 999px; font-size: 15px; letter-spacing: .5px; }
