/* Feedback visual reutilizable para botones que disparan un proceso.
   Estados: cargando (spinner) -> exito (palomita verde) / error (tache rojo).
   Lo maneja button-feedback.js anadiendo .btn-feedback + .is-loading/.is-success/.is-error.
   Se usa igual en el portal (tema claro) y en el core (tema oscuro). */

.btn-feedback {
  position: relative;
  overflow: hidden;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

/* En cualquier estado de feedback ocultamos el texto para mostrar el icono centrado. */
.btn-feedback.is-loading,
.btn-feedback.is-success,
.btn-feedback.is-error {
  color: transparent !important;
  cursor: default;
}

/* --- Cargando: spinner --- */
.btn-feedback.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #fff;
  border-radius: 50%;
  animation: bf-spin 0.7s linear infinite;
}

/* --- Exito: cambia a verde y dibuja la palomita --- */
.btn-feedback.is-success {
  background: #0f8f4e !important;
  border-color: #0f8f4e !important;
}

.btn-feedback.is-success::after {
  content: "\2713"; /* palomita */
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1em;
  font-weight: 900;
  line-height: 1;
  animation: bf-pop 0.3s ease;
}

/* --- Error: cambia a rojo y dibuja el tache --- */
.btn-feedback.is-error {
  background: #d23b3b !important;
  border-color: #d23b3b !important;
}

.btn-feedback.is-error::after {
  content: "\2715"; /* tache */
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.05em;
  font-weight: 900;
  line-height: 1;
  animation: bf-shake 0.4s ease;
}

@keyframes bf-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes bf-pop {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }
  60% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

@keyframes bf-shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  75% {
    transform: translateX(3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-feedback.is-loading::after {
    animation-duration: 1.4s;
  }
  .btn-feedback.is-success::after,
  .btn-feedback.is-error::after {
    animation: none;
  }
}
