/**
 * Auth Transitions CSS
 * Transiciones suaves para páginas de autenticación
 * 
 * Características:
 * - Fade in/out animations
 * - Slide transitions entre páginas
 * - Smooth form element transitions
 * - Micro-interactions para inputs y botones
 * - Respeta prefers-reduced-motion para accesibilidad
 */

/* ============================================
   IMPORT FONTS
   ============================================ */
@import url('fonts.css');

/* ============================================
   PAGE TRANSITIONS
   ============================================ */

/**
 * Fade-in animation para toda la página
 * Se aplica cuando la página se carga
 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/**
 * Slide-in animations desde diferentes direcciones
 */
@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/**
 * Aplicar fade-in al contenedor principal
 */
.login-container {
  animation: fadeIn 0.6s ease-out;
}

/**
 * Transiciones para el panel de formulario
 */
.form-panel {
  animation: slideInFromRight 0.8s ease-out;
}

/**
 * Transiciones para el panel de imagen
 */
.image-panel {
  animation: slideInFromLeft 0.8s ease-out;
}

/* ============================================
   FORM ELEMENT TRANSITIONS
   ============================================ */

/**
 * Animación en cascada para elementos del formulario
 */
.login-form > * {
  animation: fadeIn 0.5s ease-out backwards;
}

.login-form > *:nth-child(1) { animation-delay: 0.1s; }
.login-form > *:nth-child(2) { animation-delay: 0.2s; }
.login-form > *:nth-child(3) { animation-delay: 0.3s; }
.login-form > *:nth-child(4) { animation-delay: 0.4s; }
.login-form > *:nth-child(5) { animation-delay: 0.5s; }
.login-form > *:nth-child(6) { animation-delay: 0.6s; }

/**
 * Transiciones suaves para inputs
 */
.form-input,
.input-wrapper {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/**
 * Focus state con transición suave
 */
.form-input:focus {
  transform: scale(1.01);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/**
 * Hover state para input wrappers
 */
.input-wrapper:hover {
  transform: translateY(-2px);
  transition: transform 0.3s ease;
}

/* ============================================
   BUTTON TRANSITIONS
   ============================================ */

/**
 * Transiciones para botones
 */
.submit-button,
.btn-secondary {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

/**
 * Efecto ripple al hacer click
 */
.submit-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.submit-button:active::before {
  width: 300px;
  height: 300px;
}

/**
 * Ripple dinámico generado por JavaScript
 */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: rippleEffect 0.6s ease-out;
}

@keyframes rippleEffect {
  from {
    width: 0;
    height: 0;
    opacity: 1;
  }
  to {
    width: 200px;
    height: 200px;
    opacity: 0;
  }
}

/**
 * Hover states con transiciones
 */
.submit-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

.submit-button:active {
  transform: translateY(0);
  transition: transform 0.1s;
}

/* ============================================
   LINK TRANSITIONS
   ============================================ */

/**
 * Transiciones para enlaces
 */
.form-link,
.back-link,
a {
  transition: all 0.3s ease;
  position: relative;
}

/**
 * Underline effect en hover
 */
.form-link::after,
.back-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: currentColor;
  transition: width 0.3s ease;
}

.form-link:hover::after,
.back-link:hover::after {
  width: 100%;
}

/* ============================================
   MESSAGE TRANSITIONS
   ============================================ */

/**
 * Fade-in para mensajes flash
 */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.flash-messages .alert,
.flash-message {
  animation: slideDown 0.4s ease-out;
}

/**
 * Transición para cerrar mensajes
 */
.flash-messages .alert {
  transition: all 0.3s ease;
}

.flash-messages .alert.removing {
  opacity: 0;
  transform: translateX(100%);
}

/**
 * Info box con transición
 */
.info-box,
.form-help {
  transition: all 0.3s ease;
}

.info-box:hover {
  transform: translateX(5px);
}

/* ============================================
   ICON TRANSITIONS
   ============================================ */

/**
 * Transiciones para iconos
 */
.input-icon,
.password-toggle,
.fa,
.fas,
.far {
  transition: all 0.3s ease;
}

/**
 * Rotación suave para el toggle de contraseña
 */
.password-toggle:hover {
  transform: scale(1.15);
}

.password-toggle:active {
  transform: scale(0.95);
}

/**
 * Pulso para iconos de error/success
 */
@keyframes iconPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.input-icon.error {
  animation: iconPulse 0.5s ease;
  color: #ef4444;
}

.input-icon.success {
  animation: iconPulse 0.5s ease;
  color: #10b981;
}

/* ============================================
   PASSWORD STRENGTH TRANSITIONS
   ============================================ */

/**
 * Barra de fuerza con transición suave
 */
.password-strength .bar {
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              background-color 0.4s ease;
}

/**
 * Match indicator con transición
 */
.pw-match {
  transition: all 0.3s ease;
  animation: fadeIn 0.4s ease-out;
}

/**
 * Requirements list con animación individual
 */
.requirements-list li {
  transition: all 0.3s ease;
}

.requirements-list li.valid {
  animation: fadeIn 0.3s ease-out;
}

.requirements-list li.valid i {
  animation: iconPulse 0.5s ease;
}

/* ============================================
   LOADING STATES
   ============================================ */

/**
 * Spinner animation
 */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.submit-button.loading i,
.loading-spinner {
  animation: spin 1s linear infinite;
}

/**
 * Skeleton loading animation
 */
@keyframes shimmer {
  0% {
    background-position: -468px 0;
  }
  100% {
    background-position: 468px 0;
  }
}

.skeleton-loading {
  animation: shimmer 1.2s ease-in-out infinite;
  background: linear-gradient(
    to right,
    #f0f0f0 0%,
    #e0e0e0 20%,
    #f0f0f0 40%,
    #f0f0f0 100%
  );
  background-size: 800px 104px;
}

/* ============================================
   PAGE EXIT TRANSITIONS
   ============================================ */

/**
 * Clase para aplicar cuando se sale de la página
 * Se debe agregar via JavaScript antes de navegar
 */
body.page-exit .login-container {
  animation: fadeOut 0.4s ease-out forwards;
}

body.page-exit .form-panel {
  animation: slideOutRight 0.5s ease-out forwards;
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

@keyframes slideOutLeft {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-30px);
  }
}

/* ============================================
   RESPONSIVE TRANSITIONS
   ============================================ */

/**
 * Ajustar velocidad de transiciones en móviles
 */
@media (max-width: 768px) {
  .login-container,
  .form-panel,
  .image-panel {
    animation-duration: 0.4s;
  }

  .login-form > * {
    animation-duration: 0.3s;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/**
 * Desactivar animaciones para usuarios que prefieren movimiento reducido
 */
@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;
  }

  .login-container,
  .form-panel,
  .image-panel,
  .login-form > * {
    animation: none !important;
  }
}

/* ============================================
   DARK MODE TRANSITIONS
   ============================================ */

/**
 * Transiciones suaves al cambiar tema
 */
@media (prefers-color-scheme: dark) {
  * {
    transition: background-color 0.3s ease, color 0.3s ease;
  }
}

/* ============================================
   FOCUS VISIBLE (Accesibilidad con teclado)
   ============================================ */

/**
 * Outline animado para navegación con teclado
 */
*:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
  transition: outline-offset 0.2s ease;
}

*:focus-visible:active {
  outline-offset: 0;
}
