/* ====================================
  NHC PWA - Sistema de Animaciones Avanzadas
   Optimizado para Angular 8 y PWA
   ==================================== */

/* Variables CSS para animaciones consistentes */
:root {
  --animation-duration-fast: 0.2s;
  --animation-duration-normal: 0.3s;
  --animation-duration-slow: 0.5s;
  --animation-timing: cubic-bezier(0.4, 0, 0.2, 1);
  --animation-timing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --animation-timing-elastic: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  
  /* Colores dinámicos */
  --primary-color: #1e40af;
  --secondary-color: #3b82f6;
  --accent-color: #06b6d4;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
}

/* ====================================
   ANIMACIONES DE ENTRADA/SALIDA
   ==================================== */

/* Fade In/Out */
.fade-in {
  animation: fadeIn var(--animation-duration-normal) var(--animation-timing) forwards;
}

.fade-out {
  animation: fadeOut var(--animation-duration-normal) var(--animation-timing) forwards;
}

@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: translateY(10px);
  }
  to { 
    opacity: 1; 
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from { 
    opacity: 1; 
    transform: translateY(0);
  }
  to { 
    opacity: 0; 
    transform: translateY(-10px);
  }
}

/* Slide Animations */
.slide-in-left {
  animation: slideInLeft var(--animation-duration-normal) var(--animation-timing) forwards;
}

.slide-in-right {
  animation: slideInRight var(--animation-duration-normal) var(--animation-timing) forwards;
}

.slide-in-up {
  animation: slideInUp var(--animation-duration-normal) var(--animation-timing) forwards;
}

.slide-in-down {
  animation: slideInDown var(--animation-duration-normal) var(--animation-timing) forwards;
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Scale Animations */
.scale-in {
  animation: scaleIn var(--animation-duration-normal) var(--animation-timing-bounce) forwards;
}

.scale-out {
  animation: scaleOut var(--animation-duration-normal) var(--animation-timing) forwards;
}

@keyframes scaleIn {
  from { 
    transform: scale(0.8); 
    opacity: 0; 
  }
  to { 
    transform: scale(1); 
    opacity: 1; 
  }
}

@keyframes scaleOut {
  from { 
    transform: scale(1); 
    opacity: 1; 
  }
  to { 
    transform: scale(0.8); 
    opacity: 0; 
  }
}

/* Bounce Animations */
.bounce-in {
  animation: bounceIn var(--animation-duration-slow) var(--animation-timing-elastic) forwards;
}

@keyframes bounceIn {
  0% { 
    transform: scale(0.3); 
    opacity: 0; 
  }
  50% { 
    transform: scale(1.05); 
    opacity: 0.8; 
  }
  70% { 
    transform: scale(0.9); 
    opacity: 0.9; 
  }
  100% { 
    transform: scale(1); 
    opacity: 1; 
  }
}

/* ====================================
   MICRO-INTERACCIONES
   ==================================== */

/* Hover Effects */
.hover-lift {
  transition: transform var(--animation-duration-fast) var(--animation-timing),
              box-shadow var(--animation-duration-fast) var(--animation-timing);
}

.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.hover-scale {
  transition: transform var(--animation-duration-fast) var(--animation-timing);
}

.hover-scale:hover {
  transform: scale(1.05);
}

.hover-glow {
  transition: box-shadow var(--animation-duration-normal) var(--animation-timing);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

/* Button Animations */
.btn-animated {
  position: relative;
  overflow: hidden;
  transition: all var(--animation-duration-normal) var(--animation-timing);
}

.btn-animated::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s var(--animation-timing);
}

.btn-animated:hover::before {
  left: 100%;
}

.btn-animated:active {
  transform: scale(0.98);
}

/* Ripple Effect */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.ripple:active::before {
  width: 300px;
  height: 300px;
}

/* ====================================
   LOADING ANIMATIONS
   ==================================== */

/* Spinner Animations */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(59, 130, 246, 0.1);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner-small {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner-large {
  width: 60px;
  height: 60px;
  border-width: 6px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Pulse Animation */
.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ====================================
   ELEMENTOS UI AVANZADOS
   ==================================== */

/* Card Animations */
.card-animated {
  transition: all var(--animation-duration-normal) var(--animation-timing);
  transform: translateY(0);
}

.card-animated:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.card-flip {
  perspective: 1000px;
}

.card-flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.card-flip:hover .card-flip-inner {
  transform: rotateY(180deg);
}

.card-flip-front, .card-flip-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 10px;
}

.card-flip-back {
  transform: rotateY(180deg);
}

/* Progress Bars */
.progress-animated {
  background: #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.progress-animated::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  border-radius: 10px;
  transition: width 1s var(--animation-timing);
}

/* Floating Elements */
.float-animation {
  animation: floating 3s ease-in-out infinite;
}

@keyframes floating {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

/* ====================================
   NOTIFICATION ANIMATIONS
   ==================================== */

.notification-enter {
  animation: notificationSlideIn 0.5s var(--animation-timing) forwards;
}

.notification-exit {
  animation: notificationSlideOut 0.3s var(--animation-timing) forwards;
}

@keyframes notificationSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes notificationSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Toast Animations */
.toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
}

.toast-item {
  margin-bottom: 10px;
  animation: toastSlideIn 0.3s var(--animation-timing) forwards;
}

.toast-item.removing {
  animation: toastSlideOut 0.3s var(--animation-timing) forwards;
}

@keyframes toastSlideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

/* ====================================
   MODAL ANIMATIONS
   ==================================== */

.modal-backdrop {
  animation: modalBackdropFadeIn 0.3s var(--animation-timing) forwards;
}

.modal-backdrop.closing {
  animation: modalBackdropFadeOut 0.3s var(--animation-timing) forwards;
}

.modal-content {
  animation: modalSlideIn 0.3s var(--animation-timing) forwards;
}

.modal-content.closing {
  animation: modalSlideOut 0.3s var(--animation-timing) forwards;
}

@keyframes modalBackdropFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalBackdropFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes modalSlideOut {
  from {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  to {
    transform: translateY(-50px) scale(0.95);
    opacity: 0;
  }
}

/* ====================================
   RESPONSIVE ANIMATIONS
   ==================================== */

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Performance optimizations */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  :root {
    --animation-duration-fast: 0.15s;
    --animation-duration-normal: 0.25s;
    --animation-duration-slow: 0.4s;
  }
  
  .hover-lift:hover {
    transform: none; /* Disable hover effects on mobile */
  }
  
  .card-animated:hover {
    transform: translateY(0);
  }
}

/* ====================================
   UTILITY CLASSES
   ==================================== */

.animate-on-scroll {
  opacity: 0;
  transition: all var(--animation-duration-slow) var(--animation-timing);
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-500 { animation-delay: 0.5s; }

.duration-fast { animation-duration: var(--animation-duration-fast) !important; }
.duration-normal { animation-duration: var(--animation-duration-normal) !important; }
.duration-slow { animation-duration: var(--animation-duration-slow) !important; }

/* ====================================
   PWA SPECIFIC ANIMATIONS
   ==================================== */

.pwa-install-bounce {
  animation: pwaInstallBounce 2s infinite;
}

@keyframes pwaInstallBounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    transform: translate3d(0, -10px, 0);
  }
  70% {
    transform: translate3d(0, -5px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

.pwa-notification-slide {
  animation: pwaNotificationSlide 0.5s var(--animation-timing-elastic) forwards;
}

@keyframes pwaNotificationSlide {
  from {
    transform: translateY(-100%) translateX(-50%);
    opacity: 0;
  }
  to {
    transform: translateY(0) translateX(-50%);
    opacity: 1;
  }
}

/* Success state animations */
.success-checkmark {
  animation: successCheckmark 0.6s var(--animation-timing-elastic) forwards;
}

@keyframes successCheckmark {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.8;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Error shake animation */
.error-shake {
  animation: errorShake 0.5s var(--animation-timing);
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}
