/* ====== Importaciones de fuentes ====== */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;800&family=Inter:wght@300;400;600&display=swap');

/* ====== Variables CSS - Paleta corporativa ====== */
:root {
  /* Colores principales */
  --brand: #00A74D;       /* Verde principal (logo) */
  --brand-neon: #00C853;  /* Verde brillo/acentos */
  --bg1: #E8F5E9;         /* Fondo suave 1 */
  --bg2: #C8E6C9;         /* Fondo suave 2 */
  --ink: #00A74D;         /* Texto oscuro */
  --muted: #546E7A;       /* Texto secundario */
  --card: rgba(255,255,255,0.55); /* Efecto vidrio */
  --card-stroke: rgba(0,0,0,0.10);
  --danger: #ff1744;
  
  /* Variables para animaciones y transiciones */
  --transition-speed: 0.25s;
  --transition-slow: 0.7s;
  --blur-amount: 10px;
  --border-radius: 20px;
  --border-radius-sm: 12px;
}

/* ====== Estilos base ====== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--ink);
  /* Base muy suave para que las capas brillantes destaquen */
  background:
    radial-gradient(1200px 900px at 85% 10%, rgba(0,200,83,.12), transparent 60%),
    radial-gradient(1000px 700px at 10% 90%, rgba(0,167,77,.10), transparent 60%),
    linear-gradient(135deg, var(--bg1), var(--bg2));
  overflow-x: hidden;
  position: relative;
  /* Mejora de rendimiento para animaciones */
  will-change: transform;
}

/* ====== Efectos de fondo - Auroras Neón Dinámicas ====== */
.bg-blobs::before,
.bg-blobs::after {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  /* Dos auroras que se cruzan, con brillo y blur */
  background:
    radial-gradient(60% 140% at 20% 20%, rgba(0,200,83,.55), transparent 60%),
    radial-gradient(40% 110% at 80% 70%, rgba(0,167,77,.50), transparent 60%),
    conic-gradient(from 0deg at 50% 50%,
      rgba(0,200,83,.20),
      rgba(0,167,77,.10),
      rgba(0,200,83,.18),
      rgba(0,167,77,.10),
      rgba(0,200,83,.20));
  filter: blur(28px) saturate(125%) drop-shadow(0 0 30px rgba(0,200,83,.18));
  mix-blend-mode: screen;
  animation: auroraShift 16s ease-in-out infinite alternate;
  /* Optimización para animaciones */
  will-change: transform, filter;
}

.bg-blobs::after {
  /* Segunda capa con fase distinta para más profundidad */
  animation-duration: 22s;
  animation-delay: -6s;
  opacity: .75;
  transform: scale(1.05);
}

@keyframes auroraShift {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1); filter: blur(26px) saturate(120%); }
  50%  { transform: translate3d( 2%,  1%, 0) scale(1.03); filter: blur(30px) saturate(135%); }
  100% { transform: translate3d(-1%,  2%, 0) scale(0.99); filter: blur(26px) saturate(120%); }
}

/* ====== Grid Holográfica con efecto "scan" ====== */
.holo-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(transparent 31px, rgba(0,167,77,.10) 32px),
    linear-gradient(90deg, transparent 31px, rgba(0,167,77,.10) 32px);
  background-size: 32px 32px;
  /* Viñeta superior: el grid se "pierde" hacia arriba */
  mask-image: radial-gradient(120% 80% at 50% 15%, #000 55%, transparent 85%);
  opacity: .55;
  transform: perspective(1100px) rotateX(55deg) translateY(-8%);
  transform-origin: top center;
  animation: scan 9s linear infinite;
  /* Optimización para animaciones */
  will-change: transform, background-position;
}

@keyframes scan {
  0%   { background-position: 0 0, 0 0; }
  100% { background-position: 0 64px, 64px 0; }
}

/* ====== Layout principal ====== */
.login-container {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
  width: min(1180px, 94vw);
  margin: min(8vh, 56px) auto;
  align-items: stretch;
  /* Mejora de rendimiento */
  contain: layout;
}

/* ====== Panel izquierdo - Branding ====== */
.left-panel {
  border: 1px solid var(--card-stroke);
  border-radius: var(--border-radius);
  backdrop-filter: blur(var(--blur-amount));
  background: var(--card);
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: clamp(20px, 5vw, 40px);
  text-align: center;
  transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.left-panel:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0,0,0,.1);
}

.left-inner {
  position: relative;
  z-index: 1;
}

.brand {
  font-family: Orbitron, Inter, sans-serif;
  font-weight: 800;
  letter-spacing: .06em;
  font-size: clamp(28px, 3.4vw, 44px);
  text-transform: uppercase;
  color: var(--ink);
  transition: text-shadow var(--transition-speed) ease;
}

.left-panel:hover .brand {
  text-shadow: 0 0 15px rgba(0,167,77,.3);
}

.brand-sub {
  color: var(--muted);
  margin-top: 6px;
  letter-spacing: .18em;
  font-size: clamp(11px, 1.1vw, 14px);
  transition: opacity var(--transition-speed) ease;
}

.left-panel:hover .brand-sub {
  opacity: 0.8;
}

/* Muestra de logos */
.brand-logos {
  margin-top: clamp(18px, 2.2vw, 26px);
  width: 100%;
  max-width: 520px;
  height: clamp(180px, 26vw, 260px);
  border-radius: 14px;
  border: 1px dashed rgba(0,0,0,.12);
  background:
   url('../images/Logo_Impulsa_Peru.png') no-repeat center 35% / 80%,
   url('../images/Impulsa_Perú.png') no-repeat center 75% / 36%;
  filter: drop-shadow(0 0 18px rgba(0,167,77,.18));
  position: relative;
  transition: filter var(--transition-speed) ease;
}

.left-panel:hover .brand-logos {
  filter: drop-shadow(0 0 25px rgba(0,167,77,.25));
}

/* ====== Panel derecho - Tarjeta de login ====== */
.right-panel {
  display: grid;
  place-items: center;
  position: relative;
}

.login-card {
  width: min(460px, 92vw);
  border-radius: var(--border-radius);
  border: 1px solid var(--card-stroke);
  background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(255,255,255,0.62));
  backdrop-filter: blur(14px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.45),
    0 10px 30px rgba(0,0,0,.15),
    0 0 0 2px rgba(0,167,77,.06);
  padding: clamp(22px, 3.4vw, 36px);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.login-card:hover {
  transform: translateY(-3px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.45),
    0 15px 35px rgba(0,0,0,.18),
    0 0 0 2px rgba(0,167,77,.1);
}

.login-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: var(--border-radius);
  padding: 1px;
  background: linear-gradient(135deg, rgba(0,167,77,.55), rgba(0,200,83,.55), rgba(0,167,77,.2));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: .35;
  pointer-events: none;
  transition: opacity var(--transition-speed) ease;
}

.login-card:hover::before {
  opacity: .5;
}

.login-card h2 {
  font-family: Orbitron, Inter, sans-serif;
  margin: 0 0 18px;
  font-size: clamp(22px, 2.2vw, 28px);
  letter-spacing: .22em;
  color: var(--brand);
  text-align: center;
  text-shadow: 0 0 12px rgba(0,167,77,.35);
  transition: text-shadow var(--transition-speed) ease;
}

.login-card:hover h2 {
  text-shadow: 0 0 18px rgba(0,167,77,.5);
}

/* ====== Formulario - Inputs ====== */
.input-wrap {
  position: relative;
  margin-bottom: 14px;
}

.form-control {
  height: 48px;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(0,0,0,0.12);
  color: var(--ink);
  border-radius: var(--border-radius-sm);
  padding: 0 46px 0 42px;
  outline: none;
  transition: all var(--transition-speed) ease;
  width: 100%;
  font-size: 16px;
}

.form-control::placeholder {
  color: #607D8B;
  transition: opacity var(--transition-speed) ease;
}

.form-control:focus {
  border-color: rgba(0,167,77,.65);
  background: rgba(255,255,255,0.9);
  box-shadow: 0 0 0 4px rgba(0,167,77,.14), 0 0 18px rgba(0,167,77,.22);
}

.form-control:focus::placeholder {
  opacity: 0.6;
}

.input-icon, .toggle-pass {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--muted);
  opacity: .9;
  transition: color var(--transition-speed) ease, transform var(--transition-speed) ease;
}

.input-icon {
  left: 14px;
}

.toggle-pass {
  right: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle-pass:hover {
  color: var(--brand);
  transform: translateY(-50%) scale(1.1);
}

/* ====== Botón principal ====== */
.btn-primary {
  --btn-h: 48px;
  display: inline-grid;
  place-items: center;
  height: var(--btn-h);
  width: 100%;
  border: 0;
  border-radius: var(--border-radius-sm);
  font-weight: 700;
  letter-spacing: .12em;
  color: #ffffff;
  background: linear-gradient(90deg, var(--brand), var(--brand-neon));
  box-shadow: 0 10px 24px rgba(0,167,77,.25), 0 0 0 2px rgba(0,167,77,.18) inset;
  transition: all var(--transition-speed) ease;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  font-size: 16px;
  text-transform: uppercase;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0,167,77,.32), 0 0 0 2px rgba(0,167,77,.28) inset;
  filter: brightness(1.04);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,.35) 40%, transparent 60%);
  mix-blend-mode: screen;
  transform: translateX(-120%);
  transition: transform var(--transition-slow) ease;
}

.btn-primary:hover::before {
  transform: translateX(120%);
}

.btn-primary:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(0,167,77,.3), 0 10px 24px rgba(0,167,77,.25), 0 0 0 2px rgba(0,167,77,.18) inset;
}

.helper {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  transition: color var(--transition-speed) ease;
}

.helper:hover {
  color: var(--ink);
}

/* ====== Loader de autenticación ====== */
.login-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  backdrop-filter: blur(8px);
  background: radial-gradient(60% 60% at 50% 50%, rgba(0,167,77,.12), rgba(255,255,255,.65));
}

body.loading .login-loader {
  display: flex;
}

.loader-ring {
  width: clamp(120px, 16vw, 180px);
  height: clamp(120px, 16vw, 180px);
  border-radius: 50%;
  border: 3px solid rgba(0,0,0,.08);
  position: relative;
  box-shadow: 0 0 40px rgba(0,167,77,.12) inset;
}

.loader-ring::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--brand);
  border-right-color: var(--brand-neon);
  filter: drop-shadow(0 0 10px rgba(0,167,77,.8));
  animation: spin 1.1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-title {
  font-family: Orbitron, Inter, sans-serif;
  margin-top: 16px;
  letter-spacing: .18em;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink);
}

.loader-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.progress-line {
  width: min(360px, 80vw);
  height: 6px;
  border-radius: 999px;
  background: rgba(0,0,0,.08);
  margin-top: 18px;
  overflow: hidden;
  position: relative;
}

.progress-line::before {
  content: "";
  position: absolute;
  left: -40%;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-neon));
  animation: slide 1.2s ease-in-out infinite;
  border-radius: 999px;
}

@keyframes slide {
  0% { left: -45%; width: 35%; }
  50% { left: 35%; width: 45%; }
  100% { left: 105%; width: 30%; }
}

/* ====== Mejoras de accesibilidad ====== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .bg-blobs::before,
  .bg-blobs::after {
    animation: none;
  }
  
  .holo-grid {
    animation: none;
  }
}

/* ====== Diseño responsivo ====== */
@media (max-width: 992px) {
  .login-container {
    grid-template-columns: 1fr;
    gap: 16px;
    width: 94vw;
  }
  
  .left-panel {
    order: -1;
    min-height: 220px;
  }
  
  .brand-logos {
    height: clamp(150px, 40vw, 220px);
  }
}

@media (max-width: 576px) {
  .brand {
    font-size: 24px;
  }
  
  .brand-sub {
    font-size: 11px;
  }
  
  .login-card {
    padding: 18px;
  }
  
  .form-control {
    height: 44px;
    padding: 0 42px 0 38px;
  }
  
  .btn-primary {
    --btn-h: 44px;
  }
}

/* ====== Utilidades adicionales ====== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.fade-in {
  animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}