/* Toast - Glassmorphism / Liquid */
/* Uses CSS vars from variables.css: --toast-bg, --toast-border, --toast-title, --toast-desc, --toast-close */
/* Variant colors: --info-color, --success-color, --error-color */

#toast-container {
  position: fixed;
  top: 11%;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 80; /* above all floating panels (bring-to-front z counter starts at 46) */
  font-family: 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;
  pointer-events: none;
}

#toast-container .toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  width: 100%;
  max-width: 380px;
  padding: 16px;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  /* Liquid Glass Effect */
  background: var(--toast-bg);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid var(--toast-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: toast-slide-in 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

#toast-container .toast.toast-exit {
  animation: toast-shrink-out 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Accent Glow */
#toast-container .toast::before {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(135deg, var(--toast-accent) 0%, transparent 40%);
  opacity: 0.15;
  z-index: 0;
  pointer-events: none;
}

#toast-container .toast-info { --toast-accent: #3b82f6; }
#toast-container .toast-success { --toast-accent: #22c55e; }
#toast-container .toast-error { --toast-accent: #ef4444; }

.toast-icon-wrapper {
  z-index: 1;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  color: var(--toast-accent);
  font-size: 1.2rem;
}

/* Exact design colors for icon backgrounds */
.toast-info .toast-icon-wrapper { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.toast-success .toast-icon-wrapper { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.toast-error .toast-icon-wrapper { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

.toast-content {
  flex-grow: 1;
  z-index: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--toast-title);
  margin-bottom: 2px;
}

.toast-error .toast-title {
  color: #ef4444;
}

.toast-description {
  font-size: 0.85rem;
  color: var(--toast-desc);
  line-height: 1.4;
  /* Never let a long/raw error string blow up the toast: clamp height, wrap hard,
     keep line breaks readable. Full detail belongs in the AI-agent payload, not here. */
  white-space: pre-line;
  overflow-wrap: anywhere;
  max-height: 5.6em;
  overflow-y: auto;
}

.toast-description:empty {
  display: none;
}

.toast-close {
  z-index: 1;
  background: none;
  border: none;
  color: var(--toast-close);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
  flex-shrink: 0;
  line-height: 1;
}

.toast-close:hover {
  color: var(--toast-title);
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-shrink-out {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
}

@media (max-width: 480px) {
  #toast-container {
    left: 12px;
    right: 12px;
    top: 11%;
    max-width: none;
  }

  #toast-container .toast {
    max-width: none;
  }
}
