/* === Estructura general === */
body {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
}

/* Sutil textura de fondo */
body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: radial-gradient(circle at 20% 50%, rgba(59, 73, 223, 0.03) 0%, transparent 50%),
                    radial-gradient(circle at 80% 80%, rgba(59, 73, 223, 0.03) 0%, transparent 50%);
  pointer-events: none;
}

/* === Contenedor principal === */
.container {
  position: relative;
  z-index: 1;
}

/* === Título === */
h1.h2 {
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.75rem;
  font-size: 1.875rem;
  letter-spacing: -0.025em;
}

p.lead {
  font-size: 0.9375rem;
  color: #64748b;
  margin-bottom: 2rem;
  font-weight: 400;
}

/* === Tarjeta principal === */
.card {
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 1rem;
  background-color: #ffffff;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 
              0 2px 4px -1px rgba(0, 0, 0, 0.03);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 
              0 4px 6px -2px rgba(0, 0, 0, 0.04);
  transform: translateY(-2px);
}

.card-body {
  padding: 2.5rem;
}

/* === Labels === */
.form-label {
  font-weight: 500;
  color: #334155;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  display: block;
}

/* === Inputs === */
.form-control-lg {
  border-radius: 0.625rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid #e2e8f0;
  background-color: #ffffff;
  font-size: 0.9375rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  height: 48px;
  font-family: inherit;
}

.form-control-lg:hover {
  border-color: #cbd5e1;
}

.form-control-lg:focus {
  border-color: #3b49df;
  box-shadow: 0 0 0 3px rgba(59, 73, 223, 0.1);
  outline: none;
  background-color: #ffffff;
}

.form-control-lg::placeholder {
  color: #94a3b8;
  font-style: normal;
  opacity: 1;
}

/* === Password input group === */
.input-group {
  position: relative;
  display: flex;
  align-items: stretch;
}

.input-group .form-control-lg {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
  padding-right: 1rem;
}

.input-group .form-control-lg:focus {
  border-right: none;
}

/* === Botón del ícono (toggle password) === */
.input-group .toggle-password {
  height: 48px;
  width: 48px;
  padding: 0;
  border: 1.5px solid #e2e8f0;
  border-left: none;
  background-color: #ffffff;
  color: #64748b;
  border-radius: 0.625rem;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 1.125rem;
}

.input-group .toggle-password:hover {
  background-color: #f8fafc;
  color: #3b49df;
}

.input-group .toggle-password:focus {
  outline: none;
  border-color: #3b49df;
  box-shadow: 0 0 0 3px rgba(59, 73, 223, 0.1);
}

/* Cuando el input está enfocado, el botón también cambia */
.input-group .form-control-lg:focus ~ .toggle-password,
.input-group:focus-within .toggle-password {
  border-color: #3b49df;
}

/* === Checkbox === */
.form-check {
  display: flex;
  align-items: center;
  padding-left: 0;
}

.form-check-input {
  width: 1.125rem;
  height: 1.125rem;
  margin-right: 0.625rem;
  border: 1.5px solid #cbd5e1;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
}

.form-check-input:checked {
  background-color: #3b49df;
  border-color: #3b49df;
}

.form-check-input:focus {
  box-shadow: 0 0 0 3px rgba(59, 73, 223, 0.1);
  border-color: #3b49df;
}

.form-check-label {
  color: #475569;
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
  line-height: 1.5;
}

/* === Botón de login === */
.btn-primary {
  background-color: #3b49df;
  border: none;
  border-radius: 0.625rem;
  font-weight: 600;
  padding: 0.875rem 1.5rem;
  font-size: 0.9375rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  height: 48px;
  letter-spacing: 0.015em;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
  background-color: #2f3ab8;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(59, 73, 223, 0.3), 
              0 2px 4px -1px rgba(59, 73, 223, 0.2);
}

.btn-primary:active {
  background-color: #2830a0;
  transform: translateY(0);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-primary:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 73, 223, 0.4);
}

/* === Enlaces === */
.text-center a {
  color: #3b49df;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s ease;
}

.text-center a:hover {
  color: #2f3ab8;
  text-decoration: underline;
}

/* === Animación de entrada === */
.card {
  animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Footer === */
.footer-text {
  font-size: 0.8125rem;
  color: #94a3b8;
  text-align: center;
  margin-top: 1.5rem;
}

/* === Espaciado === */
.mb-3 {
  margin-bottom: 1.25rem;
}

.mt-3 {
  margin-top: 1.25rem;
}

/* === Estados de carga === */
.btn-primary.loading {
  pointer-events: none;
  opacity: 0.7;
  position: relative;
}

.btn-primary.loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  top: 50%;
  left: 50%;
  margin-left: -9px;
  margin-top: -9px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
  to {
    transform: rotate(360deg);
  }
}

/* === Responsive === */
@media (max-width: 576px) {
  body {
    padding: 1rem;
  }

  .card-body {
    padding: 2rem 1.5rem;
  }

  h1.h2 {
    font-size: 1.625rem;
  }

  .form-control-lg,
  .btn-primary,
  .input-group .toggle-password {
    height: 44px;
  }
}

/* === Accesibilidad === */
*:focus-visible {
  outline: 2px solid #3b49df;
  outline-offset: 2px;
}

.form-control-lg:focus-visible,
.form-check-input:focus-visible,
.btn-primary:focus-visible,
.toggle-password:focus-visible {
  outline: none;
}

/* === Estados de error === */
.form-control-lg.is-invalid {
  border-color: #ef4444;
}

.form-control-lg.is-invalid:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* === Mejoras visuales sutiles === */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #3b49df 0%, #5865f2 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover::before {
  opacity: 1;
}

/* === Indicador de fortaleza de contraseña === */
.password-strength {
  height: 3px;
  background-color: #e2e8f0;
  border-radius: 3px;
  margin-top: 0.5rem;
  overflow: hidden;
  display: none;
}

.password-strength.active {
  display: block;
}

.password-strength-bar {
  height: 100%;
  width: 0%;
  transition: all 0.3s ease;
  border-radius: 3px;
}

.password-strength-bar.weak {
  width: 33%;
  background-color: #ef4444;
}

.password-strength-bar.medium {
  width: 66%;
  background-color: #f59e0b;
}

.password-strength-bar.strong {
  width: 100%;
  background-color: #10b981;
}

.password-strength-text {
  font-size: 0.75rem;
  margin-top: 0.25rem;
  font-weight: 500;
  display: none;
}

.password-strength-text.active {
  display: block;
}

.password-strength-text.weak {
  color: #ef4444;
}

.password-strength-text.medium {
  color: #f59e0b;
}

.password-strength-text.strong {
  color: #10b981;
}

/* === Auto-fill styling === */
.form-control-lg:-webkit-autofill,
.form-control-lg:-webkit-autofill:hover,
.form-control-lg:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 30px white inset !important;
  -webkit-text-fill-color: #1e293b !important;
  border-color: #3b49df;
  transition: background-color 5000s ease-in-out 0s;
}

/* === Efecto ripple en el botón === */
.btn-primary {
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-primary:active::before {
  width: 300px;
  height: 300px;
}

/* === Shake animation para errores === */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

.form-control-lg.error-shake {
  animation: shake 0.5s;
  border-color: #ef4444;
}

/* === Tooltip de ayuda === */
.form-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
}

.form-help-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #e2e8f0;
  color: #64748b;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  transition: all 0.2s ease;
}

.form-help-icon:hover {
  background-color: #3b49df;
  color: white;
}

.form-help-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background-color: #1e293b;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
}

.form-help-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #1e293b;
}

.form-help-icon:hover + .form-help-tooltip {
  opacity: 1;
}

/* === Progreso de carga en el botón === */
.btn-primary.loading-progress {
  background: linear-gradient(90deg, 
    #2f3ab8 0%, 
    #3b49df 50%, 
    #2f3ab8 100%);
  background-size: 200% 100%;
  animation: loading-gradient 1.5s ease infinite;
}

@keyframes loading-gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* === Badge de notificación === */
.notification-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: #ef4444;
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 0.125rem 0.375rem;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* === Mensaje de error inline === */
.form-error-message {
  font-size: 0.8125rem;
  color: #ef4444;
  margin-top: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-error-message i {
  font-size: 0.875rem;
}

/* === Skeleton loading === */
.skeleton {
  background: linear-gradient(90deg, 
    #f0f0f0 25%, 
    #e0e0e0 50%, 
    #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 0.375rem;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* === Modo oscuro (opcional) === */
@media (prefers-color-scheme: dark) {
  body.dark-mode {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  }

  .dark-mode .card {
    background-color: #1e293b;
    border-color: #334155;
  }

  .dark-mode h1.h2 {
    color: #f1f5f9;
  }

  .dark-mode p.lead {
    color: #94a3b8;
  }

  .dark-mode .form-label {
    color: #e2e8f0;
  }

  .dark-mode .form-control-lg {
    background-color: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
  }

  .dark-mode .form-control-lg:focus {
    background-color: #1e293b;
    border-color: #3b49df;
  }

  .dark-mode .input-group .toggle-password {
    background-color: #0f172a;
    border-color: #334155;
    color: #94a3b8;
  }

  .dark-mode .input-group .toggle-password:hover {
    background-color: #1e293b;
  }
}

/* === Indicador de Caps Lock activo === */
.caps-lock-warning {
  position: absolute;
  right: 3.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: #f59e0b;
  font-size: 0.875rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.caps-lock-warning.active {
  opacity: 1;
}

/* === Efecto de focus en todo el formulario === */
.form-control-lg:focus ~ .form-focus-indicator {
  opacity: 1;
}

/* === Divider con texto === */
.form-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 1.5rem 0;
}

.form-divider::before,
.form-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #e2e8f0;
}

.form-divider span {
  padding: 0 1rem;
  color: #94a3b8;
  font-size: 0.875rem;
  font-weight: 500;
}

/* === Animación de éxito === */
@keyframes successPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
  }
}

.btn-primary.success {
  background-color: #10b981;
  animation: successPulse 1s ease-out;
}

/* === Mejora de accesibilidad - Skip link === */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: #3b49df;
  color: white;
  padding: 0.5rem 1rem;
  text-decoration: none;
  border-radius: 0 0 0.375rem 0;
  z-index: 1000;
}

.skip-to-content:focus {
  top: 0;
}