/* CRM — pantalla de login premium (Ingenio #0F4C97) */

:root {
  --ingenio-blue: #0f4c97;
  --ingenio-blue-dark: #0a3568;
  --ingenio-blue-light: #1a6bc4;
  --ingenio-blue-glow: rgba(26, 107, 196, 0.45);
  --auth-glass: rgba(255, 255, 255, 0.12);
  --auth-glass-border: rgba(255, 255, 255, 0.28);
  --auth-text-on-dark: #f8fafc;
  --auth-muted-on-dark: rgba(248, 250, 252, 0.78);
}

.auth-forgot-link {
  display: block;
  width: 100%;
  margin-top: 0.85rem;
  background: none;
  border: none;
  color: var(--auth-muted-on-dark);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.2s ease;
}
.auth-forgot-link:hover {
  color: var(--auth-text-on-dark);
  text-decoration: underline;
}

#login-route.auth-page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  overflow: hidden;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

#login-route.hidden {
  display: none !important;
}

/* —— Fondo —— */
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.auth-bg-gradient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(26, 107, 196, 0.55) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 85% 90%, rgba(15, 76, 151, 0.5) 0%, transparent 50%),
    linear-gradient(145deg, #061a33 0%, var(--ingenio-blue) 38%, #0c3d78 72%, #051525 100%);
  background-size: 120% 120%;
  animation: auth-gradient-shift 18s ease-in-out infinite alternate;
}

@keyframes auth-gradient-shift {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 100% 100%;
  }
}

.auth-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.55;
  will-change: transform;
}

.auth-blob--1 {
  width: min(420px, 55vw);
  height: min(420px, 55vw);
  top: -8%;
  left: -6%;
  background: #3b82f6;
  animation: auth-blob-float 14s ease-in-out infinite;
}

.auth-blob--2 {
  width: min(360px, 48vw);
  height: min(360px, 48vw);
  bottom: -12%;
  right: -4%;
  background: #60a5fa;
  animation: auth-blob-float 16s ease-in-out infinite reverse;
}

.auth-blob--3 {
  width: min(280px, 40vw);
  height: min(280px, 40vw);
  top: 42%;
  left: 58%;
  background: #0ea5e9;
  animation: auth-blob-float 12s ease-in-out infinite 2s;
}

@keyframes auth-blob-float {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(24px, -18px) scale(1.06);
  }
}

.auth-particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.35;
}

.auth-float-cards {
  position: absolute;
  inset: 0;
}

.auth-float-card {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.15rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--auth-text-on-dark);
  opacity: 0.08;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  backdrop-filter: blur(8px);
  will-change: transform;
}

.auth-float-card svg {
  width: 28px;
  height: 28px;
  opacity: 0.9;
}

.auth-float-card--1 {
  top: 12%;
  left: 8%;
}

.auth-float-card--2 {
  top: 22%;
  right: 10%;
}

.auth-float-card--3 {
  bottom: 18%;
  left: 12%;
}

.auth-float-card--4 {
  bottom: 14%;
  right: 14%;
}

/* —— Contenido —— */
.auth-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-bottom: 1.75rem;
  color: var(--auth-text-on-dark);
}

.auth-logo-wrap {
  flex-shrink: 0;
  padding: 0.5rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--auth-glass-border);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 0 40px var(--ingenio-blue-glow);
  animation: auth-logo-glow 4s ease-in-out infinite;
}

@keyframes auth-logo-glow {
  0%,
  100% {
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.05),
      0 8px 32px rgba(0, 0, 0, 0.2),
      0 0 28px var(--ingenio-blue-glow);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.08),
      0 12px 40px rgba(0, 0, 0, 0.25),
      0 0 52px rgba(26, 107, 196, 0.55);
  }
}

.auth-logo-img {
  display: block;
  width: 72px;
  height: auto;
  object-fit: contain;
  animation: auth-logo-in 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes auth-logo-in {
  from {
    opacity: 0;
    transform: scale(0.88);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.auth-brand-text strong {
  display: block;
  font-size: clamp(1.2rem, 3.5vw, 1.45rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.auth-slogan {
  margin: 0.35rem 0 0.25rem;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--auth-muted-on-dark);
  max-width: 28ch;
}

.auth-sub {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.65;
}

/* —— Tarjeta glass —— */
.auth-card {
  position: relative;
  padding: clamp(1.5rem, 4vw, 2rem);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--auth-glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.04),
    0 24px 48px rgba(6, 26, 51, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition:
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.4s ease;
  animation: auth-card-in 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.12s;
}

.auth-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 12px rgba(0, 0, 0, 0.06),
    0 32px 56px rgba(6, 26, 51, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

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

.auth-title {
  margin: 0 0 0.4rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff;
}

.auth-lead {
  margin: 0 0 1.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.82);
}

/* —— Campos —— */
.auth-field {
  display: block;
  margin-bottom: 1.1rem;
}

.auth-field__label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  letter-spacing: 0.02em;
}

.auth-field__control {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-field__icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: rgba(15, 76, 151, 0.55);
  pointer-events: none;
  transition: color 0.3s ease;
  z-index: 1;
}

.auth-field__icon svg {
  width: 100%;
  height: 100%;
}

#login-form input {
  width: 100%;
  padding: 0.8rem 0.85rem 0.8rem 2.65rem;
  font-family: inherit;
  font-size: 1rem;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease,
    background 0.3s ease,
    transform 0.2s ease;
}

#login-form .password-input-wrap input {
  padding-right: 2.85rem;
}

#login-form input::placeholder {
  color: #94a3b8;
}

#login-form input:hover {
  background: #fff;
}

#login-form input:focus {
  outline: none;
  border-color: var(--ingenio-blue-light);
  background: #fff;
  box-shadow:
    0 0 0 3px rgba(15, 76, 151, 0.2),
    0 0 24px rgba(26, 107, 196, 0.25);
  transform: translateY(-1px);
}

#login-form input:focus + .password-toggle,
#login-form input:focus ~ .auth-field__icon,
.auth-field__control:focus-within .auth-field__icon {
  color: var(--ingenio-blue);
}

.password-toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  border: none;
  background: transparent;
  color: #64748b;
  border-radius: 8px;
  cursor: pointer;
  transition:
    color 0.3s ease,
    background 0.3s ease;
  z-index: 2;
}

.password-toggle:hover {
  color: var(--ingenio-blue);
  background: rgba(15, 76, 151, 0.08);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--ingenio-blue-light);
  outline-offset: 2px;
}

.password-toggle__icon {
  display: flex;
}

/* —— Botón —— */
.btn-login {
  position: relative;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.9rem 1.25rem;
  min-height: 52px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  overflow: hidden;
  background: linear-gradient(135deg, var(--ingenio-blue-light) 0%, var(--ingenio-blue) 50%, var(--ingenio-blue-dark) 100%);
  background-size: 200% 200%;
  box-shadow:
    0 4px 14px rgba(15, 76, 151, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition:
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.3s ease,
    background-position 0.4s ease;
}

.btn-login:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.01);
  box-shadow:
    0 8px 24px rgba(15, 76, 151, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  background-position: 100% 50%;
}

.btn-login:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.btn-login:disabled {
  cursor: wait;
  opacity: 0.92;
}

.btn-login__text {
  position: relative;
  z-index: 1;
  transition: opacity 0.25s ease;
}

.btn-login__spinner {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
}

.btn-login.is-loading .btn-login__text {
  opacity: 0;
}

.btn-login.is-loading .btn-login__spinner {
  display: block;
}

.btn-login .btn-ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: rgba(255, 255, 255, 0.45);
  animation: auth-ripple 0.55s ease-out forwards;
  pointer-events: none;
}

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

@keyframes auth-ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* —— Mensaje —— */
.login-msg {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  line-height: 1.45;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.login-msg.msg-err {
  background: rgba(185, 28, 28, 0.2);
  border-color: rgba(248, 113, 113, 0.4);
  color: #fecaca;
}

.login-msg.hidden {
  display: none !important;
}

.auth-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--auth-muted-on-dark);
}

/* —— Entrada secuencial —— */
.auth-reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: auth-reveal 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(0.08s * var(--reveal-i, 0));
}

@keyframes auth-reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 520px) {
  .auth-brand {
    flex-direction: column;
    text-align: center;
  }

  .auth-slogan {
    max-width: none;
  }

  .auth-float-card {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-bg-gradient,
  .auth-blob,
  .auth-logo-wrap,
  .auth-logo-img,
  .auth-card,
  .auth-reveal,
  .auth-particles {
    animation: none !important;
  }

  /* Sin animación, .auth-reveal queda en opacity:0 — mostrar el formulario igual */
  .auth-reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  .auth-card:hover,
  .btn-login:hover:not(:disabled) {
    transform: none;
  }
}
