/* =========================================================
   MODAL URGENCY COUNTDOWN
   Tampilan presisi & "tetap urgent" meski durasi sale panjang:
   - Tier color (l1 → l5) berdasarkan sisa waktu.
   - Segmented digit display (hari : jam : menit : detik).
   - Progress bar 48-jam window — selalu kelihatan ada momentum.
   - Detik berkedip halus tiap update → micro-motion = urgency.
   ========================================================= */
.modal-urgency {
  /* Posisi: tepat di bawah modal-head (yang berisi nama produk),
     di atas modal-body (yang berisi input nama & email). */
  position: relative;
  margin: 0 20px 0;
  padding: 12px 14px 10px;
  border-radius: 14px;
  background: linear-gradient(135deg, #fff7ed 0%, #fef2f2 100%);
  border: 1px solid #fed7aa;
  color: #7c2d12;
  font-family: inherit;
  overflow: hidden;
  isolation: isolate;
  transition: background .35s ease, border-color .35s ease, color .35s ease, box-shadow .35s ease;
}
.modal-urgency[hidden] { display: none !important; }

/* Flag + savings badge */
.mu-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #b45309;
}
.mu-flag-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: mu-flag-pulse 1.6s ease-in-out infinite;
}
.mu-savings {
  margin-left: 8px;
  background: #fff;
  color: #15803d;
  border: 1px solid #bbf7d0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .04em;
}
.mu-savings[hidden] { display: none; }

.mu-body {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.mu-label {
  font-size: .78rem;
  font-weight: 700;
  color: inherit;
  opacity: .82;
  letter-spacing: .01em;
}

.mu-timer {
  display: inline-flex;
  align-items: flex-end;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.mu-seg {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 8px;
  padding: 3px 7px 2px;
  min-width: 38px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  transition: background .25s ease, border-color .25s ease, color .25s ease, transform .15s ease;
}
.mu-seg b {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.02em;
  color: #111827;
  font-variant-numeric: tabular-nums;
}
.mu-seg i {
  font-style: normal;
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #9ca3af;
  margin-top: 1px;
}
.mu-sep {
  font-size: .95rem;
  font-weight: 800;
  color: #9ca3af;
  align-self: flex-start;
  padding-top: 4px;
}

/* Detik berkedip halus tiap update */
.mu-seg-s b {
  animation: mu-tick .9s ease-out;
}
@keyframes mu-tick {
  0%   { transform: translateY(-2px); opacity: .55; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Progress bar */
.mu-bar {
  margin-top: 10px;
  height: 6px;
  border-radius: 999px;
  background: rgba(0,0,0,.06);
  overflow: hidden;
}
.mu-bar-fill {
  height: 100%;
  width: 6%;
  background: linear-gradient(90deg, #fbbf24, #f97316);
  border-radius: inherit;
  transition: width .8s cubic-bezier(.22,1.1,.36,1), background .3s ease;
  box-shadow: 0 0 6px rgba(249,115,22,.4);
}

/* Collapse segmen yang tidak perlu agar makin terasa urgent.
   - <24h: sembunyikan segmen "hari" + separator setelahnya
   - <1h:  sembunyikan segmen "jam" juga
*/
.modal-urgency.mu-hide-d .mu-seg[data-seg="d"],
.modal-urgency.mu-hide-d .mu-seg[data-seg="d"] + .mu-sep { display: none; }
.modal-urgency.mu-hide-h .mu-seg[data-seg="h"],
.modal-urgency.mu-hide-h .mu-seg[data-seg="h"] + .mu-sep { display: none; }
.modal-urgency.mu-hide-h .mu-seg b { font-size: 1.25rem; }
.modal-urgency.mu-hide-h .mu-seg { min-width: 44px; }

/* =================== TIERS =================== */

/* L1: santai (>48h) — kuning lembut */
.modal-urgency.mu-l1 {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fde68a;
  color: #92400e;
}
.modal-urgency.mu-l1 .mu-bar-fill { background: linear-gradient(90deg, #fcd34d, #fbbf24); }

/* L2: oranye (12-48h) */
.modal-urgency.mu-l2 {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border-color: #fdba74;
  color: #9a3412;
}
.modal-urgency.mu-l2 .mu-bar-fill { background: linear-gradient(90deg, #fb923c, #f97316); }

/* L3: merah (1-12h) — berakhir hari ini */
.modal-urgency.mu-l3 {
  background: linear-gradient(135deg, #fff1f2 0%, #fee2e2 100%);
  border-color: #fca5a5;
  color: #991b1b;
  box-shadow: 0 0 0 0 rgba(220,38,38,0);
}
.modal-urgency.mu-l3 .mu-bar-fill { background: linear-gradient(90deg, #f87171, #dc2626); }
.modal-urgency.mu-l3 .mu-flag-dot { animation-duration: 1.1s; }

/* L4: merah pulse (5-60m) — sisa sedikit */
.modal-urgency.mu-l4 {
  background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%);
  border-color: #f87171;
  color: #7f1d1d;
  animation: mu-pulse-border 1.6s ease-in-out infinite;
}
.modal-urgency.mu-l4 .mu-bar-fill { background: linear-gradient(90deg, #ef4444, #b91c1c); }
.modal-urgency.mu-l4 .mu-seg b { color: #b91c1c; }
.modal-urgency.mu-l4 .mu-flag-dot { animation-duration: .8s; }

/* L5: detik-detik terakhir (<5m) — paling intens */
.modal-urgency.mu-l5 {
  background: linear-gradient(135deg, #fee2e2 0%, #fca5a5 100%);
  border-color: #dc2626;
  color: #7f1d1d;
  animation: mu-pulse-strong 1s ease-in-out infinite;
}
.modal-urgency.mu-l5 .mu-bar-fill {
  background: linear-gradient(90deg, #dc2626, #991b1b);
  box-shadow: 0 0 12px rgba(220,38,38,.7);
}
.modal-urgency.mu-l5 .mu-seg {
  background: #fff;
  border-color: #fca5a5;
}
.modal-urgency.mu-l5 .mu-seg b {
  color: #b91c1c;
  animation: mu-flash 1s ease-in-out infinite;
}
.modal-urgency.mu-l5 .mu-flag-dot { animation-duration: .5s; }

/* Expired */
.modal-urgency.mu-expired {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #6b7280;
}
.modal-urgency.mu-expired .mu-bar-fill {
  background: #d1d5db;
  box-shadow: none;
}
.modal-urgency.mu-expired .mu-seg b { color: #6b7280; }
.modal-urgency.mu-expired .mu-flag-dot { animation: none; opacity: .5; }

/* =================== KEYFRAMES =================== */
@keyframes mu-flag-pulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; }
  50%      { box-shadow: 0 0 0 6px rgba(255,255,255,0); }
}
@keyframes mu-pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.15); }
  50%      { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}
@keyframes mu-pulse-strong {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.35); }
  50%      { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}
@keyframes mu-flash {
  0%, 100% { opacity: 1; }
  50%      { opacity: .6; }
}

/* Mobile */
@media (max-width: 520px) {
  .modal-urgency { margin: 0 14px; padding: 11px 12px 9px; border-radius: 12px; }
  .mu-label { font-size: .72rem; }
  .mu-seg { min-width: 34px; padding: 3px 5px 2px; }
  .mu-seg b { font-size: .95rem; }
  .mu-seg i { font-size: .54rem; }
  .modal-urgency.mu-hide-h .mu-seg b { font-size: 1.1rem; }
  .modal-urgency.mu-hide-h .mu-seg { min-width: 40px; }
  .mu-flag { font-size: .64rem; }
  .mu-savings { font-size: .64rem; padding: 2px 7px; }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .modal-urgency.mu-l1 {
    background: linear-gradient(135deg, rgba(251,191,36,.08), rgba(249,115,22,.06));
    border-color: rgba(251,191,36,.35); color: #fcd34d;
  }
  .modal-urgency.mu-l2 {
    background: linear-gradient(135deg, rgba(249,115,22,.10), rgba(234,88,12,.08));
    border-color: rgba(249,115,22,.4); color: #fdba74;
  }
  .modal-urgency.mu-l3,
  .modal-urgency.mu-l4,
  .modal-urgency.mu-l5 {
    background: linear-gradient(135deg, rgba(220,38,38,.12), rgba(153,27,27,.10));
    border-color: rgba(248,113,113,.45); color: #fca5a5;
  }
  .mu-seg { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.08); }
  .mu-seg b { color: #f9fafb; }
  .mu-seg i { color: #9ca3af; }
  .mu-savings { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.35); color: #86efac; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .modal-urgency,
  .modal-urgency.mu-l4,
  .modal-urgency.mu-l5,
  .mu-flag-dot,
  .mu-seg-s b,
  .modal-urgency.mu-l5 .mu-seg b { animation: none !important; }
  .mu-bar-fill { transition: width .3s linear; }
}
