/*=============================================
LOGIN — Tornado CRM

Todo se construye sobre los tokens de theme.css
(--surface, --text-primary, --accent-primary, --radius-*,
--shadow-*), asi que el modo oscuro funciona solo: no hay
un solo color hardcodeado que haya que duplicar.

Todas las reglas cuelgan de .login-shell para no filtrar
estilos al dashboard, que comparte Bootstrap.
=============================================*/

.login-shell {
  min-height: 100vh;
  /* dvh evita que la barra del navegador en movil corte el layout */
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--bg-app);
  color: var(--text-primary);
}

/* A partir de 992px entra el panel de marca al costado */
@media (min-width: 992px) {
  .login-shell {
    grid-template-columns: 1.05fr 1fr;
  }
}

/*=============================================
PANEL DE MARCA

En pantallas chicas se colapsa a una franja
compacta arriba del formulario.
=============================================*/

.login-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  padding: 40px 32px;
  background:
    radial-gradient(120% 90% at 12% 0%, var(--sidebar-bg-2) 0%, var(--sidebar-bg) 62%);
  color: var(--sidebar-fg-strong);
}

@media (min-width: 992px) {
  .login-brand {
    padding: 56px 60px;
  }
}

/* Imagen de fondo opcional (admins.back_admin). Se pone
   como capa con un velo para no matar el contraste del texto. */
.login-brand__bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.22;
  pointer-events: none;
}

.login-brand > *:not(.login-brand__bg) {
  position: relative;
  z-index: 1;
}

/* Trama sutil de fondo. Decorativa: se oculta a lectores. */
.login-brand__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--sidebar-hover) 1px, transparent 1px),
    linear-gradient(90deg, var(--sidebar-hover) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: 0.35;
  mask-image: radial-gradient(70% 60% at 20% 30%, #000 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(70% 60% at 20% 30%, #000 0%, transparent 75%);
  pointer-events: none;
}

.login-brand__lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand__mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}

.login-brand__mark svg {
  width: 26px;
  height: 26px;
}

.login-brand__name {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: #fff;
}

.login-brand__headline {
  margin: 0;
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: #fff;
  max-width: 18ch;
}

.login-brand__sub {
  margin: 0;
  /* Sobre el fondo oscuro este gris supera 4.5:1 */
  color: var(--sidebar-fg);
  font-size: 0.9375rem;
  line-height: 1.6;
  max-width: 46ch;
}

.login-brand__points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.login-brand__points li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-fg);
  font-size: 0.875rem;
}

.login-brand__points svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--sidebar-active-fg);
}

/* En movil el panel se reduce a la marca sola */
@media (max-width: 991.98px) {
  .login-brand {
    padding: 24px 20px;
    gap: 0;
  }
  .login-brand__headline,
  .login-brand__sub,
  .login-brand__points,
  .login-brand__grid {
    display: none;
  }
}

/*=============================================
COLUMNA DEL FORMULARIO
=============================================*/

.login-main {
  display: grid;
  place-items: center;
  padding: 32px 20px 48px;
}

@media (min-width: 992px) {
  .login-main {
    padding: 40px;
  }
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-card__title {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.login-card__sub {
  margin: 0 0 28px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

/*=============================================
CAMPOS
=============================================*/

.login-field {
  margin-bottom: 18px;
}

.login-field__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.login-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.login-field__top .login-label {
  margin-bottom: 0;
}

.login-input {
  width: 100%;
  /* 46px: por encima del minimo de 44px de area tactil */
  height: 46px;
  padding: 0 14px;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 160ms ease, box-shadow 160ms ease;
  appearance: none;
}

.login-input::placeholder {
  color: var(--text-muted);
}

.login-input:hover {
  border-color: var(--border-strong);
}

.login-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Anillo de foco tambien para navegacion por teclado */
.login-input:focus-visible {
  outline: none;
}

/*=============================================
CONTRASEÑA CON TOGGLE

El boton lleva las clases .viewPass y .bi-* directamente
porque el handler de forms.js hace addClass/removeClass
sobre el propio elemento clickeado. Si el icono fuera un
hijo, un click en el padding del boton no dispararia el
handler delegado de jQuery.
=============================================*/

.login-pass {
  position: relative;
}

.login-pass .login-input {
  padding-right: 46px;
}

.login-pass-toggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  background: none;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  transition: color 160ms ease;
}

.login-pass-toggle:hover {
  color: var(--text-secondary);
}

.login-pass-toggle:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

.login-forgot {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent-primary);
  text-decoration: none;
  white-space: nowrap;
}

.login-forgot:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.login-forgot:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/*=============================================
RECORDAR
=============================================*/

.login-remember {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 4px 0 24px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  /* Ancho al contenido para que el label no sea clickeable
     a lo largo de toda la fila */
  width: fit-content;
}

.login-remember input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent-primary);
  cursor: pointer;
  margin: 0;
}

.login-remember input:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/*=============================================
BOTON PRINCIPAL
=============================================*/

.login-submit {
  width: 100%;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent-primary);
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 160ms ease, transform 120ms ease;
}

.login-submit:hover {
  background: var(--accent-hover);
}

/* Sin desplazar el layout: transform no reflowea */
.login-submit:active {
  transform: translateY(1px);
}

.login-submit:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/*=============================================
CAPTCHA (aparece tras 3 intentos fallidos)
=============================================*/

.login-captcha {
  padding: 16px;
  margin-bottom: 18px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.login-captcha__row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.login-captcha__img {
  height: 56px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.login-captcha__reload {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

.login-captcha__reload:hover {
  background: var(--surface-muted);
  color: var(--text-primary);
}

.login-captcha__reload:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.login-captcha__hint {
  display: block;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.login-captcha .login-input {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
}

/*=============================================
MENSAJES DEL CONTROLADOR

AdminsController::login() imprime <div class="alert
alert-danger"> dentro del formulario. Se les da el
tratamiento del tema en vez del de Bootstrap.
=============================================*/

.login-card .alert {
  margin: 0 0 18px;
  padding: 12px 14px;
  font-size: 0.875rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
}

.login-card .alert-danger {
  color: var(--danger-text);
  background: var(--danger-soft);
  border-color: var(--danger-soft);
}

.login-card .alert-success {
  color: var(--success-text);
  background: var(--success-soft);
  border-color: var(--success-soft);
}

/*=============================================
PIE
=============================================*/

.login-foot {
  margin-top: 28px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/*=============================================
MODAL DE RECUPERAR CONTRASEÑA
=============================================*/

.login-modal .modal-content {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.login-modal .modal-header,
.login-modal .modal-footer {
  border-color: var(--divider);
}

.login-modal .modal-title {
  font-size: 1.0625rem;
  font-weight: 700;
}

.login-btn-ghost {
  height: 42px;
  padding: 0 16px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.login-btn-ghost:hover {
  color: var(--text-primary);
  background: var(--surface);
}

.login-modal .login-submit {
  width: auto;
  height: 42px;
  padding: 0 20px;
}

/*=============================================
MOVIMIENTO REDUCIDO
=============================================*/

@media (prefers-reduced-motion: reduce) {
  .login-shell *,
  .login-shell *::before,
  .login-shell *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
