/* =============================================
   UniMate Toast System v4.0
   Bottom-right stacking · Animated SVG icons
   Light + Dark theme · Premium glassmorphism
   ============================================= */

/* ── Container ── */
#um-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
  max-width: 400px;
  width: calc(100% - 48px);
}

/* ── Toast Card ── */
.um-toast {
  --toast-accent: var(--primary, #6366f1);
  --toast-accent-soft: rgba(99, 102, 241, 0.10);
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--surface, #ffffff);
  border: 1px solid rgba(0, 0, 0, 0.06);
  position: relative;
  overflow: hidden;
  font-family: inherit;
  cursor: default;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04);
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  transition:
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Type accents ── */
.um-toast--success {
  --toast-accent: #10b981;
  --toast-accent-soft: rgba(16, 185, 129, 0.10);
}

.um-toast--error {
  --toast-accent: #ef4444;
  --toast-accent-soft: rgba(239, 68, 68, 0.10);
}

.um-toast--warning {
  --toast-accent: #f59e0b;
  --toast-accent-soft: rgba(245, 158, 11, 0.10);
}

.um-toast--info {
  --toast-accent: #6366f1;
  --toast-accent-soft: rgba(99, 102, 241, 0.10);
}

/* ── Visibility States ── */
.um-toast--visible {
  transform: translateX(0);
  opacity: 1;
}

.um-toast--exit {
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  transition:
    transform 0.35s cubic-bezier(0.55, 0, 1, 0.45),
    opacity 0.25s ease;
}

/* ── Left accent stripe ── */
.um-toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--toast-accent);
  border-radius: 16px 0 0 16px;
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.1s;
}

.um-toast--visible::before {
  transform: scaleY(1);
}

/* ── No shimmer ── */
.um-toast::after {
  display: none;
}

/* ── Icon Container ── */
.um-toast-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--toast-accent-soft);
  color: var(--toast-accent);
  font-size: 16px;
  position: relative;
}

.um-toast--visible .um-toast-icon {
  animation: um-toast-icon-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both;
}

/* SVG icon inside */
.um-toast-icon svg {
  width: 20px;
  height: 20px;
}

/* Animated SVG strokes */
.um-toast-icon svg path,
.um-toast-icon svg polyline,
.um-toast-icon svg line,
.um-toast-icon svg circle.draw {
  stroke: var(--toast-accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.um-toast--visible .um-toast-icon svg .um-draw {
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: um-svg-draw 0.5s cubic-bezier(0.65, 0, 0.35, 1) 0.25s forwards;
}

@keyframes um-svg-draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes um-toast-icon-pop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  50% {
    transform: scale(1.08);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── Body ── */
.um-toast-body {
  flex: 1;
  min-width: 0;
  padding: 1px 0;
}

.um-toast-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--text, #0f172a);
  line-height: 1.35;
  margin-bottom: 2px;
  word-break: break-word;
}

.um-toast-msg {
  font-size: 13px;
  font-weight: 450;
  color: var(--muted, #64748b);
  line-height: 1.4;
  word-break: break-word;
}

/* When there's no title, the body text gets a slightly stronger treatment */
.um-toast-body:not(:has(.um-toast-title)) {
  font-size: 14px;
  font-weight: 550;
  color: var(--text, #1e293b);
  line-height: 1.45;
  padding: 4px 0;
  word-break: break-word;
}

/* ── Action Buttons ── */
.um-toast-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.um-toast-action {
  padding: 5px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border, #e2e8f0);
  background: transparent;
  color: var(--text, #475569);
  transition: all 0.15s ease;
  font-family: inherit;
  line-height: 1.4;
}

.um-toast-action:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
}

.um-toast-action--primary {
  background: var(--toast-accent);
  color: #ffffff;
  border-color: var(--toast-accent);
}

.um-toast-action--primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--toast-accent) 30%, transparent);
}

/* ── Close button ── */
.um-toast-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted, #94a3b8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
  font-size: 11px;
  opacity: 0;
  margin: -2px -4px 0 0;
}

.um-toast:hover .um-toast-close {
  opacity: 1;
}

.um-toast-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text, #475569);
  transform: rotate(90deg);
}

/* ── Progress bar ── */
.um-toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 0 0 16px 16px;
  overflow: hidden;
}

.um-toast-progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--toast-accent);
  opacity: 0.45;
  animation: um-toast-shrink 4000ms linear forwards;
}

@keyframes um-toast-shrink {
  from {
    width: 100%;
  }

  to {
    width: 0%;
  }
}

/* =============================================
   Confirm Modal (integrated with toast CSS)
   ============================================= */
.um-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.um-confirm-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.um-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.um-confirm-dialog {
  position: relative;
  width: min(420px, calc(100% - 32px));
  background: var(--surface, #ffffff);
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.12), 0 8px 20px rgba(0, 0, 0, 0.06);
  padding: 24px;
  transform: scale(0.92) translateY(16px);
  opacity: 0;
  transition:
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.3s ease;
}

.um-confirm-overlay.active .um-confirm-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.um-confirm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.um-confirm-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text, #0f172a);
  margin: 0;
  letter-spacing: -0.01em;
}

.um-confirm-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  background: transparent;
  color: var(--muted, #94a3b8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
}

.um-confirm-close:hover {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25);
  transform: rotate(90deg);
}

.um-confirm-body {
  font-size: 14px;
  color: var(--muted, #475569);
  line-height: 1.6;
  margin-bottom: 20px;
}

.um-confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.um-confirm-btn {
  padding: 9px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  font-family: inherit;
}

.um-confirm-btn--cancel {
  background: transparent;
  color: var(--text, #475569);
  border: 1px solid var(--border, #e2e8f0);
}

.um-confirm-btn--cancel:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text, #0f172a);
}

.um-confirm-btn--ok {
  background: var(--primary, #6366f1);
  color: #fff;
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.2);
}

.um-confirm-btn--ok:hover {
  background: var(--primary-hover, #4f46e5);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.um-confirm-btn--ok:active {
  transform: scale(0.97);
}

/* ══════════════════════════════════════════════
   DARK THEME
   ══════════════════════════════════════════════ */

/* ── Toast Dark ── */
.theme-dark .um-toast {
  background: var(--surface, #1e293b);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.35),
    0 2px 8px rgba(0, 0, 0, 0.2);
}

.theme-dark .um-toast--success {
  --toast-accent: #34d399;
  --toast-accent-soft: rgba(52, 211, 153, 0.12);
}

.theme-dark .um-toast--error {
  --toast-accent: #f87171;
  --toast-accent-soft: rgba(248, 113, 113, 0.12);
}

.theme-dark .um-toast--warning {
  --toast-accent: #fbbf24;
  --toast-accent-soft: rgba(251, 191, 36, 0.12);
}

.theme-dark .um-toast--info {
  --toast-accent: #818cf8;
  --toast-accent-soft: rgba(129, 140, 248, 0.12);
}

.theme-dark .um-toast-title {
  color: var(--text, #f1f5f9);
}

.theme-dark .um-toast-msg {
  color: var(--muted, #94a3b8);
}

.theme-dark .um-toast-body:not(:has(.um-toast-title)) {
  color: var(--text, #e2e8f0);
}

.theme-dark .um-toast-close {
  color: #64748b;
}

.theme-dark .um-toast-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
}

.theme-dark .um-toast-progress {
  background: rgba(255, 255, 255, 0.04);
}

.theme-dark .um-toast-action {
  border-color: rgba(148, 163, 184, 0.15);
  color: var(--text, #e2e8f0);
}

.theme-dark .um-toast-action:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(148, 163, 184, 0.25);
}

.theme-dark .um-toast-action--primary {
  background: var(--toast-accent);
  border-color: var(--toast-accent);
  color: #0f172a;
}

/* ── Confirm Dark ── */
.theme-dark .um-confirm-dialog {
  background: var(--surface, #1e293b);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 8px 20px rgba(0, 0, 0, 0.2);
}

.theme-dark .um-confirm-backdrop {
  background: rgba(2, 6, 23, 0.55);
}

.theme-dark .um-confirm-title {
  color: var(--text, #e2e8f0);
}

.theme-dark .um-confirm-body {
  color: var(--muted, #94a3b8);
}

.theme-dark .um-confirm-close {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

.theme-dark .um-confirm-close:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.theme-dark .um-confirm-btn--cancel {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.15);
  color: var(--text, #94a3b8);
}

.theme-dark .um-confirm-btn--cancel:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text, #e2e8f0);
}

.theme-dark .um-confirm-btn--ok {
  background: var(--primary, #6366f1);
  color: #fff;
}

.theme-dark .um-confirm-btn--ok:hover {
  background: var(--primary-hover, #4f46e5);
}

/* ── Mobile ── */
@media (max-width: 768px) {
  #um-toast-container {
    bottom: 80px;
    /* above mobile nav */
    right: 12px;
    left: 12px;
    width: auto;
    max-width: 100%;
  }

  .um-toast {
    border-radius: 14px;
    padding: 14px 16px;
    gap: 12px;
  }

  .um-toast-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
  }

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

  .um-toast-title {
    font-size: 13.5px;
  }

  .um-toast-msg {
    font-size: 12.5px;
  }

  .um-toast-close {
    opacity: 1;
  }
}

@media (max-width: 480px) {
  #um-toast-container {
    bottom: 72px;
    right: 8px;
    left: 8px;
  }
}

/* Safe area for notched devices */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #um-toast-container {
    padding-bottom: env(safe-area-inset-bottom);
  }
}