/* ==========================================================================
   Tema de alertas y confirmaciones (SweetAlert2) con la paleta KOA.
   Se aplica en todo el sistema desde js/alertas.js.
   ========================================================================== */

/* Fondo */
.swal2-container.swal2-backdrop-show:not(:has(.swal2-toast)),
.swal2-container.swal2-noanimation:not(:has(.swal2-toast)) {
  background: rgba(47, 52, 44, 0.42) !important;
  backdrop-filter: blur(3px);
}

/* Ventana */
.swal2-popup.koa-alerta {
  width: min(26rem, calc(100vw - 2rem));
  padding: 1.75rem 1.6rem 1.4rem;
  border-radius: 1.25rem;
  background: #ffffff;
  box-shadow: 0 1.5rem 3.5rem rgba(31, 36, 28, 0.22), 0 0.25rem 0.75rem rgba(31, 36, 28, 0.08);
  font-family: inherit;
  color: #4F4F57;
}

/* Ícono: círculo suave con el ícono de Bootstrap Icons */
.swal2-icon.koa-alerta-icono {
  width: 4.25rem;
  height: 4.25rem;
  margin: 0.25rem auto 1rem;
  border: 0 !important;
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  animation: koa-icono-entrar 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.swal2-icon.koa-alerta-icono .swal2-icon-content {
  font-size: 2rem;
  line-height: 1;
}

.swal2-icon.koa-alerta-icono .swal2-icon-content .bi {
  display: block;
}

.swal2-icon.swal2-success.koa-alerta-icono { background: #EDF3EA; color: #5E7D4A; }
.swal2-icon.swal2-error.koa-alerta-icono { background: #FBEAEA; color: #C0392B; }
.swal2-icon.swal2-warning.koa-alerta-icono { background: #FFF6E0; color: #B7791F; }
.swal2-icon.swal2-info.koa-alerta-icono { background: #EEF0F2; color: #4F4F57; }
.swal2-icon.swal2-question.koa-alerta-icono { background: #F1F5EF; color: #6E8F5C; }

/* Anillo que se expande detrás del ícono */
.swal2-icon.koa-alerta-icono::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 currentColor;
  opacity: 0.25;
  animation: koa-icono-anillo 0.9s ease-out 0.15s both;
}

.swal2-icon.koa-alerta-icono {
  position: relative;
}

/* Textos */
.swal2-title.koa-alerta-titulo {
  padding: 0;
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  font-weight: 800;
  color: #3E3E45;
  line-height: 1.3;
}

.swal2-html-container.koa-alerta-texto {
  margin: 0.25rem 0 0;
  padding: 0;
  font-size: 0.95rem;
  color: #6B6D72;
  line-height: 1.5;
}

/* Campos */
.swal2-input.koa-alerta-input,
.swal2-textarea.koa-alerta-input,
.swal2-select.koa-alerta-input {
  width: 100%;
  margin: 1rem 0 0;
  border: 1px solid #DCE2D8;
  border-radius: 0.75rem;
  box-shadow: none;
  font-size: 0.95rem;
  color: #3E3E45;
}

.swal2-input.koa-alerta-input:focus,
.swal2-textarea.koa-alerta-input:focus {
  border-color: #9DBB95;
  box-shadow: 0 0 0 0.2rem rgba(94, 125, 74, 0.15);
}

.swal2-validation-message {
  margin: 0.75rem 0 0;
  border-radius: 0.6rem;
  background: #FBEAEA;
  color: #A93226;
  font-size: 0.85rem;
}

/* Botones */
.swal2-actions.koa-alerta-acciones {
  margin: 1.4rem 0 0;
  gap: 0.6rem;
  width: 100%;
  flex-wrap: nowrap;
}

.koa-btn {
  flex: 1;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.2rem;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.koa-btn:active {
  transform: scale(0.97);
}

.koa-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 0.25rem rgba(94, 125, 74, 0.25);
}

.koa-btn-ok {
  background: #5E7D4A;
  color: #ffffff;
}

.koa-btn-ok:hover {
  background: #4A6339;
}

.koa-btn-peligro {
  background: #C0392B;
  color: #ffffff;
}

.koa-btn-peligro:hover {
  background: #A93226;
}

.koa-btn-cancelar {
  background: #F1F2F0;
  color: #4F4F57;
}

.koa-btn-cancelar:hover {
  background: #E4E6E2;
}

.swal2-loader {
  border-color: #5E7D4A transparent #5E7D4A transparent;
}

.swal2-close:focus {
  box-shadow: none;
}

/* Avisos flotantes (toast): sin fondo oscuro */
.swal2-container:has(.swal2-toast) {
  background: transparent !important;
  backdrop-filter: none;
}

.swal2-popup.swal2-toast.koa-alerta {
  width: auto;
  max-width: 24rem;
  padding: 0.75rem 1rem;
  border-radius: 0.9rem;
  border-left: 5px solid #5E7D4A;
  box-shadow: 0 0.75rem 2rem rgba(31, 36, 28, 0.18);
}

.swal2-popup.swal2-toast.koa-alerta.koa-tipo-error { border-left-color: #C0392B; }
.swal2-popup.swal2-toast.koa-alerta.koa-tipo-warning { border-left-color: #B7791F; }
.swal2-popup.swal2-toast.koa-alerta.koa-tipo-info { border-left-color: #4F4F57; }

.swal2-toast .swal2-icon.koa-alerta-icono {
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  margin: 0 0.6rem 0 0;
  animation-duration: 0.3s;
}

.swal2-toast .swal2-icon.koa-alerta-icono .swal2-icon-content {
  font-size: 1rem;
}

.swal2-toast .swal2-icon.koa-alerta-icono::after {
  display: none;
}

.swal2-toast .swal2-title.koa-alerta-titulo {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
}

.swal2-toast .swal2-timer-progress-bar {
  background: rgba(94, 125, 74, 0.35);
}

/* Animaciones */
.koa-entrar {
  animation: koa-entrar 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.koa-salir {
  animation: koa-salir 0.16s ease-in both;
}

.swal2-toast.koa-entrar {
  animation: koa-toast-entrar 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.swal2-toast.koa-salir {
  animation: koa-toast-salir 0.2s ease-in both;
}

@keyframes koa-entrar {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes koa-salir {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.96); }
}

@keyframes koa-toast-entrar {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes koa-toast-salir {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(24px); }
}

@keyframes koa-icono-entrar {
  0% { opacity: 0; transform: scale(0.4) rotate(-12deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes koa-icono-anillo {
  from { box-shadow: 0 0 0 0 currentColor; opacity: 0.35; }
  to { box-shadow: 0 0 0 14px currentColor; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .koa-entrar, .koa-salir, .swal2-icon.koa-alerta-icono, .swal2-icon.koa-alerta-icono::after {
    animation: none !important;
  }
}
