/* ==========================================================
   WISAXIS — MODAL & NOTIFICATION COMPONENTS (2026 SaaS Design System)
   Toast notifications, alerts, modal dialogs, and overlays.
   ========================================================== */

/* ===== MODAL BACKDROP & CARD ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: var(--z-modal, 9000);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: backdropFadeIn 0.3s var(--ease-out-smooth) both;
}

.modal-card {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-2xl);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  position: relative;
  animation: modalEnter 0.35s var(--ease-spring) both;
  transform-origin: center center;
}

@media (max-width: 600px) {
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-card {
    max-width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-radius: 24px 24px 0 0;
    max-height: 85vh;
    animation: modalSheetUp 0.35s var(--ease-spring) both;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
  }

  @keyframes modalSheetUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
}

html[data-theme="light"] .modal-overlay {
  background: rgba(15, 23, 42, 0.45);
}

html[data-theme="light"] .modal-card {
  background: #ffffff;
  border-color: var(--border-default);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--text-main);
  letter-spacing: var(--tracking-tight);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.2s, transform 0.2s var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}

.modal-close-btn:hover,
.modal-close-btn:active {
  color: var(--text-main);
  transform: scale(1.1);
}

.modal-body {
  padding: 1.5rem;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== TOAST CONTAINER ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: var(--z-toast, 10000);
  max-width: 380px;
  width: calc(100% - 48px);
  pointer-events: none;
}

/* ===== TOAST BASE ===== */
.toast {
  pointer-events: auto;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: #ffffff;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border-strong);
  position: relative;
  overflow: hidden;
  animation: toastIn 0.35s var(--ease-spring) both;
  transition: transform 0.25s var(--ease-spring), opacity 0.25s ease;
}

.toast:hover {
  transform: translateY(-2px) scale(1.02);
}

.toast.toast-dismissing {
  animation: toastOut 0.3s var(--ease-out-smooth) forwards;
}

/* Toast progress countdown bar */
.toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: currentColor;
  opacity: 0.4;
  animation: toastProgressBar 3.8s linear forwards;
}

.toast:hover::after {
  animation-play-state: paused;
}

@keyframes toastProgressBar {
  from { width: 100%; }
  to   { width: 0%; }
}

/* ===== TOAST VARIANTS ===== */
.toast-success {
  background: rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.5);
  color: #34d399;
}

.toast-error {
  background: rgba(244, 63, 94, 0.25);
  border-color: rgba(244, 63, 94, 0.5);
  color: #fda4af;
}

html[data-theme="light"] .toast-success {
  background: #ffffff;
  border-color: rgba(16, 185, 129, 0.4);
  color: #059669;
  box-shadow: var(--shadow-md);
}

html[data-theme="light"] .toast-error {
  background: #ffffff;
  border-color: rgba(244, 63, 94, 0.4);
  color: #e11d48;
  box-shadow: var(--shadow-md);
}

/* ===== TOAST ANIMATIONS ===== */
@keyframes toastIn {
  0% {
    opacity: 0;
    transform: translateY(24px) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(16px) scale(0.92);
  }
}

/* ===== MOBILE TOAST ===== */
@media (max-width: 500px) {
  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
    width: auto;
    max-width: none;
  }

  .toast {
    font-size: var(--text-xs);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
  }
}
