/**
 * Sileo-inspired toast notifications (vanilla JS companion to sileo.js)
 */

.sileo-viewport {
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  max-width: calc(100vw - 32px);
}

.sileo-viewport--top-right {
  top: 0;
  right: 0;
  align-items: flex-end;
}

.sileo-toast {
  pointer-events: auto;
  min-width: 300px;
  max-width: 380px;
  background: var(--sileo-bg, #ffffff);
  border: 1px solid var(--sileo-border, rgba(15, 23, 42, 0.08));
  border-radius: 14px;
  box-shadow: var(--sileo-shadow, 0 8px 32px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06));
  overflow: hidden;
  transform-origin: top right;
  animation: sileoEnter 0.38s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.sileo-toast.is-leaving {
  animation: sileoLeave 0.28s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes sileoEnter {
  from {
    opacity: 0;
    transform: translateX(16px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes sileoLeave {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(12px) scale(0.95);
  }
}

.sileo-toast__bar {
  height: 3px;
  width: 100%;
}

.sileo-toast--success .sileo-toast__bar { background: linear-gradient(90deg, #059669, #10b981); }
.sileo-toast--error .sileo-toast__bar { background: linear-gradient(90deg, #dc2626, #ef4444); }
.sileo-toast--warning .sileo-toast__bar { background: linear-gradient(90deg, #d97706, #f59e0b); }
.sileo-toast--info .sileo-toast__bar { background: var(--ent-accent, #e8943a); }
.sileo-toast--loading .sileo-toast__bar {
  background: var(--ent-accent, #e8943a);
  background-size: 200% 100%;
  animation: sileoBarShimmer 1.2s linear infinite;
}

@keyframes sileoBarShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.sileo-toast__body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px 16px;
}

.sileo-toast__icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.sileo-toast--success .sileo-toast__icon { background: #ecfdf5; color: #059669; }
.sileo-toast--error .sileo-toast__icon { background: #fef2f2; color: #dc2626; }
.sileo-toast--warning .sileo-toast__icon { background: #fffbeb; color: #d97706; }
.sileo-toast--info .sileo-toast__icon { background: #ecfeff; color: #0891b2; }
.sileo-toast--loading .sileo-toast__icon { background: #ecfeff; color: #0891b2; }

.sileo-toast__icon .fa-spinner {
  animation: sileoSpin 0.75s linear infinite;
}

@keyframes sileoSpin {
  to { transform: rotate(360deg); }
}

.sileo-toast__content {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
}

.sileo-toast__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--sileo-title, #0f172a);
  line-height: 1.35;
  margin: 0 0 2px;
}

.sileo-toast__description {
  font-size: 13px;
  color: var(--sileo-desc, #64748b);
  line-height: 1.45;
  margin: 0;
}

.sileo-toast__close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--sileo-close, #94a3b8);
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.sileo-toast__close:hover {
  background: var(--sileo-close-hover-bg, #f1f5f9);
  color: var(--sileo-close-hover, #475569);
}

.sileo-toast__progress {
  height: 2px;
  background: var(--sileo-progress-bg, rgba(15, 23, 42, 0.06));
  overflow: hidden;
}

.sileo-toast__progress span {
  display: block;
  height: 100%;
  background: var(--ent-accent-muted, rgba(232, 148, 58, 0.5));
  transform-origin: left;
  animation: sileoProgress linear forwards;
}

@keyframes sileoProgress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media (max-width: 480px) {
  .sileo-toast {
    min-width: 0;
    width: calc(100vw - 32px);
  }
}

/* Theme integration (admin + auth) */
[data-ent-theme="light"] {
  --sileo-bg: #ffffff;
  --sileo-border: rgba(15, 23, 42, 0.08);
  --sileo-shadow: 0 8px 32px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06);
  --sileo-title: #0f172a;
  --sileo-desc: #64748b;
  --sileo-close: #94a3b8;
  --sileo-close-hover-bg: #f1f5f9;
  --sileo-close-hover: #475569;
  --sileo-progress-bg: rgba(15, 23, 42, 0.06);
}

[data-ent-theme="dark"] {
  --sileo-bg: #1a2234;
  --sileo-border: rgba(255, 255, 255, 0.08);
  --sileo-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.25);
  --sileo-title: #f1f5f9;
  --sileo-desc: #94a3b8;
  --sileo-close: #64748b;
  --sileo-close-hover-bg: rgba(255, 255, 255, 0.08);
  --sileo-close-hover: #e2e8f0;
  --sileo-progress-bg: rgba(255, 255, 255, 0.08);
}

[data-ent-theme="dark"] .sileo-toast--success .sileo-toast__icon { background: rgba(5, 150, 105, 0.15); color: #34d399; }
[data-ent-theme="dark"] .sileo-toast--error .sileo-toast__icon { background: rgba(220, 38, 38, 0.15); color: #f87171; }
[data-ent-theme="dark"] .sileo-toast--warning .sileo-toast__icon { background: rgba(217, 119, 6, 0.15); color: #fbbf24; }
[data-ent-theme="dark"] .sileo-toast--info .sileo-toast__icon,
[data-ent-theme="dark"] .sileo-toast--loading .sileo-toast__icon { background: rgba(8, 145, 178, 0.15); color: #22d3ee; }
