/**
 * Login Enhanced Styles - AppTaller
 * Mejoras de accesibilidad, animaciones y UX
 * 
 * ⚠️ IMPORTANTE: Importar variables.css ANTES de este archivo
 */
@import url('variables.css');

/* ============================================
   BODY Y CONTENEDOR PRINCIPAL
   ============================================ */
body.login-page {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow-x: hidden;
}

/* Fondo animado con partículas */
.particles-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 40% 20%, rgba(255, 255, 255, 0.03) 0%, transparent 50%);
  animation: particles-float 20s ease-in-out infinite;
  z-index: 0;
}

@keyframes particles-float {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-20px) scale(1.05);
  }
}

/* ============================================
   ACCESIBILIDAD - SKIP TO CONTENT
   ============================================ */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-color);
  color: white;
  padding: 12px 24px;
  border-radius: var(--border-radius);
  text-decoration: none;
  font-weight: 600;
  z-index: 9999;
  transition: top var(--transition-fast);
  box-shadow: var(--shadow-lg);
}

.skip-to-content:focus {
  top: 20px;
  outline: 3px solid white;
  outline-offset: 4px;
  color: white;
  text-decoration: none;
}

/* ============================================
   ALERTAS MEJORADAS
   ============================================ */
.alert {
  border: none;
  border-radius: var(--border-radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.alert::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: currentColor;
}

.alert-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.alert-icon {
  font-size: 20px;
  animation: pulse-icon 2s ease-in-out infinite;
}

@keyframes pulse-icon {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.alert-danger {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
  color: white;
}

.alert-info {
  background: linear-gradient(135deg, #4dabf7 0%, #339af0 100%);
  color: white;
}

.alert .close {
  color: white;
  opacity: 0.8;
  text-shadow: none;
  transition: opacity var(--transition-fast);
}

.alert .close:hover {
  opacity: 1;
}

/* ============================================
   ANIMACIONES DE ENTRADA
   ============================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInTop {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.fade-in-up {
  animation: fadeInUp 0.6s ease-out;
}

.fade-in-top {
  animation: fadeInTop 0.5s ease-out;
}

/* ============================================
   TARJETA DE LOGIN
   ============================================ */
.login-card {
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-xl);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  position: relative;
  z-index: 1;
}

.login-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

/* ============================================
   LADO IZQUIERDO - BRANDING
   ============================================ */
.bg-login-image-enhanced {
  background: var(--gradient-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.bg-login-image-enhanced::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  animation: rotate-gradient 30s linear infinite;
}

@keyframes rotate-gradient {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.login-branding {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 40px;
  color: white;
  animation: fadeIn 1s ease-out;
}

.logo-container {
  width: 200px;
  height: 200px;
  margin: 0 auto 24px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  animation: float 3s ease-in-out infinite;
  padding: 15px;
  overflow: hidden;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.logo-icon {
  font-size: 48px;
  color: white;
}

.logo-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
  animation: fadeIn 0.8s ease-out;
}

.brand-title {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 32px;
  font-weight: 300;
}

.brand-features {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 32px;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  border-radius: var(--border-radius);
  backdrop-filter: blur(10px);
  transition: all var(--transition-normal);
  animation: fadeInUp 0.6s ease-out;
  animation-fill-mode: both;
}

.feature-item:nth-child(1) { animation-delay: 0.2s; }
.feature-item:nth-child(2) { animation-delay: 0.4s; }
.feature-item:nth-child(3) { animation-delay: 0.6s; }

.feature-item:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateX(5px);
}

.feature-item i {
  font-size: 18px;
  flex-shrink: 0;
}

.feature-item span {
  font-size: 14px;
  font-weight: 400;
}

/* ============================================
   FORMULARIO DE LOGIN
   ============================================ */
.login-form-container {
  position: relative;
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

/* Logo móvil */
.mobile-logo {
  animation: fadeIn 0.6s ease-out;
}

.mobile-logo-img {
  max-width: 120px;
  height: auto;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.login-header-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 20px;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  box-shadow: var(--shadow-md);
  animation: pulse-scale 2s ease-in-out infinite;
}

@keyframes pulse-scale {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 12px rgba(34, 74, 190, 0.3);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(34, 74, 190, 0.4);
  }
}

/* ============================================
   INPUTS MEJORADOS
   ============================================ */
.form-label {
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.form-label i {
  color: var(--primary-color);
}

.input-group-animated {
  margin-bottom: 24px;
  position: relative;
}

.input-wrapper {
  position: relative;
}

.form-control-user {
  border: 2px solid #e0e0e0;
  padding: 14px 48px 14px 48px;
  font-size: 15px;
  transition: all var(--transition-normal);
  background: white;
}

.form-control-user:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(34, 74, 190, 0.1);
  background: white;
}

.form-control-user.is-invalid {
  border-color: var(--danger-color);
  animation: shake 0.5s;
}

.form-control-user.is-valid {
  border-color: var(--success-color);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Icono dentro del input */
.input-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  pointer-events: none;
  transition: color var(--transition-fast);
  z-index: 1;
}

.form-control-user:focus ~ .input-icon {
  color: var(--primary-color);
}

/* Borde animado al hacer focus */
.input-focus-border {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--gradient-primary);
  transition: all var(--transition-normal);
  transform: translateX(-50%);
}

.form-control-user:focus ~ .input-focus-border {
  width: 100%;
}

/* ============================================
   BOTÓN MOSTRAR/OCULTAR CONTRASEÑA
   ============================================ */
.btn-toggle-password {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #999;
  font-size: 18px;
  padding: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-radius: 50%;
  z-index: 2;
}

.btn-toggle-password:hover {
  color: var(--primary-color);
  background: rgba(34, 74, 190, 0.1);
}

.btn-toggle-password:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.btn-toggle-password:active {
  transform: translateY(-50%) scale(0.95);
}

/* ============================================
   BOTÓN DE LOGIN
   ============================================ */
.btn-login {
  background: var(--gradient-primary);
  border: none;
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  margin-top: 8px;
}

.btn-login::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s;
}

.btn-login:hover::before {
  left: 100%;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(34, 74, 190, 0.4);
}

.btn-login:active {
  transform: translateY(0);
}

.btn-login:focus {
  box-shadow: 0 0 0 4px rgba(34, 74, 190, 0.3);
  outline: none;
}

.btn-login.loading {
  pointer-events: none;
  opacity: 0.8;
}

/* ============================================
   OVERLAY DE CARGA
   ============================================ */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(5px);
  animation: fadeIn var(--transition-fast);
}

.spinner-border {
  width: 3rem;
  height: 3rem;
  border-width: 0.3rem;
}

/* ============================================
   MENSAJES DE VALIDACIÓN
   ============================================ */
.invalid-feedback {
  display: none;
  color: var(--danger-color);
  font-size: 13px;
  margin-top: 6px;
  animation: fadeInTop 0.3s ease-out;
}

.invalid-feedback.d-block {
  display: block !important;
}

.form-text {
  font-size: 12px;
  color: #6c757d;
  margin-top: 4px;
}

/* ============================================
   DIVIDER
   ============================================ */
.divider {
  margin: 32px 0;
  border-top: 1px solid #e0e0e0;
  position: relative;
}

/* ============================================
   FOOTER DEL LOGIN
   ============================================ */
.login-footer {
  animation: fadeIn 1s ease-out 0.8s both;
}

.login-footer i {
  color: var(--success-color);
  margin-right: 4px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 991.98px) {
  .login-card {
    margin: 20px 0 !important;
  }
  
  .login-form-container {
    padding: 30px !important;
  }
}

@media (max-width: 575.98px) {
  body.login-page {
    padding: 10px;
  }
  
  .login-form-container {
    padding: 20px !important;
  }
  
  .login-header-icon {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }
  
  .brand-title {
    font-size: 24px;
  }
  
  .form-control-user {
    padding: 12px 40px 12px 40px;
    font-size: 14px;
  }
  
  .btn-login {
    padding: 12px 24px;
    font-size: 15px;
  }
}

/* ============================================
   DARK MODE (opcional para accesibilidad)
   ============================================ */
@media (prefers-color-scheme: dark) {
  body.login-page {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  }
  
  .login-card {
    background: rgba(30, 30, 46, 0.98);
  }
  
  .login-form-container h1,
  .form-label,
  .text-gray-900 {
    color: #e0e0e0 !important;
  }
  
  .form-control-user {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
  }
  
  .form-control-user:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-light);
  }
  
  .form-text,
  .text-muted {
    color: #999 !important;
  }
}

/* ============================================
   ACCESIBILIDAD - ALTO CONTRASTE
   ============================================ */
@media (prefers-contrast: high) {
  .form-control-user {
    border-width: 3px;
  }
  
  .btn-login {
    border: 3px solid var(--primary-dark);
  }
  
  .btn-toggle-password:focus {
    outline-width: 3px;
  }
  
  .skip-to-content:focus {
    outline-width: 4px;
  }
}

/* ============================================
   REDUCCIÓN DE MOVIMIENTO
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .particles-background {
    animation: none;
  }
  
  .logo-container,
  .login-header-icon {
    animation: none;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  body.login-page {
    background: white;
  }
  
  .particles-background,
  .btn-toggle-password,
  .alert {
    display: none !important;
  }
  
  .login-card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
