/* Toast container styles */
[id^="toast-container"] {
  max-width: 350px;
  z-index: 9999;
  pointer-events: none; /* Allow clicking through the container */
}

/* Toast styles */
.toast {
  width: 100%;
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  background-color: #4b5563; /* Default gray */
  pointer-events: auto; /* Make the toast itself clickable */
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.25rem;
  border-radius: 50%;
  position: relative;
  transition: transform 0.3s ease;
}

.toast-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 2px;
  background: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.8),
    rgba(255, 255, 255, 0.1)
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.7;
}

.toast-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.6));
  transition: transform 0.2s ease;
}

.toast:hover .toast-icon {
  transform: scale(1.05);
}

.toast:hover .toast-icon svg {
  transform: scale(1.1);
}

.toast-success .toast-icon {
  background-color: rgba(16, 185, 129, 0.3);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.5);
}

.toast-error .toast-icon {
  background-color: rgba(239, 68, 68, 0.3);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.5);
}

.toast-warning .toast-icon {
  background-color: rgba(245, 158, 11, 0.3);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
}

.toast-info .toast-icon {
  background-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
}

.toast-message {
  font-weight: 500;
  letter-spacing: 0.01em;
}

.toast-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  margin-left: 0.5rem;
  opacity: 0.7;
  transition:
    opacity 0.2s,
    transform 0.2s;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.toast-close:hover {
  opacity: 1;
  background-color: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.toast-success {
  background-color: rgba(16, 185, 129, 0.9);
  border-left: 5px solid rgb(6, 148, 100);
  background-image: linear-gradient(
    135deg,
    rgba(16, 185, 129, 0.9),
    rgba(5, 150, 105, 0.9)
  );
}

.toast-error {
  background-color: rgba(239, 68, 68, 0.9);
  border-left: 5px solid rgb(190, 18, 18);
  background-image: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.9),
    rgba(185, 28, 28, 0.9)
  );
}

.toast-warning {
  background-color: rgba(245, 158, 11, 0.9);
  border-left: 5px solid rgb(194, 120, 3);
  background-image: linear-gradient(
    135deg,
    rgba(245, 158, 11, 0.9),
    rgba(217, 119, 6, 0.9)
  );
}

.toast-info {
  background-color: rgba(59, 130, 246, 0.9);
  border-left: 5px solid rgb(30, 64, 175);
  background-image: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.9),
    rgba(37, 99, 235, 0.9)
  );
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  width: 100%;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.toast-success .toast-progress {
  background-color: rgb(6, 148, 100);
  background-image: linear-gradient(
    to right,
    rgb(6, 148, 100),
    rgb(16, 185, 129)
  );
}

.toast-error .toast-progress {
  background-color: rgb(190, 18, 18);
  background-image: linear-gradient(
    to right,
    rgb(190, 18, 18),
    rgb(239, 68, 68)
  );
}

.toast-warning .toast-progress {
  background-color: rgb(194, 120, 3);
  background-image: linear-gradient(
    to right,
    rgb(194, 120, 3),
    rgb(245, 158, 11)
  );
}

.toast-info .toast-progress {
  background-color: rgb(30, 64, 175);
  background-image: linear-gradient(
    to right,
    rgb(30, 64, 175),
    rgb(59, 130, 246)
  );
}

/* Animation for the progress bar */
@keyframes shrink {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}

.toast-progress.active {
  animation: shrink linear forwards;
}

/* Animation improvements */
/* Top right animations */
@keyframes slide-in-right {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

/* Top left animations */
@keyframes slide-in-left {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

/* Bottom animations (additional up/down movement) */
@keyframes slide-in-bottom-right {
  from {
    transform: translate(100%, 20px);
    opacity: 0;
  }
  to {
    transform: translate(0, 0);
    opacity: 1;
  }
}

@keyframes slide-out-bottom-right {
  from {
    transform: translate(0, 0);
    opacity: 1;
  }
  to {
    transform: translate(100%, 20px);
    opacity: 0;
  }
}

@keyframes slide-in-bottom-left {
  from {
    transform: translate(-100%, 20px);
    opacity: 0;
  }
  to {
    transform: translate(0, 0);
    opacity: 1;
  }
}

@keyframes slide-out-bottom-left {
  from {
    transform: translate(0, 0);
    opacity: 1;
  }
  to {
    transform: translate(-100%, 20px);
    opacity: 0;
  }
}

/* Apply animations based on position */
#toast-container-top-right .toast {
  animation: slide-in-right 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

#toast-container-top-right .toast.removing {
  animation: slide-out-right 0.3s cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards;
}

#toast-container-top-left .toast {
  animation: slide-in-left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

#toast-container-top-left .toast.removing {
  animation: slide-out-left 0.3s cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards;
}

#toast-container-bottom-right .toast {
  animation: slide-in-bottom-right 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94)
    forwards;
}

#toast-container-bottom-right .toast.removing {
  animation: slide-out-bottom-right 0.3s cubic-bezier(0.55, 0.085, 0.68, 0.53)
    forwards;
}

#toast-container-bottom-left .toast {
  animation: slide-in-bottom-left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94)
    forwards;
}

#toast-container-bottom-left .toast.removing {
  animation: slide-out-bottom-left 0.3s cubic-bezier(0.55, 0.085, 0.68, 0.53)
    forwards;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .toast {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.05);
  }

  .toast-success {
    background-color: rgba(5, 122, 85, 0.9);
    background-image: linear-gradient(
      135deg,
      rgba(5, 122, 85, 0.9),
      rgba(4, 108, 78, 0.9)
    );
  }

  .toast-error {
    background-color: rgba(185, 28, 28, 0.9);
    background-image: linear-gradient(
      135deg,
      rgba(185, 28, 28, 0.9),
      rgba(153, 27, 27, 0.9)
    );
  }

  .toast-warning {
    background-color: rgba(171, 104, 2, 0.9);
    background-image: linear-gradient(
      135deg,
      rgba(171, 104, 2, 0.9),
      rgba(146, 89, 3, 0.9)
    );
  }

  .toast-info {
    background-color: rgba(30, 64, 175, 0.9);
    background-image: linear-gradient(
      135deg,
      rgba(30, 64, 175, 0.9),
      rgba(29, 57, 150, 0.9)
    );
  }
}
