/* Social Proof: badge "X terjual" + popup riwayat pembelian */

/* Badge pada product card */
.sp-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  white-space: nowrap;
  letter-spacing: -0.01em;
  margin-top: 0.375rem;
}
.katalog-card-badge {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}
.sp-badge-sold {
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}
.sp-badge-sold i {
  color: #6366f1;
  font-size: 0.75rem;
}
.sp-badge-new {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* Badge di product-detail header */
.sp-badge-detail {
  font-size: 0.75rem;
  padding: 0.3rem 0.625rem;
  margin-top: 0.25rem;
}

/* Popup riwayat pembelian — pojok kiri bawah */
.sp-popup {
  position: fixed;
  left: 1rem;
  bottom: 5rem;
  z-index: 900;
  max-width: 320px;
  width: calc(100vw - 2rem);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.04);
  padding: 0.875rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.sp-popup.sp-popup-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.sp-popup.sp-popup-exit {
  opacity: 0;
  transform: translateY(16px);
}

.sp-popup-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.625rem;
  background: #eef2ff;
  color: #4f46e5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.125rem;
}

.sp-popup-body {
  flex: 1;
  min-width: 0;
}
.sp-popup-buyer {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}
.sp-popup-product {
  font-size: 0.75rem;
  color: #475569;
  line-height: 1.3;
  margin-top: 0.125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sp-popup-time {
  font-size: 0.6875rem;
  color: #94a3b8;
  margin-top: 0.25rem;
}

.sp-popup-close {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  width: 1.5rem;
  height: 1.5rem;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.sp-popup-close:hover {
  background: #f1f5f9;
  color: #475569;
}

/* Desktop: popup lebih besar sedikit, posisi lebih rendah agar tidak menutupi nav */
@media (min-width: 768px) {
  .sp-popup {
    max-width: 360px;
    bottom: 1.5rem;
    left: 1.5rem;
    padding: 1rem 1.25rem;
  }
  .sp-popup-buyer { font-size: 0.875rem; }
  .sp-popup-product { font-size: 0.8125rem; }
}

/* Reduced motion: tampilkan langsung tanpa animasi */
@media (prefers-reduced-motion: reduce) {
  .sp-popup {
    transition: none;
  }
  .sp-popup.sp-popup-visible {
    transform: none;
  }
  .sp-popup.sp-popup-exit {
    transform: none;
  }
}

/* Popup hidden state untuk dismiss permanen via localStorage */
.sp-popup.sp-popup-dismissed {
  display: none !important;
}

/* Mobile: popup dipindah ke atas agar tidak menindih tombol beli dan kartu paket.
   Kasus nyata: di layar 390px popup pojok kiri bawah menutupi CTA "Beli Starter". */
@media (max-width: 767px) {
  .sp-popup {
    top: 76px;
    bottom: auto;
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    max-width: none;
    padding: 0.75rem 0.875rem;
    transform: translateY(-12px);
  }
  .sp-popup.sp-popup-visible { transform: translateY(0); }
  .sp-popup.sp-popup-exit { transform: translateY(-12px); }
}
