/* ============================================================
   Scribonautes — Toast Notification System
   static/css/components/toasts.css
   ============================================================ */

/* ── Conteneur positionné ── */
#scribo-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
  width: calc(100vw - 48px);
  pointer-events: none;         /* laisse passer les clics sauf sur les toasts */
}

/* ── Toast de base ── */
.scribo-toast {
  pointer-events: all;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius, 8px);
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10), 0 1px 4px rgba(0, 0, 0, 0.06);
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text, #1a1a1a);
  position: relative;
  overflow: hidden;

  /* Entrée / sortie */
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  transition:
    opacity      0.22s ease,
    transform    0.22s ease;
}

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

.scribo-toast.toast--leaving {
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  transition-duration: 0.18s;
}

/* ── Icône ── */
.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  margin-top: 1px;
}

/* ── Message ── */
.toast-msg {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

/* ── Bouton fermer ── */
.toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted, #9ca3af);
  padding: 0 2px;
  margin-top: -1px;
  transition: color 0.15s;
}
.toast-close:hover { color: var(--text, #1a1a1a); }

/* ── Barre de progression ── */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform linear;
  border-radius: 0 0 var(--radius, 8px) var(--radius, 8px);
}

/* ── Variantes ── */

/* Success */
.toast--success {
  border-left: 4px solid #22c55e;
}
.toast--success .toast-icon {
  background: #dcfce7;
  color: #16a34a;
}
.toast--success .toast-progress { background: #22c55e; }

/* Error */
.toast--error {
  border-left: 4px solid #ef4444;
}
.toast--error .toast-icon {
  background: #fee2e2;
  color: #dc2626;
}
.toast--error .toast-progress { background: #ef4444; }

/* Warning */
.toast--warning {
  border-left: 4px solid #f59e0b;
}
.toast--warning .toast-icon {
  background: #fef3c7;
  color: #d97706;
}
.toast--warning .toast-progress { background: #f59e0b; }

/* Info */
.toast--info {
  border-left: 4px solid var(--accent, #6366f1);
}
.toast--info .toast-icon {
  background: var(--accent-light, #eef2ff);
  color: var(--accent, #6366f1);
}
.toast--info .toast-progress { background: var(--accent, #6366f1); }

/* ── Adaptations thème sombre (chapter reader) ── */
[data-theme="dark"] .scribo-toast {
  background: #1e1e2e;
  border-color: #2a2a3e;
  color: #e2e8f0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

[data-theme="sepia"] .scribo-toast {
  background: #f5f0e8;
  border-color: #d4c9a8;
  color: #3d2b1f;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  #scribo-toast-container {
    bottom: 16px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
  }
}
