/**
 * LOGIN — Diseño dinámico (gradient + glassmorphism + cursor custom)
 * Portal Digital de Inversiones - Avance Corp S.A.C.
 *
 * Adaptado desde design_handoff_login (vanilla CSS).
 * Se carga DESPUÉS de main.css y sobrescribe lo necesario.
 */

/* ============================================
   TOKENS LOCALES (extienden los globales)
   ============================================ */
.login-page {
  --navy-deep: #0a1430;
  --navy-2:    #1a2f5a;
  --navy-3:    #2a4378;
  --green:     #0fb27d;
  --green-bg:  #e8f7f2;

  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  color: var(--navy-dark);
}

html.login-html, body.login-page {
  margin: 0; padding: 0; height: 100%;
  overflow: hidden;
}

.login-page * { box-sizing: border-box; }

/* ============================================
   CAPA 0 — GRADIENTE FIJO
   ============================================ */
.login-page .bg-stage {
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 18% 20%, #1a2f5a 0%, transparent 55%),
    radial-gradient(ellipse 70% 70% at 90% 80%, #f6f8fc 0%, transparent 50%),
    linear-gradient(115deg, #0a1430 0%, #111e3d 28%, #1a2f5a 45%, #3a4d78 58%, #d8dde8 72%, #f6f8fc 100%);
  z-index: 0;
}

/* Blobs flotantes */
.login-page .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  pointer-events: none;
  will-change: transform;
}
.login-page .blob-1 {
  width: 540px; height: 540px;
  background: radial-gradient(circle, rgba(200,146,42,0.35), transparent 70%);
  top: -10%; left: 10%;
  animation: drift1 22s ease-in-out infinite;
}
.login-page .blob-2 {
  width: 620px; height: 620px;
  background: radial-gradient(circle, rgba(26,47,90,0.6), transparent 65%);
  bottom: -15%; left: 25%;
  animation: drift2 28s ease-in-out infinite;
}
.login-page .blob-3 {
  width: 480px; height: 480px;
  background: radial-gradient(circle, rgba(240,192,96,0.18), transparent 65%);
  top: 30%; left: 35%;
  animation: drift3 26s ease-in-out infinite;
}
@keyframes drift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(60px, 80px) scale(1.1); }
}
@keyframes drift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-80px, -50px) scale(1.08); }
}
@keyframes drift3 {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.6; }
  50%      { transform: translate(120px, -40px) scale(1.2); opacity: 0.85; }
}

/* ============================================
   CAPA 1 — GRID + GRAIN
   ============================================ */
.login-page .grid-lines {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: linear-gradient(110deg, #000 0%, #000 45%, transparent 75%);
          mask-image: linear-gradient(110deg, #000 0%, #000 45%, transparent 75%);
}

.login-page .grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  opacity: 0.06; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.5'/></svg>");
}

/* ============================================
   CAPA 2 — PARTÍCULAS DORADAS
   ============================================ */
.login-page .particles {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
}
.login-page .particle {
  position: absolute;
  width: 3px; height: 3px;
  background: rgba(240,192,96,0.7);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(240,192,96,0.6);
  animation: float-up linear infinite;
}
@keyframes float-up {
  0%   { transform: translateY(100vh) translateX(0); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(-10vh) translateX(40px); opacity: 0; }
}

/* ============================================
   LAYOUT — SHELL 2 COLUMNAS
   ============================================ */
.login-page .shell {
  position: relative; z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 100vh;
  width: 100vw;
}
.login-page .left {
  display: flex; flex-direction: column;
  padding: 48px 64px;
  color: #fff;
  position: relative;
}
.login-page .right {
  display: flex; align-items: center; justify-content: center;
  padding: 48px;
  position: relative;
}

/* ============================================
   BRAND
   ============================================ */
.login-page .brand {
  display: flex; align-items: center; gap: 12px;
  animation: fadeUp 0.8s ease 0.1s both;
}
.login-page .brand-logo {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, #fff 0%, #eaf3ee 100%);
  border-radius: 11px;
  padding: 5px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.login-page .brand-logo img {
  width: 100%; height: 100%; object-fit: contain;
}
.login-page .brand-text-name {
  font-size: 19px; font-weight: 800; color: #fff;
  letter-spacing: -0.01em; line-height: 1;
}
.login-page .brand-text-sub {
  font-size: 10.5px; font-weight: 700;
  color: rgba(240, 192, 96, 0.85);
  letter-spacing: 0.18em;
  margin-top: 4px;
}

/* ============================================
   HERO COPY
   ============================================ */
.login-page .hero {
  margin-top: auto; margin-bottom: 60px; max-width: 460px;
}
.login-page .eyebrow {
  font-size: 11px; font-weight: 800;
  color: var(--gold-light);
  letter-spacing: 0.22em;
  margin-bottom: 18px;
  display: inline-flex; align-items: center; gap: 10px;
  animation: fadeUp 0.8s ease 0.3s both;
}
.login-page .eyebrow::before {
  content: ""; width: 28px; height: 1px;
  background: var(--gold-light);
  display: inline-block;
}
.login-page .headline {
  font-size: 44px; font-weight: 800;
  letter-spacing: -0.03em; line-height: 1.05;
  color: #fff;
  margin: 0 0 18px;
  animation: fadeUp 0.8s ease 0.4s both;
}
.login-page .headline em {
  font-style: normal;
  background: linear-gradient(135deg, #c8922a 0%, #f0c060 50%, #c8922a 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmerText 4s ease-in-out infinite;
}
@keyframes shimmerText {
  0%, 100% { background-position: 0% center; }
  50%      { background-position: 100% center; }
}
.login-page .lead {
  font-size: 14.5px; line-height: 1.6;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 28px;
  animation: fadeUp 0.8s ease 0.5s both;
}

/* ============================================
   FEATURE LIST
   ============================================ */
.login-page .features { list-style: none; margin: 0; padding: 0; }
.login-page .features li {
  display: flex; align-items: center; gap: 12px;
  font-size: 13.5px; font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  padding: 8px 0;
  animation: fadeUp 0.8s ease both;
  position: relative;
}
.login-page .features li:nth-child(1) { animation-delay: 0.6s; }
.login-page .features li:nth-child(2) { animation-delay: 0.7s; }
.login-page .features li:nth-child(3) { animation-delay: 0.8s; }
.login-page .features li:nth-child(4) { animation-delay: 0.9s; }
.login-page .features-check {
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(200, 146, 42, 0.4);
}
.login-page .features-check svg { width: 11px; height: 11px; }

/* ============================================
   FOOTER LEFT
   ============================================ */
.login-page .foot-left {
  font-size: 11px; color: rgba(255, 255, 255, 0.4);
  margin-top: 32px;
  animation: fadeUp 0.8s ease 1s both;
}

/* ============================================
   LOGIN CARD (glassmorphism)
   ============================================ */
.login-page .login-card {
  width: 100%; max-width: 420px;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
          backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  padding: 36px 36px 28px;
  box-shadow:
    0 30px 80px rgba(10, 20, 48, 0.35),
    0 4px 12px rgba(10, 20, 48, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  animation: cardIn 0.9s cubic-bezier(0.34, 1.2, 0.64, 1) 0.2s both;
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;
  will-change: transform;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.login-page .login-card::before {
  content: "";
  position: absolute; top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(240, 192, 96, 0.08), transparent);
  animation: gloss 8s ease-in-out infinite;
  animation-delay: 2s;
  pointer-events: none;
}
@keyframes gloss {
  0%, 100% { left: -100%; }
  50%      { left: 200%;  }
}

.login-page .card-title {
  font-size: 26px; font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--navy-dark);
  margin: 0 0 6px;
}
.login-page .card-sub {
  font-size: 13.5px; color: var(--text-muted);
  margin: 0 0 22px;
}

/* ============================================
   ALERT (errorAlert / success)
   ============================================ */
.login-page .login-alert {
  font-size: 12.5px;
  font-weight: 600;
  padding: 11px 14px;
  border-radius: 10px;
  margin-bottom: 18px;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.45;
  animation: alertIn 0.25s ease;
}
.login-page .login-alert.alert-danger {
  background: rgba(214, 59, 59, 0.08);
  border-color: rgba(214, 59, 59, 0.22);
  color: #b22929;
}
.login-page .login-alert.alert-success {
  background: rgba(15, 178, 125, 0.10);
  border-color: rgba(15, 178, 125, 0.28);
  color: #088a5c;
}
.login-page .login-alert.hidden { display: none !important; }
@keyframes alertIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ============================================
   FORM
   ============================================ */
.login-page .field { margin-bottom: 18px; }
.login-page .field-label {
  display: block;
  font-size: 12.5px; font-weight: 700;
  color: var(--navy-dark);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}
.login-page .input-wrap {
  position: relative;
  display: flex; align-items: center;
}
.login-page .login-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  background: #fafbfd;
  border: 1.5px solid #e8ebf2;
  border-radius: 11px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--navy-dark);
  transition: all 0.2s ease;
  outline: none;
}
.login-page .login-input::placeholder { color: #b8c0d0; }
.login-page .login-input:hover { border-color: #d0d6e0; }
.login-page .login-input:focus {
  border-color: var(--gold);
  background: #fff;
  box-shadow:
    0 0 0 4px rgba(200, 146, 42, 0.12),
    0 4px 14px rgba(200, 146, 42, 0.08);
}
.login-page .field-pass .login-input { padding-right: 48px; }

.login-page .eye {
  position: absolute; right: 14px;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}
.login-page .eye:hover { color: var(--gold); }
.login-page .eye .eye-icon { display: none; }
.login-page .eye .eye-open { display: inline; }
.login-page .eye.is-shown .eye-open  { display: none; }
.login-page .eye.is-shown .eye-closed { display: inline; }

/* Row: remember + forgot */
.login-page .row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; margin-bottom: 22px;
}
.login-page .check {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-secondary, #5a6480); font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.login-page .check input { display: none; }
.login-page .check-box {
  width: 16px; height: 16px;
  border: 1.5px solid #d0d6e0;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.login-page .check input:checked + .check-box {
  background: var(--navy-dark);
  border-color: var(--navy-dark);
}
.login-page .check input:checked + .check-box::after {
  content: ""; width: 8px; height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}
.login-page .forgot {
  font-size: 12.5px; font-weight: 700;
  color: var(--navy-dark); text-decoration: none;
  transition: color 0.2s;
}
.login-page .forgot:hover { color: var(--gold); }

/* Submit */
.login-page .submit {
  width: 100%; height: 52px;
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy-2) 100%);
  background-size: 200% auto;
  color: #fff;
  border: none;
  border-radius: 11px;
  font-family: inherit;
  font-size: 15px; font-weight: 700;
  letter-spacing: 0.015em;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  position: relative; overflow: hidden;
  box-shadow: 0 8px 24px rgba(17, 30, 61, 0.25);
  transition: all 0.3s;
}
.login-page .submit::before {
  content: "";
  position: absolute; top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(240, 192, 96, 0.3), transparent);
  transition: left 0.6s;
}
.login-page .submit:hover {
  background-position: right center;
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(17, 30, 61, 0.35);
}
.login-page .submit:hover::before { left: 100%; }
.login-page .submit:active { transform: translateY(0); }
.login-page .submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}
.login-page .submit-arrow { transition: transform 0.2s; flex-shrink: 0; }
.login-page .submit:hover:not(:disabled) .submit-arrow { transform: translateX(3px); }

/* Loading state */
.login-page .submit.loading::after {
  content: "";
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  margin-left: 8px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Card footer */
.login-page .card-foot {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px dashed #eef0f7;
  text-align: center;
}
.login-page .card-foot-1 {
  font-size: 11.5px; color: var(--text-muted);
  margin-bottom: 6px; line-height: 1.5;
}
.login-page .card-foot-2 {
  font-size: 11px; color: #b8c0d0; font-weight: 500;
  margin-bottom: 14px;
}
.login-page .ssl {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 100px;
  background: var(--green-bg);
  color: var(--green);
  font-size: 11px; font-weight: 700;
}
.login-page .ssl-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(15, 178, 125, 0.5);
  animation: pulseDot 2s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(15, 178, 125, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(15, 178, 125, 0); }
}

/* Entrance */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  /* Permitir scroll y altura natural en móvil/tablet */
  html.login-html, body.login-page {
    overflow: auto;
    height: auto;
    min-height: 100%;
  }

  .login-page .shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }
  .login-page .left { padding: 32px 28px; min-height: auto; }
  .login-page .right { padding: 32px 28px; }
  .login-page .hero { margin-top: 32px; margin-bottom: 24px; }
  .login-page .headline { font-size: 32px; }
  .login-page .foot-left { display: none; }
}

@media (max-width: 768px) {
  .login-page .left { padding: 28px 20px; }
  .login-page .right { padding: 24px 20px 40px; }
  .login-page .headline { font-size: 28px; }
  .login-page .lead { font-size: 13.5px; }
  .login-page .features li { font-size: 13px; padding: 6px 0; }

  .login-page .login-card {
    padding: 28px 22px 22px;
    border-radius: 16px;
  }
  .login-page .card-title { font-size: 22px; }
  .login-page .card-sub { font-size: 13px; margin-bottom: 18px; }

  /* Inputs: font-size 16px (evita zoom iOS) y altura 48px ya OK */
  .login-page .login-input {
    font-size: 16px;
    height: 48px;
  }
  .login-page .submit { height: 50px; font-size: 15px; }
}

@media (max-width: 480px) {
  .login-page .left { padding: 24px 18px; }
  .login-page .right { padding: 18px 16px 32px; }
  .login-page .headline { font-size: 24px; }
  .login-page .brand-text-name { font-size: 17px; }
  .login-page .brand-text-sub { font-size: 9.5px; letter-spacing: 0.14em; }
  .login-page .login-card { padding: 24px 18px 20px; }
  .login-page .row { flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
  .login-page .forgot { font-size: 12px; }
}

/* Accessibility — respeta usuarios con reduced motion */
@media (prefers-reduced-motion: reduce) {
  .login-page *,
  .login-page *::before,
  .login-page *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
