/* Всплывающие уведомления в стиле Sonner. Цвета и тайминги взяты из оригинала. */

.toaster {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 356px;
  max-width: calc(100vw - 32px);
  z-index: 9999;
  pointer-events: none;
}
.toaster > * { pointer-events: auto; }

.toast {
  --y: 0px;
  --s: 1;
  --swipe: 0px;
  position: absolute;
  right: 0;
  bottom: 0;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  background: #fff;
  color: #171717;                       /* gray12 */
  border: 1px solid #ededed;            /* gray4 */
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .1);
  font-size: 13px;
  line-height: 1.4;
  transform-origin: bottom right;
  transform: translateY(var(--y)) translateX(var(--swipe)) scale(var(--s));
  transition: transform 400ms ease, opacity 400ms ease, box-shadow 200ms ease;
  touch-action: pan-y;
  cursor: default;
  user-select: none;
}

/* Появление снизу и уход */
.toast.toast-in { transform: translateY(100%) scale(1); opacity: 0; }
.toast.toast-out { transform: translateY(var(--y)) translateX(120%) scale(var(--s)); opacity: 0; transition-duration: 200ms; transition-timing-function: ease-out; }
/* Во время перетаскивания карточка следует за курсором без задержки */
.toast.toast-dragging { transition: none; cursor: grabbing; }

.toast-icon { flex: 0 0 auto; margin-left: -3px; margin-right: 4px; display: flex; align-items: center; }
.toast-icon svg { width: 20px; height: 20px; display: block; }

.toast-content { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toast-title { font-weight: 600; }
.toast-desc { color: #6b7280; font-weight: 400; }

.toast-close {
  flex: 0 0 auto;
  border: none;
  background: none;
  color: inherit;
  opacity: .45;
  font-size: 18px;
  line-height: 1;
  padding: 0 0 0 6px;
  cursor: pointer;
}
.toast-close:hover { opacity: 1; }

/* --- Цветные варианты (richColors из Sonner) --- */
.toast-success { background: hsl(143, 85%, 96%); border-color: hsl(145, 92%, 87%); color: hsl(140, 100%, 27%); }
.toast-error   { background: hsl(359, 100%, 97%); border-color: hsl(359, 100%, 94%); color: hsl(360, 100%, 45%); }
.toast-warning { background: hsl(49, 100%, 97%);  border-color: hsl(49, 91%, 84%);   color: hsl(31, 92%, 45%); }
.toast-info    { background: hsl(208, 100%, 97%); border-color: hsl(221, 91%, 93%);  color: hsl(210, 92%, 45%); }
.toast-success .toast-desc,
.toast-error .toast-desc,
.toast-warning .toast-desc,
.toast-info .toast-desc { color: currentColor; opacity: .75; }

/* Индикатор загрузки */
.toast-spinner {
  display: block;
  width: 18px; height: 18px;
  border: 2px solid rgba(0, 0, 0, .15);
  border-top-color: rgba(0, 0, 0, .55);
  border-radius: 50%;
  animation: toast-spin .7s linear infinite;
}
@keyframes toast-spin { to { transform: rotate(360deg); } }

/* На телефоне — во всю ширину экрана */
@media (max-width: 600px) {
  .toaster { right: 16px; left: 16px; width: auto; bottom: 16px; }
}

/* Уважаем системную настройку «меньше движения» */
@media (prefers-reduced-motion) {
  .toast { transition: none; }
  .toast-spinner { animation: none; }
}
