/*
|--------------------------------------------------------------------------
|  CORDAMI — Sistema de Notificaciones Toast
|--------------------------------------------------------------------------
|  Diseñado para integrarse con la identidad visual de la plataforma.
|  Colores base: verde #28a745, oscuro #2e2e2e, Montserrat.
|  Microanimaciones no intrusivas, Stack vertical auto-gestionado.
*/

/* ── Contenedor raíz de todos los toasts ─────────────────────────────── */
#cordami-toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
  max-width: 380px;
  width: calc(100% - 3rem);
}

/* ── Toast base ──────────────────────────────────────────────────────── */
.cordami-toast {
  pointer-events: all;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.06);
  font-family: "Montserrat", sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #1a1a1a;
  position: relative;
  overflow: hidden;

  /* Estado inicial para la animación de entrada */
  opacity: 0;
  transform: translateX(110%);
  transition:
    opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Estado visible (activado por JS) */
.cordami-toast.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

/* Estado de salida */
.cordami-toast.toast-leaving {
  opacity: 0;
  transform: translateX(110%);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

/* ── Barra de progreso inferior ─────────────────────────────────────── */
.cordami-toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: currentColor;
  opacity: 0.25;
  transform-origin: left;
  animation: toast-progress var(--toast-duration, 5000ms) linear forwards;
}

@keyframes toast-progress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ── Ícono del toast ─────────────────────────────────────────────────── */
.cordami-toast-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
}

/* ── Contenido del toast ─────────────────────────────────────────────── */
.cordami-toast-body {
  flex: 1;
  min-width: 0;
}

.cordami-toast-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
  display: block;
}

.cordami-toast-message {
  color: #444;
  font-size: 0.82rem;
}

/* ── Botón de cierre ─────────────────────────────────────────────────── */
.cordami-toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.2s ease;
}
.cordami-toast-close:hover {
  color: #333;
}

/* ── Variantes de tipo ───────────────────────────────────────────────── */

/* SUCCESS */
.cordami-toast.toast-success {
  border-left: 4px solid #28a745;
  color: #28a745;
}
.cordami-toast.toast-success .cordami-toast-icon {
  background: #eaf6ec;
  color: #28a745;
}
.cordami-toast.toast-success .cordami-toast-title {
  color: #1a5c2a;
}

/* ERROR */
.cordami-toast.toast-error {
  border-left: 4px solid #dc3545;
  color: #dc3545;
}
.cordami-toast.toast-error .cordami-toast-icon {
  background: #fde8e8;
  color: #dc3545;
}
.cordami-toast.toast-error .cordami-toast-title {
  color: #7b1d1d;
}

/* WARNING */
.cordami-toast.toast-warning {
  border-left: 4px solid #f59e0b;
  color: #f59e0b;
}
.cordami-toast.toast-warning .cordami-toast-icon {
  background: #fef3c7;
  color: #d97706;
}
.cordami-toast.toast-warning .cordami-toast-title {
  color: #78350f;
}

/* INFO */
.cordami-toast.toast-info {
  border-left: 4px solid #3b82f6;
  color: #3b82f6;
}
.cordami-toast.toast-info .cordami-toast-icon {
  background: #eff6ff;
  color: #3b82f6;
}
.cordami-toast.toast-info .cordami-toast-title {
  color: #1e3a8a;
}

/* ── LOADING STATE  (spinner animado) ─────────────────────────────────── */
.cordami-toast.toast-loading {
  border-left: 4px solid #6c757d;
  color: #6c757d;
}
.cordami-toast.toast-loading .cordami-toast-icon {
  background: #f0f0f0;
  color: #6c757d;
}
.cordami-toast.toast-loading .cordami-toast-icon svg {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Responsive mobile ───────────────────────────────────────────────── */
@media (max-width: 520px) {
  #cordami-toast-container {
    top: 1rem;
    right: 1rem;
    left: 1rem;
    max-width: 100%;
    width: auto;
  }
}
