/* =========================
   QWIPLUS ANIMATIONS SYSTEM
   "App viva" - microanimaciones, skeletons, transiciones
========================= */

/* ================= TRANSICIONES DE VISTAS ================= */

#main {
  animation: viewFadeIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

#main.view-exit {
  animation: viewFadeOut 0.18s ease forwards;
}

@keyframes viewFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes viewFadeOut {
  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* ================= SKELETON LOADING ================= */

.skeleton-card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.skeleton-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.skeleton-line {
  height: 14px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
  margin: 10px 12px;
}

.skeleton-line.short {
  width: 50%;
  height: 18px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ================= CARDS ENTRANCE ================= */

.card {
  animation: cardEnter 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.card:nth-child(1) { animation-delay: 0.02s; }
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.08s; }
.card:nth-child(4) { animation-delay: 0.11s; }
.card:nth-child(5) { animation-delay: 0.14s; }
.card:nth-child(6) { animation-delay: 0.17s; }
.card:nth-child(7) { animation-delay: 0.20s; }
.card:nth-child(8) { animation-delay: 0.23s; }

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* feedback táctil al presionar card */
.card:active {
  transform: scale(0.97);
  transition: transform 0.1s ease;
}

/* ================= FAVORITO ANIMADO ================= */

.fav-btn {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fav-btn:active {
  transform: scale(0.85);
}

.fav-btn.pop {
  animation: heartPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes heartPop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.4) rotate(-8deg); }
  60%  { transform: scale(0.9) rotate(4deg); }
  100% { transform: scale(1); }
}

/* contador favoritos */
.fav-count {
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fav-count.bump {
  animation: countBump 0.4s ease;
}

@keyframes countBump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); color: #ef4444; }
  100% { transform: scale(1); }
}

/* ================= BADGES (vendido / reservado) ================= */

.status-badge {
  animation: badgePop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badgePop {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ================= BOTONES ================= */

.btn-primary,
.profile-menu-btn,
.profile-btn,
.chat-btn,
.btn {
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.15s;
}

.btn-primary:active,
.profile-menu-btn:active,
.profile-btn:active,
.chat-btn:active,
.btn:active {
  transform: scale(0.96);
  filter: brightness(0.95);
}

/* ================= NAV INFERIOR ================= */

.nav-item {
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item:active {
  transform: scale(0.85);
}

/* badge mensajes pulsa cuando aparece */
.msg-badge {
  animation: badgePulse 1.8s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* ================= BURBUJAS CHAT ================= */

.bubble {
  animation: bubbleIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ================= CONVERSACIONES INBOX ================= */

.conversation {
  transition: background 0.18s ease, transform 0.12s ease;
  cursor: pointer;
}

.conversation:active {
  background: #f9fafb;
  transform: scale(0.99);
}

/* ================= TOAST ================= */

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ================= CATEGORÍAS ================= */

.category-card {
  animation: cardEnter 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.category-card:nth-child(1) { animation-delay: 0.02s; }
.category-card:nth-child(2) { animation-delay: 0.05s; }
.category-card:nth-child(3) { animation-delay: 0.08s; }
.category-card:nth-child(4) { animation-delay: 0.11s; }
.category-card:nth-child(5) { animation-delay: 0.14s; }
.category-card:nth-child(6) { animation-delay: 0.17s; }
.category-card:nth-child(7) { animation-delay: 0.20s; }
.category-card:nth-child(8) { animation-delay: 0.23s; }

/* ================= REDUCIR ANIMACIONES (accesibilidad) ================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
