/* ==========================================================================
   KAPROD WORKSPACE — MODALS, ALERTS, & TOAST SYSTEM (OPTIMIZED)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. MODAL BACKDROP & BOX CONTAINERS
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9990;
  background: rgba(9, 13, 22, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0s linear 0.22s;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.modal-backdrop.on,
.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition: opacity 0.22s ease, visibility 0s;
}

/* Modal Box */
.modal-box {
  background: var(--surface, #0e1524);
  border: 1px solid var(--line, #1b263b);
  border-radius: var(--r-l, 16px);
  width: 100%;
  max-width: 580px;
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-pop, 0 20px 50px rgba(0, 0, 0, 0.5));
  transform: translateY(18px) scale(0.97);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.modal-backdrop.on .modal-box,
.modal-backdrop.active .modal-box {
  transform: translateY(0) scale(1);
}

/* Sub-Elemen Dalam Modal */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line, #1b263b);
}

.modal-title {
  font-family: var(--display, system-ui);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink, #f1f5f9);
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--r-s, 8px);
  border: none;
  background: var(--surface-2, #162033);
  color: var(--ink-2, #a3b0c4);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.modal-close:hover {
  background: var(--surface-3, #1e2a40);
  color: var(--ink, #f1f5f9);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  margin-top: 20px;
  border-top: 1px solid var(--line, #1b263b);
}

/* Ukuran Modal */
.modal-sm { max-width: 400px; }
.modal-lg { max-width: 800px; }
.modal-full { max-width: 95vw; height: 92vh; height: 92dvh; }

/* --------------------------------------------------------------------------
   2. GLOBAL ALERT CALLOUTS
   -------------------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-m, 12px);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  border: 1px solid transparent;
}

.alert-err  { background: var(--err-soft, rgba(239, 68, 68, 0.12));  border-color: rgba(239, 68, 68, 0.25);  color: var(--err, #ef4444); }
.alert-ok   { background: var(--ok-soft, rgba(16, 185, 129, 0.12)); border-color: rgba(16, 185, 129, 0.25); color: var(--ok, #10b981); }
.alert-warn { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.25); color: var(--brand-ink); }
.alert-info { background: rgba(59, 130, 246, 0.12); border-color: rgba(59, 130, 246, 0.25); color: var(--info); }

/* --------------------------------------------------------------------------
   3. TOAST NOTIFICATIONS
   -------------------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  background: var(--surface-3, #1e2a40);
  color: var(--ink, #f1f5f9);
  border: 1px solid var(--line-strong, #2d3b55);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  z-index: 10001;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.on, .toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.toast[data-type="error"], .toast.error     { border-left: 4px solid var(--err, #ef4444); }
.toast[data-type="success"], .toast.success { border-left: 4px solid var(--ok, #10b981); }
.toast[data-type="warning"], .toast.warning { border-left: 4px solid var(--brand, #f59e0b); }

/* --------------------------------------------------------------------------
   4. KEYFRAME ANIMATIONS
   -------------------------------------------------------------------------- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.view-enter > * {
  animation: fadeUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.stagger > * {
  animation: popIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}

/* --------------------------------------------------------------------------
   5. RESPONSIVE MOBILE ADAPTATION (Bottom Sheet Modal di HP <= 640px)
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal-box {
    max-width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
  }

  .modal-backdrop.on .modal-box,
  .modal-backdrop.active .modal-box {
    transform: translateY(0);
  }

  .toast {
    font-size: 12.5px;
    padding: 10px 16px;
  }
}