.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  --toast-bg: #ffffff;
  --toast-border-color: #e0e0e0;
  --toast-text-color: #333;
  --toast-icon-bg: #e0e0e0;
  --toast-icon-color: #fff;

  display: flex;
  align-items: center;
  gap: 0.5rem;

  min-width: 220px;
  max-width: 400px;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--toast-bg);
  color: var(--toast-text-color);
  border: 1px solid var(--toast-border-color);
  font-size: 15px;
  font-family: inherit;

  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.04);

  pointer-events: auto;
  cursor: default;

  /* 進入動畫 */
  opacity: 0;
  transform: scale(0.95) translateY(-20px);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}

.toast.is-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.toast--success {
  --toast-icon-bg: #4caf50;
}
.toast--error {
  --toast-icon-bg: #f44336;
}

/* === Icon Styles === */
.toast-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background-color: var(--toast-icon-bg);
  color: var(--toast-icon-color);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: toast-icon-pop 0.3s ease-out both;
}

.toast-icon svg {
  width: 0.875rem;
  height: 0.875rem;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* === Icon Animation === */
@keyframes toast-icon-pop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  80% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.toast-content {
  flex-grow: 1;
  font-weight: 400;
  line-height: 1.4;
}

.toast-close {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  background: none;
  border: 0;
  padding: 0.25rem;
  margin-left: auto;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
  border-radius: 50%;
}

.toast-close:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.05);
}

.toast-close svg {
  width: 14px;
  height: 14px;
  color: #555;
  stroke: currentColor;
  stroke-width: 2.5;
  fill: none;
}

@media (max-width: 600px) {
  .toast-container {
    top: 1rem;
    left: 1rem;
    right: 1rem;
    width: auto;
    align-items: center;
  }

  .toast {
    max-width: 90%;
    min-width: 0;
    transform: translateY(-100%) scale(0.9);
  }

  .toast.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
