/* ==========================================================================
   Responsive Minimal Toast Notification System
   Defined width, closable, with error, warning, and success distinctions.
   ========================================================================== */

/* Toast Container - Fixed Position & Top-Level Stacking Above All Modals */
.toast-container,
#toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--space-4));
  right: var(--space-6);
  z-index: var(--z-toast, 99999);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  max-height: calc(100vh - var(--header-height) - var(--space-10));
  overflow: visible;
}

/* Individual Toast Item - Defined Width */
.toast-item {
  pointer-events: auto;
  width: 360px;
  max-width: calc(100vw - 32px);
  min-height: 48px;
  padding: 12px 14px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px -4px rgba(0, 0, 0, 0.24), 0 4px 10px -2px rgba(0, 0, 0, 0.12);
  display: grid;
  grid-template-columns: 20px 1fr 20px;
  align-items: flex-start;
  gap: 10px;
  user-select: none;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  animation: toast-enter 220ms var(--ease-spring) forwards;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.toast-item.toast-leaving {
  animation: toast-leave 180ms ease forwards;
}

/* Toast Icon Wrapper */
.toast-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  flex-shrink: 0;
}

.toast-icon-svg {
  width: 16px;
  height: 16px;
}

/* Type Distinctions (Success, Warning, Error, Info) */
.toast-item.toast-success {
  border-left: 3px solid #10b981;
}
.toast-item.toast-success .toast-icon-wrapper {
  color: #10b981;
}

.toast-item.toast-warning {
  border-left: 3px solid #f59e0b;
}
.toast-item.toast-warning .toast-icon-wrapper {
  color: #f59e0b;
}

.toast-item.toast-error {
  border-left: 3px solid #ef4444;
}
.toast-item.toast-error .toast-icon-wrapper {
  color: #ef4444;
}

.toast-item.toast-info {
  border-left: 3px solid var(--text-primary);
}
.toast-item.toast-info .toast-icon-wrapper {
  color: var(--text-primary);
}

/* Toast Body */
.toast-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.toast-title {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  line-height: 1.3;
}

.toast-message {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

/* Toast Close Button */
.toast-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
  outline: none;
  margin-top: 1px;
}

.toast-close-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

.toast-close-svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */
@keyframes toast-enter {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-leave {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
    max-height: 80px;
    margin-bottom: 0;
  }
  100% {
    opacity: 0;
    transform: translateY(-8px) scale(0.94);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: -8px;
    border-width: 0;
  }
}

/* --------------------------------------------------------------------------
   Responsive Adaptations
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .toast-container,
  #toast-container {
    top: calc(var(--header-height) + var(--space-3));
    left: var(--space-4);
    right: var(--space-4);
    align-items: stretch;
    z-index: var(--z-toast, 99999);
  }

  .toast-item {
    width: 100%;
    max-width: 100%;
  }
}
