/**
 * Admin UI: Loading halaman, loading tombol, modal konfirmasi, notifikasi toast
 */

/* ========== PAGE LOADING OVERLAY ========== */
#admin-page-loader {
  position: fixed;
  inset: 0;
  background: rgba(44, 62, 80, 0.92);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
#admin-page-loader.show {
  opacity: 1;
  visibility: visible;
}
#admin-page-loader .loader-spinner {
  width: 56px;
  height: 56px;
  border: 4px solid rgba(241, 196, 15, 0.3);
  border-top-color: #f1c40f;
  border-radius: 50%;
  animation: admin-spin 0.9s linear infinite;
}
#admin-page-loader .loader-text {
  margin-top: 16px;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.05em;
}
@keyframes admin-spin {
  to { transform: rotate(360deg); }
}

/* ========== BUTTON LOADING STATE ========== */
.btn-loading,
button.btn-loading,
a.btn-loading,
input[type="submit"].btn-loading {
  pointer-events: none !important;
  opacity: 0.85;
  position: relative;
}
.btn-loading .btn-loading-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-right: 8px;
  vertical-align: middle;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: admin-spin 0.7s linear infinite;
}
.btn-loading .btn-loading-text {
  vertical-align: middle;
}

/* ========== CUSTOM CONFIRM MODAL ========== */
#admin-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  backdrop-filter: blur(4px);
}
#admin-confirm-overlay.show {
  opacity: 1;
  visibility: visible;
}
#admin-confirm-box {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 420px;
  width: 100%;
  padding: 28px 24px;
  transform: scale(0.9) translateY(10px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid rgba(0, 0, 0, 0.06);
}
#admin-confirm-overlay.show #admin-confirm-box {
  transform: scale(1) translateY(0);
}
#admin-confirm-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f39c12 0%, #f1c40f 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 18px;
  animation: admin-pulse-icon 2s ease-in-out infinite;
}
@keyframes admin-pulse-icon {
  0%, 100% { box-shadow: 0 0 0 0 rgba(241, 196, 15, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(241, 196, 15, 0); }
}
#admin-confirm-title {
  font-size: 18px;
  font-weight: 700;
  color: #2c3e50;
  margin: 0 0 8px;
  text-align: center;
}
#admin-confirm-msg {
  font-size: 14px;
  color: #5a6c7d;
  line-height: 1.5;
  margin: 0 0 24px;
  text-align: center;
}
#admin-confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
#admin-confirm-actions .admin-confirm-btn {
  min-width: 100px;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
#admin-confirm-actions .admin-confirm-btn:hover {
  transform: translateY(-1px);
}
#admin-confirm-actions .admin-confirm-btn.cancel {
  background: #ecf0f1;
  color: #2c3e50;
}
#admin-confirm-actions .admin-confirm-btn.confirm.danger {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(231, 76, 60, 0.4);
}
#admin-confirm-actions .admin-confirm-btn.confirm.primary {
  background: linear-gradient(135deg, #0984e3 0%, #0770c7 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(9, 132, 227, 0.4);
}
#admin-confirm-actions .admin-confirm-btn.confirm:not(.primary):not(.danger) {
  background: linear-gradient(135deg, #636e72 0%, #4a5568 100%);
  color: #fff;
}

/* ========== TOAST CONTAINER ========== */
#admin-toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 100001;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 380px;
  width: calc(100vw - 48px);
  pointer-events: none;
}
@media (max-width: 480px) {
  #admin-toast-container {
    top: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
    width: auto;
  }
}

/* ========== TOAST ITEM ========== */
.admin-toast {
  pointer-events: auto;
  position: relative;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.1);
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  overflow: hidden;
  transform: translateX(120%) scale(0.9);
  opacity: 0;
  animation: admin-toast-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  border-left: 4px solid #3498db;
}
.admin-toast.hide {
  animation: admin-toast-out 0.35s ease forwards;
}
.admin-toast.success { border-left-color: #00b894; }
.admin-toast.error { border-left-color: #e74c3c; }
.admin-toast.warning { border-left-color: #f39c12; }
.admin-toast.info { border-left-color: #3498db; }

.admin-toast-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}
.admin-toast.success .admin-toast-icon { background: linear-gradient(135deg, #00b894 0%, #00cec9 100%); }
.admin-toast.error .admin-toast-icon { background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%); }
.admin-toast.warning .admin-toast-icon { background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%); }
.admin-toast.info .admin-toast-icon { background: linear-gradient(135deg, #3498db 0%, #2980b9 100%); }

.admin-toast-body {
  flex: 1;
  min-width: 0;
}
.admin-toast-title {
  font-size: 14px;
  font-weight: 700;
  color: #2c3e50;
  margin: 0 0 4px;
}
.admin-toast-msg {
  font-size: 13px;
  color: #5a6c7d;
  line-height: 1.45;
  margin: 0;
}
.admin-toast-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  color: #7f8c8d;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}
.admin-toast-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #2c3e50;
}

@keyframes admin-toast-in {
  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}
@keyframes admin-toast-out {
  to {
    transform: translateX(120%) scale(0.9);
    opacity: 0;
  }
}

/* Progress bar under toast (optional) */
.admin-toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 0 0 14px 14px;
  overflow: hidden;
}
.admin-toast-progress-bar {
  height: 100%;
  background: currentColor;
  opacity: 0.5;
  width: 100%;
  animation: admin-toast-progress 4s linear forwards;
  transform-origin: left;
}
@keyframes admin-toast-progress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}
