/**
 * Estilos para validaciones en tiempo real - Sistema de Autenticación
 * Coparmex Metropolitano
 */

/* ==========================================================================
   VALIDACIÓN DE CAMPOS
   ========================================================================== */

/* Estados de validación */
.form-control.is-valid {
  border-color: #28a745;
  padding-right: calc(1.5em + 0.75rem);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='m2.3 6.73.94-.94 1.44-1.44L5.4 3.61l.72-.72a.75.75 0 0 1 1.06 1.06L4.86 6.27a.75.75 0 0 1-1.06 0L2.29 4.76a.75.75 0 0 1 1.06-1.06L2.3 6.73z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-invalid {
  border-color: #dc3545;
  padding-right: calc(1.5em + 0.75rem);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 4.6 2.4 2.4m0-2.4L5.8 7'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-loading {
  border-color: #17a2b8;
  padding-right: calc(1.5em + 0.75rem);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='%2317a2b8' d='M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2v1z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

/* Mensajes de feedback */
.valid-feedback {
  color: #28a745;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.invalid-feedback {
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.loading-feedback {
  color: #17a2b8;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.warning-feedback {
  color: #ffc107;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.loading-feedback .fa-spinner {
  margin-right: 0.5rem;
}

.warning-feedback .fa-exclamation-triangle {
  margin-right: 0.5rem;
}

/* ==========================================================================
   INDICADOR DE FORTALEZA DE CONTRASEÑA
   ========================================================================== */

.password-strength {
  margin-top: 0.5rem;
}

.strength-bar {
  height: 6px;
  background-color: #e9ecef;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.strength-fill {
  height: 100%;
  transition: width 0.3s ease, background-color 0.3s ease;
  border-radius: 3px;
}

.password-strength.very-weak .strength-fill {
  background-color: #dc3545;
}

.password-strength.weak .strength-fill {
  background-color: #fd7e14;
}

.password-strength.medium .strength-fill {
  background-color: #ffc107;
}

.password-strength.strong .strength-fill {
  background-color: #28a745;
}

.strength-text {
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
}

.password-strength.very-weak .strength-text {
  color: #dc3545;
}

.password-strength.weak .strength-text {
  color: #fd7e14;
}

.password-strength.medium .strength-text {
  color: #ffc107;
}

.password-strength.strong .strength-text {
  color: #28a745;
}

/* ==========================================================================
   ERRORES DE FORMULARIO
   ========================================================================== */

.form-error {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
}

/* ==========================================================================
   ANIMACIONES Y TRANSICIONES
   ========================================================================== */

.form-control {
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out,
    background-image 0.15s ease-in-out;
}

.invalid-feedback,
.valid-feedback,
.loading-feedback,
.warning-feedback {
  opacity: 0;
  animation: fadeIn 0.2s ease-in-out forwards;
}

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

/* ==========================================================================
   MEJORAS VISUALES PARA EL FORMULARIO
   ========================================================================== */

.form-group {
  position: relative;
  margin-bottom: 1.5rem;
}

/* Estilo para campos con icono */
.input-with-icon {
  position: relative;
}

.input-with-icon .form-control {
  padding-left: 2.5rem;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #6c757d;
  z-index: 4;
}

/* Hover y focus states mejorados */
.form-control:focus {
  border-color: #80bdff;
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-control.is-valid:focus {
  border-color: #28a745;
  box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

.form-control.is-invalid:focus {
  border-color: #dc3545;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 576px) {
  .password-strength {
    margin-top: 0.75rem;
  }

  .strength-text {
    font-size: 0.8rem;
  }

  .invalid-feedback,
  .valid-feedback,
  .loading-feedback,
  .warning-feedback {
    font-size: 0.8rem;
  }
}

/* ==========================================================================
   TEMA OSCURO (OPCIONAL)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  .strength-bar {
    background-color: #495057;
  }

  .input-with-icon .input-icon {
    color: #adb5bd;
  }
}

/* ==========================================================================
   UTILIDADES DE ACCESIBILIDAD
   ========================================================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible para usuarios de teclado */
.form-control:focus-visible {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

/* Indicadores de estado para lectores de pantalla */
.form-control[aria-invalid="true"] {
  border-color: #dc3545;
}

.form-control[aria-invalid="false"] {
  border-color: #28a745;
}

/* ==========================================================================
   MEJORAS ADICIONALES UX
   ========================================================================== */

/* Progress bar para formulario de registro */
.form-progress {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 0.5rem;
  border: 1px solid #dee2e6;
}

.progress-bar {
  height: 8px;
  background-color: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #007bff 0%, #0056b3 100%);
  transition: width 0.5s ease;
  border-radius: 4px;
}

.progress-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: #495057;
  text-align: center;
}

/* Password visibility toggle */
.password-toggle {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  z-index: 5;
  transition: color 0.15s ease;
}

.password-toggle:hover {
  color: #007bff;
}

.password-toggle:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* Auto-save indicator */
.auto-save-indicator {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #28a745;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.auto-save-indicator .fa {
  margin-right: 0.5rem;
}

/* Validation tooltip */
.validation-tooltip {
  background: #007bff;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
  pointer-events: none;
  opacity: 0;
  animation: tooltipFadeIn 0.3s ease forwards;
}

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

/* Form transitions */
.login_form,
.registration_form {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Auto-save animation */
@keyframes fadeInOut {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  20%,
  80% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Keyboard shortcuts hint */
.keyboard-shortcuts-hint {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.keyboard-shortcuts-hint.show {
  opacity: 1;
}

/* Enhanced form styling */
.form-group {
  position: relative;
}

.input-with-icon {
  position: relative;
}

.input-with-icon .form-control {
  padding-right: 3rem; /* Make room for toggle button */
}

/* Loading state for forms */
.form-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.form-loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* Improved focus states */
.form-control:focus {
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
  border-color: #80bdff;
}

/* Enhanced button states */
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Mobile enhancements */
@media (max-width: 768px) {
  .form-progress {
    margin-bottom: 1rem;
    padding: 0.75rem;
  }

  .progress-text {
    font-size: 0.8rem;
  }

  .auto-save-indicator {
    top: 10px;
    right: 10px;
    font-size: 0.8rem;
    padding: 0.375rem 0.75rem;
  }

  .validation-tooltip {
    font-size: 0.75rem;
    padding: 0.375rem 0.5rem;
  }

  .keyboard-shortcuts-hint {
    display: none; /* Hide on mobile */
  }
}
