/* Alertas del portal (éxito, info, aviso, error) con tres entradas animadas
   que se eligen al azar: isla, caída o lateral. Ver seguridad/static/js/alertas.js. */

.chp-alertas {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 2147483000;
  width: min(420px, calc(100% - 28px));
  transform: translateX(-50%);
  pointer-events: none;
  font-family: "Poppins", system-ui, sans-serif;
}

/* La más nueva adelante; las anteriores asoman detrás, como una pila. */
.chp-alerta-capa {
  top: 0;
  left: 0;
  right: 0;
  transition: transform .4s cubic-bezier(.22, 1, .36, 1), opacity .4s;
}
.chp-alerta-capa[data-pos="0"] { position: relative; z-index: 3; pointer-events: auto; }
.chp-alerta-capa[data-pos="1"] { position: absolute; z-index: 2; transform: translateY(10px) scale(.95); opacity: .75; }
.chp-alerta-capa[data-pos="2"] { position: absolute; z-index: 1; transform: translateY(20px) scale(.9); opacity: .5; }

.chp-alerta {
  --alerta-color: #f5c518;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 14px 10px;
  border-radius: 18px;
  background: rgba(14, 30, 58, .9);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .08);
  color: #fff;
  cursor: pointer;
  text-align: left;
}
.chp-alerta--exito { --alerta-color: #3ecf8e; }
.chp-alerta--info { --alerta-color: #f5c518; }
.chp-alerta--aviso { --alerta-color: #ffa940; }
.chp-alerta--error { --alerta-color: #ff5d5d; }

/* Entradas y salidas: una al azar por alerta (data-animacion). */
.chp-alerta[data-animacion="isla"] { animation: chp-alerta-isla-in .7s cubic-bezier(.65, 0, .35, 1) both; }
.chp-alerta[data-animacion="caida"] { animation: chp-alerta-caida-in .6s cubic-bezier(.22, 1, .36, 1) both; }
.chp-alerta[data-animacion="lateral"] { animation: chp-alerta-lateral-in .55s cubic-bezier(.22, 1, .36, 1) both; }
.chp-alerta.is-saliendo[data-animacion="isla"] { animation: chp-alerta-isla-out .48s cubic-bezier(.65, 0, .35, 1) forwards; }
.chp-alerta.is-saliendo[data-animacion="caida"] { animation: chp-alerta-caida-out .4s cubic-bezier(.4, 0, 1, 1) forwards; }
.chp-alerta.is-saliendo[data-animacion="lateral"] { animation: chp-alerta-lateral-out .35s ease-in forwards; }

@keyframes chp-alerta-isla-in {
  0% { clip-path: inset(0 calc(50% - 22px) 0 calc(50% - 22px) round 999px); transform: translateY(-30px); }
  45% { clip-path: inset(0 calc(50% - 22px) 0 calc(50% - 22px) round 999px); transform: none; }
  100% { clip-path: inset(0 0 0 0 round 18px); }
}
@keyframes chp-alerta-isla-out {
  0% { clip-path: inset(0 0 0 0 round 18px); }
  55% { clip-path: inset(0 calc(50% - 22px) 0 calc(50% - 22px) round 999px); opacity: 1; transform: none; }
  100% { clip-path: inset(0 calc(50% - 22px) 0 calc(50% - 22px) round 999px); opacity: 0; transform: translateY(-30px); }
}
@keyframes chp-alerta-caida-in {
  0% { opacity: 0; transform: translateY(-140%) scale(.92); filter: blur(6px); }
  60% { opacity: 1; transform: translateY(8%) scale(1.01); filter: blur(0); }
  80% { transform: translateY(-3%); }
  100% { transform: none; }
}
@keyframes chp-alerta-caida-out { to { opacity: 0; transform: translateY(-120%) scale(.94); filter: blur(4px); } }
@keyframes chp-alerta-lateral-in {
  0% { opacity: 0; transform: translateX(110%) rotate(4deg); }
  70% { opacity: 1; transform: translateX(-4%) rotate(-.5deg); }
  100% { transform: none; }
}
@keyframes chp-alerta-lateral-out { to { opacity: 0; transform: translateX(110%); } }

/* Mascota de cada tipo: entra con un salto y gira; detrás, un brillo del color que late. */
.chp-alerta__mascota {
  position: relative; width: 72px; height: 72px; flex: none; transform-origin: 50% 90%;
  animation: chp-alerta-mascota .7s .25s cubic-bezier(.34, 1.56, .64, 1) both;
}
.chp-alerta__brillo {
  position: absolute; left: 6px; right: 6px; top: 14px; bottom: 10px; border-radius: 50%;
  background: var(--alerta-color); filter: blur(18px); animation: chp-alerta-brillo 2s ease-in-out infinite;
}
.chp-alerta__mascota img {
  position: relative; width: 84px; height: 72px; max-width: none; margin-left: -6px; object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .35));
}
@keyframes chp-alerta-mascota {
  0% { opacity: 0; transform: translateY(30%) scale(.4) rotate(-12deg); }
  55% { opacity: 1; transform: translateY(-6%) scale(1.12) rotate(4deg); }
  75% { transform: scale(.96) rotate(-2deg); }
  100% { transform: none; }
}
@keyframes chp-alerta-brillo { 0%, 100% { opacity: .35; } 50% { opacity: .7; } }

.chp-alerta__texto {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
  animation: chp-alerta-contenido .6s ease-out both;
}
.chp-alerta__titulo { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.3; color: #fff; }
.chp-alerta__mensaje { margin: 0; font-size: 12.5px; line-height: 1.4; color: #b7c3d9; overflow-wrap: anywhere; }
.chp-alerta__cerrar {
  flex: none; width: 28px; height: 28px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .06);
  color: #9fb0cc; font: inherit; font-size: 14px; cursor: pointer; animation: chp-alerta-contenido .6s ease-out both;
  transition: background .15s, color .15s;
}
.chp-alerta__cerrar:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.chp-alerta__cerrar:focus-visible { outline: 2px solid var(--alerta-color); outline-offset: 2px; }
@keyframes chp-alerta-contenido { 0%, 40% { opacity: 0; transform: translateY(4px); } 100% { opacity: 1; transform: none; } }

/* Barra de tiempo: se vacía mientras la alerta sigue abierta. */
.chp-alerta__tiempo { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .06); }
.chp-alerta__tiempo span {
  display: block; height: 100%; background: var(--alerta-color); box-shadow: 0 0 8px var(--alerta-color);
  transform-origin: left; animation: chp-alerta-tiempo var(--alerta-duracion, 4000ms) linear forwards;
}
.chp-alerta:hover .chp-alerta__tiempo span { animation-play-state: paused; }
@keyframes chp-alerta-tiempo { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (min-width: 900px) {
  .chp-alertas { top: 20px; }
}

/* --- Confirmación (chpAlerta.confirmar): mismo vidrio navy y mascota. --- */
.chp-confirmar {
  position: fixed;
  inset: 0;
  z-index: 2147483001;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(7, 21, 39, .55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  font-family: "Poppins", system-ui, sans-serif;
  animation: chp-confirmar-fondo .2s ease-out both;
}
.chp-confirmar.is-saliendo { animation: chp-confirmar-fondo .2s ease-in reverse forwards; }
.chp-confirmar__caja {
  --alerta-color: #ffa940;
  position: relative;
  width: min(420px, 100%);
  box-sizing: border-box;
  padding: 26px 24px 22px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 22px;
  background: rgba(14, 30, 58, .96);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .08);
  color: #fff;
  text-align: center;
  animation: chp-confirmar-entra .45s cubic-bezier(.34, 1.56, .64, 1) both;
}
.chp-confirmar.is-saliendo .chp-confirmar__caja { animation: chp-confirmar-sale .2s ease-in forwards; }
/* Franja superior del color del tipo. */
.chp-confirmar__caja::before {
  content: "";
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--alerta-color);
  box-shadow: 0 0 10px var(--alerta-color);
}
.chp-confirmar__caja .chp-alerta__mascota { width: 104px; height: 96px; margin: 0 auto 8px; }
.chp-confirmar__caja .chp-alerta__mascota img { width: 116px; height: 96px; margin-left: -6px; }
.chp-confirmar__titulo { margin: 0; font-size: 19px; font-weight: 700; line-height: 1.3; color: #fff; }
.chp-confirmar__mensaje { margin: 8px 0 0; font-size: 14px; line-height: 1.5; color: #b7c3d9; overflow-wrap: anywhere; }
.chp-confirmar__botones { display: flex; gap: 10px; margin-top: 22px; }
.chp-confirmar__btn {
  flex: 1;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.chp-confirmar__btn:active { transform: scale(.97); }
.chp-confirmar__btn:focus-visible { outline: 2px solid #f5c518; outline-offset: 2px; }
.chp-confirmar__btn--cancelar { background: rgba(255, 255, 255, .08); color: #e2e8f0; }
.chp-confirmar__btn--cancelar:hover { background: rgba(255, 255, 255, .14); }
.chp-confirmar__btn--peligro { background: #ff5d5d; color: #fff; }
.chp-confirmar__btn--peligro:hover { background: #ff7373; }
.chp-confirmar__btn--ok { background: #f5c518; color: #0b1a33; }
.chp-confirmar__btn--ok:hover { background: #ffd43b; }

@keyframes chp-confirmar-fondo { from { opacity: 0; } to { opacity: 1; } }
@keyframes chp-confirmar-entra {
  0% { opacity: 0; transform: translateY(24px) scale(.9); }
  100% { opacity: 1; transform: none; }
}
@keyframes chp-confirmar-sale { to { opacity: 0; transform: translateY(12px) scale(.96); } }

@media (prefers-reduced-motion: reduce) {
  .chp-alerta, .chp-alerta *, .chp-confirmar, .chp-confirmar * { animation: none !important; transition: none !important; }
}
