/* =====================================================
   SONNER-STYLE TOAST NOTIFICATIONS
   Modern, stackable, auto-dismiss toast system
   ===================================================== */

/* Container - top-center */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 420px;
  width: calc(100% - 48px);
}

/* Individual toast */
.toast-item {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  color: #1e293b;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform: translateX(0) scale(1);
  opacity: 1;
  transition:
    transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.3s ease;
  will-change: transform, opacity;
  cursor: default;
  overflow: hidden;
  position: relative;
}

/* Entry animation */
.toast-item--entering {
  transform: translateY(-100%) scale(0.95);
  opacity: 0;
}

/* Exit animation */
.toast-item--exiting {
  transform: translateY(-100%) scale(0.95);
  opacity: 0;
  transition:
    transform 0.3s cubic-bezier(0.4, 0, 1, 1),
    opacity 0.2s ease;
}

/* Swipe hint on hover */
.toast-item:hover {
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.1),
    0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Progress bar (auto-dismiss timer) */
.toast-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 12px 12px;
  background: currentColor;
  opacity: 0.15;
  animation: toast-progress var(--toast-duration, 5s) linear forwards;
}

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

@keyframes toast-progress {
  from { width: 100%; }
  to { width: 0%; }
}

/* Icon container */
.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-top: 1px;
}

/* Content */
.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 13.5px;
  color: #0f172a;
  margin: 0 0 2px;
  line-height: 1.3;
}

.toast-message {
  font-size: 13px;
  color: #475569;
  margin: 0;
  line-height: 1.45;
  word-break: break-word;
}

/* When there's no title, make the message the primary text */
.toast-content:not(:has(.toast-title)) .toast-message {
  color: #1e293b;
  font-weight: 500;
}

/* Close button */
.toast-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #94a3b8;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  transition: all 0.15s ease;
  opacity: 0;
  margin-top: -2px;
}

.toast-item:hover .toast-close {
  opacity: 1;
}

.toast-close:hover {
  background: #f1f5f9;
  color: #475569;
}

/* ---- Variants ---- */

/* Success */
.toast-item--success {
  border-color: #d1fae5;
  background: linear-gradient(135deg, #fff 60%, #f0fdf4);
}
.toast-item--success .toast-icon { color: #10b981; }
.toast-item--success::after { background: #10b981; }

/* Error / Danger */
.toast-item--error,
.toast-item--danger {
  border-color: #fecaca;
  background: linear-gradient(135deg, #fff 60%, #fef2f2);
}
.toast-item--error .toast-icon,
.toast-item--danger .toast-icon { color: #ef4444; }
.toast-item--error::after,
.toast-item--danger::after { background: #ef4444; }

/* Warning */
.toast-item--warning {
  border-color: #fde68a;
  background: linear-gradient(135deg, #fff 60%, #fffbeb);
}
.toast-item--warning .toast-icon { color: #f59e0b; }
.toast-item--warning::after { background: #f59e0b; }

/* Info */
.toast-item--info {
  border-color: #bfdbfe;
  background: linear-gradient(135deg, #fff 60%, #eff6ff);
}
.toast-item--info .toast-icon { color: #3b82f6; }
.toast-item--info::after { background: #3b82f6; }

/* Default / message (no specific category) */
.toast-item--message,
.toast-item--default {
  border-color: #e2e8f0;
}
.toast-item--message .toast-icon,
.toast-item--default .toast-icon { color: #64748b; }

/* ---- Stacking effect (Sonner-style) ---- */
.toast-container .toast-item:nth-last-child(n+4) {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9) translateY(20px);
}

.toast-container .toast-item:nth-last-child(3) {
  opacity: 0.6;
  transform: scale(0.94) translateY(8px);
}

.toast-container .toast-item:nth-last-child(2) {
  opacity: 0.8;
  transform: scale(0.97) translateY(4px);
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .toast-container {
    top: 16px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    transform: none;
  }
}
