/* =============================================
   Toast / Notification Component — UI-0072, UI-0073
   ============================================= */

/* --- Toast Container (stack host) --- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: var(--z-toast); /* 100 */
  display: flex;
  flex-direction: column;
  gap: var(--space-2); /* 8px between toasts */
  pointer-events: none;
  max-width: 380px;
  width: calc(100vw - 32px);
}

/* --- Individual Toast --- */
.toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background-color: var(--color-white);
  border: 1px solid var(--border-default, #E2E8F0);
  border-radius: var(--radius-lg); /* 12px */
  padding: var(--space-4);
  padding-left: calc(var(--space-4) + 4px); /* extra for left bar */
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  overflow: hidden;

  /* Slide-in animation (UI-0073) */
  animation: toast-slide-in var(--duration-normal, 300ms) var(--ease-out) forwards;
}

/* 4px left colored bar */
.toast::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

/* --- Toast Exit Animation --- */
.toast.is-exiting {
  animation: toast-slide-out var(--duration-normal, 300ms) var(--ease-in) forwards;
}

/* --- Toast Type Variants --- */

/* Success */
.toast--success::before {
  background-color: var(--color-success, #10B981);
}

.toast--success .toast__icon {
  color: var(--color-success, #10B981);
}

/* Error */
.toast--error::before {
  background-color: var(--color-error, #EF4444);
}

.toast--error .toast__icon {
  color: var(--color-error, #EF4444);
}

/* Warning */
.toast--warning::before {
  background-color: var(--color-warning, #F59E0B);
}

.toast--warning .toast__icon {
  color: var(--color-warning, #F59E0B);
}

/* Info */
.toast--info::before {
  background-color: var(--color-info, #2F80ED);
}

.toast--info .toast__icon {
  color: var(--color-info, #2F80ED);
}

/* --- Toast Icon --- */
.toast__icon {
  flex-shrink: 0;
  width: var(--icon-md);
  height: var(--icon-md);
  stroke: currentColor;
  fill: none;
}

/* --- Toast Body --- */
.toast__body {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary, #111111);
  margin-bottom: var(--space-1);
}

.toast__message {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-secondary, #4A5568);
  line-height: var(--leading-normal, 1.5);
}

/* --- Toast Close Button --- */
.toast__close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted, #B0BAC5);
  border-radius: var(--radius-sm);
  padding: 0;
  transition: color var(--duration-fast) var(--ease-default),
              background-color var(--duration-fast) var(--ease-default);
}

.toast__close:hover {
  color: var(--text-primary, #111111);
  background-color: var(--bg-subtle, #F7F8FA);
}

.toast__close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
}

/* --- Progress Bar (auto-dismiss indicator) --- */
.toast__progress {
  position: absolute;
  bottom: 0;
  left: 4px; /* start after color bar */
  right: 0;
  height: 2px;
  background-color: rgba(0, 0, 0, 0.08);
  border-radius: 0 0 var(--radius-lg) 0;
  overflow: hidden;
}

.toast__progress-bar {
  height: 100%;
  width: 100%;
  transform-origin: left;
  animation: toast-progress 5s linear forwards; /* 5 second auto-dismiss */
}

.toast--success .toast__progress-bar { background-color: var(--color-success, #10B981); }
.toast--error   .toast__progress-bar { background-color: var(--color-error, #EF4444); }
.toast--warning .toast__progress-bar { background-color: var(--color-warning, #F59E0B); }
.toast--info    .toast__progress-bar { background-color: var(--color-info, #2F80ED); }

/* =============================================
   Keyframe Animations
   ============================================= */
@keyframes toast-slide-in {
  from {
    transform: translateX(calc(100% + 16px));
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-slide-out {
  from {
    transform: translateX(0);
    opacity: 1;
    max-height: 200px;
    margin-bottom: var(--space-2);
  }
  to {
    transform: translateX(calc(100% + 16px));
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
}

@keyframes toast-progress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* =============================================
   Toast — Mobile Responsive
   ============================================= */
@media (max-width: 639px) {
  .toast-container {
    top: auto;
    bottom: 16px;
    right: 8px;
    left: 8px;
    max-width: none;
    width: auto;
  }

  .toast {
    padding: var(--space-3);
    padding-left: calc(var(--space-3) + 4px);
    font-size: var(--text-sm);
  }

  .toast__title {
    font-size: var(--text-sm);
  }

  .toast__message {
    font-size: 13px;
  }

  .toast__close {
    width: 44px;
    height: 44px;
    margin: -8px -8px -8px 0;
  }

  /* Slide up from bottom on mobile */
  @keyframes toast-slide-in {
    from {
      transform: translateY(calc(100% + 16px));
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  @keyframes toast-slide-out {
    from {
      transform: translateY(0);
      opacity: 1;
      max-height: 200px;
      margin-bottom: var(--space-2);
    }
    to {
      transform: translateY(calc(100% + 16px));
      opacity: 0;
      max-height: 0;
      margin-bottom: 0;
      padding-top: 0;
      padding-bottom: 0;
    }
  }
}
