/* Palet Warna Brand BMI & Status Alert Modern */
:root {
  /* Status Warna Berbasis Komponen Brand BMI */
  --primary-success: #10b981; /* Hijau Emerald Sukses */
  --primary-error: #dc2626;   /* Merah BMI / Bahaya */
  --primary-warning: #d97706; /* Kuning Amber / Peringatan */
  --primary-info: #7f6000;    /* Perunggu Ochre BMI */
  --primary-sage: #e2f0d9;    /* Soft Sage Green BMI */
  --primary-read: #64748b;    /* Slate Gray / Netral */

  /* Light Accent untuk Efek Kontras Ringan */
  --success-light: #ecfdf5;
  --error-light: #fee2e2;
  --warning-light: #fef3c7;
  --info-light: #fbf5e6;
  --read-light: #f1f5f9;

  /* Gradasi Tema Enterprise BMI */
  --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --error-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --warning-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --info-gradient: linear-gradient(135deg, #7f6000 0%, #574200 100%);
  --sage-gradient: linear-gradient(135deg, #e2f0d9 0%, #cfe6c3 100%);
  --read-gradient: linear-gradient(135deg, #64748b 0%, #475569 100%);

  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.15);
  --shadow-medium: 0 12px 35px rgba(0, 0, 0, 0.25);
}

/* Backdrop Popup dengan efek glassmorphism modern */
.popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 22, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Tampilkan Popup */
.popup-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Kontainer Popup yang lebih compact */
.popup-container {
  background: white;
  border-radius: 18px;
  padding: 24px;
  max-width: 390px;
  width: 88%;
  transform: translateY(-20px) scale(0.95);
  transition: transform 0.35s cubic-bezier(0.18, 1.25, 0.4, 1);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.2), 0 0 20px rgba(127, 96, 0, 0.1);
  border: 1px solid rgba(127, 96, 0, 0.25);
  position: relative;
  overflow: hidden;
}

.popup-container::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3.5px;
  background: linear-gradient(90deg, #7f6000, #e2f0d9, #7f6000);
}

/* Efek kilau lebih subtle */
.popup-container::before {
  content: "";
  position: absolute;
  top: -100%;
  left: -100%;
  width: 250%;
  height: 250%;
  background: linear-gradient(
    to bottom right,
    rgba(255, 255, 255, 0.15),
    rgba(255, 255, 255, 0.01)
  );
  transform: rotate(25deg);
  animation: shine 4s infinite;
  pointer-events: none;
  opacity: 0.7;
}

/* Efek Muncul */
.popup-backdrop.active .popup-container {
  transform: translateY(0) scale(1);
}

/* Ikon Close yang lebih kecil */
.popup-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: #a89a8e;
  transition: all 0.2s ease;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.popup-close:hover {
  color: var(--primary-info);
  background: rgba(184, 115, 51, 0.1);
  transform: rotate(90deg);
}

/* Animasi Ikon yang lebih compact */
.popup-icon {
  text-align: center;
  font-size: 56px;
  margin: 10px 0 15px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  animation: iconBounce 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  position: relative;
}

/* Efek lingkaran di belakang ikon lebih kecil */
.popup-icon::before {
  content: "";
  position: absolute;
  width: 70px;
  height: 70px;
  background: rgba(138, 82, 34, 0.05);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: -1;
}

/* ============================================================
   EMOTICON & ANIMASI POPUP BERHASIL (SUCCESS) LEBIH MENARIK
   ============================================================ */
.popup-icon.success {
  margin: 4px 0 10px;
  animation: none;
  filter: none;
}

.popup-icon.success::before {
  display: none !important;
}

.popup-success-animated {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 96px;
  height: 96px;
  user-select: none;
}

/* Glow Radial Pulsa di Belakang */
.popup-success-glow {
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.35) 0%, rgba(16, 185, 129, 0.12) 50%, rgba(16, 185, 129, 0) 75%);
  animation: successGlowPulse 2.4s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

/* Lingkaran Cincin Gelombang Pop-in */
.popup-success-ring {
  position: absolute;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  border: 2.5px solid rgba(16, 185, 129, 0.85);
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.85) 0%, rgba(209, 250, 229, 0.45) 100%);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.25), inset 0 0 12px rgba(16, 185, 129, 0.15);
  animation: ringPopIn 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  z-index: 1;
}

/* Wrapper Emoticon */
.popup-success-emoji-wrap {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
}

/* Emoticon Utama */
.popup-success-emoji {
  font-size: 48px;
  line-height: 1;
  display: inline-block;
  transform-origin: center bottom;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.15));
  animation: emojiCelebrate 0.75s cubic-bezier(0.34, 1.56, 0.64, 1) both,
             emojiJoyDance 2.5s ease-in-out infinite 0.75s;
}

/* Badge Centang Sukses di Pojok */
.popup-success-check-badge {
  position: absolute;
  bottom: 5px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border: 2.5px solid #ffffff;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.45);
  z-index: 4;
  animation: badgeSpringIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

/* Partikel Ledakan Konfeti / Bintang */
.popup-success-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.popup-success-particles .particle {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 15px;
  line-height: 1;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0);
}

.popup-success-particles .p-1 {
  animation: burstP1 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.12s forwards, twinkleP 2s ease-in-out infinite 0.85s;
}
.popup-success-particles .p-2 {
  animation: burstP2 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.16s forwards, twinkleP 2.2s ease-in-out infinite 0.88s;
}
.popup-success-particles .p-3 {
  animation: burstP3 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.14s forwards, twinkleP 1.8s ease-in-out infinite 0.86s;
}
.popup-success-particles .p-4 {
  animation: burstP4 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.18s forwards, twinkleP 2.4s ease-in-out infinite 0.9s;
}
.popup-success-particles .p-5 {
  animation: burstP5 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.15s forwards, twinkleP 1.9s ease-in-out infinite 0.87s;
}
.popup-success-particles .p-6 {
  animation: burstP6 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.2s forwards, twinkleP 2.1s ease-in-out infinite 0.92s;
}

/* Keyframes */
@keyframes ringPopIn {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes emojiCelebrate {
  0% { transform: scale(0) rotate(-25deg); opacity: 0; }
  50% { transform: scale(1.35) rotate(14deg); opacity: 1; }
  75% { transform: scale(0.92) rotate(-6deg); }
  90% { transform: scale(1.08) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes emojiJoyDance {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  25% { transform: translateY(-5px) rotate(-4deg) scale(1.03); }
  50% { transform: translateY(0px) rotate(0deg) scale(1); }
  75% { transform: translateY(-4px) rotate(4deg) scale(1.03); }
}

@keyframes badgeSpringIn {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes successGlowPulse {
  0%, 100% { transform: scale(1); opacity: 0.65; }
  50% { transform: scale(1.18); opacity: 0.95; }
}

@keyframes burstP1 {
  0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(calc(-50% + 34px), calc(-50% - 32px)) scale(1) rotate(25deg); opacity: 1; }
}

@keyframes burstP2 {
  0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(calc(-50% - 36px), calc(-50% - 28px)) scale(1.1) rotate(-30deg); opacity: 1; }
}

@keyframes burstP3 {
  0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(calc(-50% + 40px), calc(-50% + 4px)) scale(0.95) rotate(45deg); opacity: 1; }
}

@keyframes burstP4 {
  0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(calc(-50% - 38px), calc(-50% + 14px)) scale(1.05) rotate(-20deg); opacity: 1; }
}

@keyframes burstP5 {
  0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(calc(-50% + 2px), calc(-50% - 42px)) scale(1) rotate(15deg); opacity: 1; }
}

@keyframes burstP6 {
  0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(calc(-50% - 22px), calc(-50% + 36px)) scale(0.9) rotate(-15deg); opacity: 1; }
}

@keyframes twinkleP {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.2); filter: brightness(1.3); }
}

/* Judul dan Pesan yang lebih compact */
.popup-title {
  font-size: 1.45rem;
  margin-bottom: 10px;
  text-align: center;
  color: #1c2817;
  letter-spacing: -0.3px;
  line-height: 1.3;
  font-weight: 700;
}

.popup-message {
  text-align: center;
  color: #475569;
  margin-bottom: 20px;
  font-size: 0.94rem;
  line-height: 1.5;
  padding: 0 10px;
}

/* Tombol yang lebih compact */
.popup-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.popup-button {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  min-width: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
  letter-spacing: 0.3px;
  font-size: 0.9rem;
}

.popup-button::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(255, 255, 255, 0.2), transparent);
  transform: translateY(100%);
  transition: transform 0.2s ease;
}

.popup-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.25);
}

.popup-button:hover::before {
  transform: translateY(0);
}

.popup-button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Warna Sesuai Tipe */
.success { color: var(--primary-success); }
.error { color: var(--primary-error); }
.warning { color: var(--primary-warning); }
.info { color: var(--primary-info); }
.sage { color: #3b5a2b; }
.read { color: var(--primary-read); }

.success-bg { background: var(--success-gradient); color: white; }
.error-bg { background: var(--error-gradient); color: white; }
.warning-bg { background: var(--warning-gradient); color: white; }
.info-bg { background: var(--info-gradient); color: white; }
.sage-bg { background: var(--sage-gradient); color: #1c2817; border: 1px solid #c5e0b7; }
.read-bg { background: var(--read-gradient); color: white; }

/* Progress Bar lebih tipis */
.popup-progress {
  height: 3px;
  width: 100%;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 15px;
  position: relative;
}

.popup-progress-bar {
  height: 100%;
  width: 100%;
  border-radius: 2px;
  animation: progressBar 5s linear forwards;
  transform-origin: left;
}

/* Animasi */
@keyframes iconBounce {
  0% { transform: scale(0.7); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shine {
  0% { transform: rotate(25deg) translate(-20%, -20%); }
  100% { transform: rotate(25deg) translate(80%, 80%); }
}

@keyframes progressBar {
  0% { transform: scaleX(1); }
  100% { transform: scaleX(0); }
}

/* ===================== RESPONSIVE DESIGN ===================== */

/* Mobile (≤ 480px) */
@media (max-width: 480px) {
  .popup-container {
    width: 90%;
    padding: 20px 15px 15px;
    max-width: 90%;
    border-radius: 14px;
  }
  .popup-title { font-size: 1.3rem; }
  .popup-message { font-size: 0.85rem; margin-bottom: 15px; padding: 0 5px; }
  .popup-icon { font-size: 48px; margin: 5px 0 10px; }
  .popup-icon::before { width: 60px; height: 60px; }
  .popup-button { padding: 8px 16px; min-width: 90px; font-size: 0.85rem; border-radius: 8px; }
  .popup-buttons { gap: 8px; }
  .popup-close { top: 8px; right: 8px; width: 26px; height: 26px; font-size: 1.2rem; }
}

/* Tablet (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
  .popup-container { max-width: 75%; padding: 22px 20px 18px; }
  .popup-title { font-size: 1.4rem; }
  .popup-message { font-size: 0.9rem; }
  .popup-button { padding: 9px 18px; min-width: 95px; }
}

/* Integrasi Sempurna dengan Bootstrap Dark Theme */
[data-bs-theme="dark"] .popup-container {
  background-color: #161c24 !important;
  border: 1px solid rgba(127, 96, 0, 0.35) !important;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 25px rgba(127, 96, 0, 0.15) !important;
}

[data-bs-theme="dark"] .popup-title { color: #f8fafc !important; }
[data-bs-theme="dark"] .popup-message { color: #cbd5e1 !important; }
[data-bs-theme="dark"] .popup-close { color: #94a3b8 !important; }
[data-bs-theme="dark"] .popup-close:hover { color: #e2f0d9 !important; background: rgba(226, 240, 217, 0.1) !important; }
[data-bs-theme="dark"] .popup-icon::before { background: rgba(127, 96, 0, 0.2) !important; }
[data-bs-theme="dark"] .sage { color: #e2f0d9 !important; }