/* --- Variables de Color --- */
:root {
    --bg-main: #02040a; 
    --panel-dark: #000000;
    --neon-cyan: #00eaff;
    --neon-blue: #0066ff;
    --text-bright: #ffffff;
    --text-dim: #a0b0c0;
    --input-bg: rgba(0, 234, 255, 0.05);
}

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Rajdhani:wght@400;600&display=swap');

/* --- Reset y Body --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Rajdhani', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-bright);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ========================================== */
/* FONDO OPTIMIZADO - SIN LAG */
/* ========================================== */
.cyber-grid-bg {
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background-color: var(--bg-main);
    z-index: -1;
    
    /* OPTIMIZACIÓN CLAVE: Usa GPU para todo */
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Capa 1: Rejilla estática (sin animación en esta) */
.cyber-grid-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(0, 234, 255, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 234, 255, 0.08) 1px, transparent 1px);
    background-size: 50px 50px;
    /* OPTIMIZACIÓN: GPU rendering */
    transform: translateZ(0);
}

/* Capa 2: Estrellas sutiles con animación MUY lenta */
.cyber-grid-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(0, 234, 255, 0.15) 1px, transparent 1px),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.2) 1px, transparent 1px),
        radial-gradient(circle at 50% 50%, rgba(0, 102, 255, 0.1) 1px, transparent 1px);
    background-size: 300px 300px;
    /* Animación MUY lenta y sutil */
    animation: gentleGlow 15s ease-in-out infinite;
    /* OPTIMIZACIÓN: GPU rendering */
    will-change: opacity;
    transform: translateZ(0);
}

/* Animación ultra suave solo de opacidad (más eficiente) */
@keyframes gentleGlow {
    0%, 100% { 
        opacity: 0.3; 
    }
    50% { 
        opacity: 0.5; 
    }
}

/* --- Contenedor Principal --- */
.login-container {
    display: flex;
    width: 1100px;
    max-width: 95%;
    background-color: var(--panel-dark);
    border-radius: 20px;
    border: 2px solid var(--neon-blue);
    box-shadow: 
        0 0 30px rgba(0, 102, 255, 0.5),
        inset 0 0 50px rgba(0, 102, 255, 0.1);
    overflow: hidden;
    min-height: 600px;
    /* OPTIMIZACIÓN: Aislamiento de rendering */
    transform: translateZ(0);
    will-change: auto;
}

/* ============================================ */
/* PANEL IZQUIERDO - LOGO (login-image-panel) */
/* ============================================ */
.login-image-panel {
    flex: 1;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px 40px;
    border-right: 2px solid rgba(0, 234, 255, 0.15);
    position: relative;
    overflow: hidden;
}

/* Efecto de resplandor estático detrás del logo */
.login-image-panel::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(0, 102, 255, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 0;
    /* Sin animación para mejor performance */
}

/* IMAGEN ESTÁTICA (SIN MOVIMIENTO) */
.logo-img {
    width: 100%;
    max-width: 450px;
    height: auto;
    object-fit: contain;
    position: relative;
    z-index: 1;
    
    /* OPTIMIZACIÓN para imágenes */
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Láser de Escaneo (Efecto Cyberpunk) - OPCIONAL */
.scanner-line {
    position: absolute;
    top: -10%;
    left: 0;
    width: 100%;
    height: 20px;
    
    background: linear-gradient(
        to right, 
        transparent 0%, 
        rgba(0, 234, 255, 0.1) 20%,
        rgba(0, 234, 255, 0.8) 50%,
        rgba(0, 234, 255, 0.1) 80%, 
        transparent 100%
    );
    
    box-shadow: 0 10px 20px rgba(0, 234, 255, 0.3);
    opacity: 0.7;
    z-index: 5;
    pointer-events: none;
    
    /* Animación más lenta */
    animation: escanear 6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    /* OPTIMIZACIÓN */
    will-change: top, opacity;
    transform: translateZ(0);
}

@keyframes escanear {
    0% { top: -10%; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 110%; opacity: 0; }
}

/* ================================================= */
/* PANEL DERECHO - FORMULARIO (login-form-panel) */
/* ================================================= */
.login-form-panel {
    flex: 1;
    padding: 60px 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: linear-gradient(180deg, rgba(5, 10, 25, 0.95), rgba(0, 0, 0, 1));
}

/* ================================================= */
/* ESTILOS COMUNES PARA AMBOS FORMULARIOS */
/* ================================================= */
#loginForm, #registroForm {
    width: 100%;
}

#loginForm h2, #registroForm h2 {
    font-family: 'Orbitron', sans-serif;
    color: var(--text-bright);
    margin-bottom: 10px;
    font-size: 2rem;
    letter-spacing: 3px;
    text-align: left;
    text-transform: uppercase;
}

.sub-title {
    display: block;
    color: var(--text-dim);
    margin-bottom: 40px;
    font-size: 0.95rem;
    text-align: left;
}

/* --- Grupos de Input --- */
.input-group {
    margin-bottom: 25px;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    color: var(--neon-cyan);
    font-size: 0.85rem;
    letter-spacing: 1.5px;
    font-weight: 600;
    text-transform: uppercase;
}

.input-field {
    display: flex;
    align-items: center;
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 14px 18px;
    transition: all 0.3s ease;
}

.input-field:focus-within {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 20px rgba(0, 234, 255, 0.3);
    background-color: rgba(0, 234, 255, 0.03);
}

.input-field i {
    color: var(--text-dim);
    margin-right: 15px;
    font-size: 1.1rem;
}

.input-field input {
    border: none;
    background: none;
    outline: none;
    color: #fff;
    flex: 1;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.1rem;
}

.input-field input::placeholder {
    color: rgba(160, 176, 192, 0.5);
}

/* --- Grupo Captcha --- */
.captcha-group {
    display: flex;
    align-items: center;
    margin-bottom: 35px;
    gap: 15px;
}

.captcha-code-box {
    background: #000;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    padding: 14px 20px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1.3rem;
    letter-spacing: 4px;
    box-shadow: 0 0 15px rgba(0, 234, 255, 0.3);
    border-radius: 6px;
    min-width: 100px;
    text-align: center;
}

.captcha-input {
    flex: 1;
}

/* --- Botón de Login --- */
.btn-login {
    width: 100%;
    padding: 16px;
    background: var(--neon-cyan);
    border: none;
    border-radius: 8px;
    color: #000;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.15rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 0 25px rgba(0, 234, 255, 0.6);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn-login:hover {
    background: #fff;
    box-shadow: 0 0 40px rgba(0, 234, 255, 0.9);
    transform: translateY(-2px);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login i {
    margin-right: 10px;
}

/* --- Footer del Formulario --- */
.form-footer {
    margin-top: 30px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.form-footer a {
    color: var(--neon-cyan);
    text-decoration: none;
    transition: color 0.3s ease;
}

.form-footer a:hover {
    color: #fff;
    text-shadow: 0 0 10px var(--neon-cyan);
}

.form-footer p {
    margin-top: 10px;
}

/* ================================ */
/* --- RESPONSIVE DESIGN --- */
/* ================================ */
@media (max-width: 900px) {
    body {
        padding: 20px 0;
    }
    
    .login-container {
        flex-direction: column;
        width: 95%;
        max-width: 450px;
        margin: 20px auto;
    }
    
    .login-image-panel {
        min-height: 280px;
        border-right: none;
        border-bottom: 2px solid rgba(0, 234, 255, 0.3);
        padding: 40px 30px;
    }
    
    .login-image-panel::before {
        width: 300px;
        height: 300px;
    }
    
    .logo-img {
        max-width: 280px;
    }
    
    .login-form-panel {
        padding: 40px 30px;
    }
    
    #loginForm h2, #registroForm h2 {
        font-size: 1.7rem;
        text-align: center;
    }
    
    .sub-title {
        text-align: center;
        font-size: 0.9rem;
    }
    
    .input-group label {
        font-size: 0.8rem;
    }
    
    .input-field {
        padding: 12px 15px;
    }
    
    .input-field input {
        font-size: 1rem;
    }
    
    .captcha-group {
        flex-direction: row;
        gap: 10px;
    }
    
    .captcha-code-box {
        min-width: 90px;
        padding: 12px 15px;
        font-size: 1.2rem;
    }
    
    .btn-login {
        font-size: 1rem;
        padding: 14px;
    }
    
    .form-footer {
        font-size: 0.85rem;
    }
}

@media (max-width: 500px) {
    .login-container {
        width: 90%;
        margin: 10px auto;
    }
    
    .login-image-panel {
        min-height: 240px;
        padding: 30px 20px;
    }
    
    .login-form-panel {
        padding: 35px 25px;
    }
    
    #loginForm h2, #registroForm h2 {
        font-size: 1.5rem;
        letter-spacing: 2px;
    }
    
    .sub-title {
        font-size: 0.85rem;
        margin-bottom: 30px;
    }
    
    .input-group {
        margin-bottom: 20px;
    }
    
    .input-field i {
        font-size: 1rem;
        margin-right: 12px;
    }
    
    .captcha-code-box {
        min-width: 80px;
        padding: 10px 12px;
        font-size: 1.1rem;
        letter-spacing: 3px;
    }
    
    .btn-login {
        font-size: 0.95rem;
        padding: 13px;
        letter-spacing: 1.5px;
    }
    
    .form-footer {
        margin-top: 25px;
        font-size: 0.8rem;
    }
}

/* --- Ajustes específicos para pantallas medianas/bajas --- */
@media (max-height: 800px) {
    .login-container {
        overflow-y: auto; 
        max-height: 90vh;
    }
}

/* ============================================== */
/* OPTIMIZACIONES MÁXIMAS PARA ELIMINAR LAG */
/* ============================================== */

/* Desactiva animaciones pesadas en equipos de bajo rendimiento */
@media (prefers-reduced-motion: reduce) {
    .cyber-grid-bg::after {
        animation: none;
        opacity: 0.4;
    }
    
    .scanner-line {
        animation: none;
        display: none;
    }
}

/* En pantallas grandes, reduce aún más las animaciones */
@media (min-width: 1200px) {
    .cyber-grid-bg::after {
        animation-duration: 20s;
    }
}

/* --- ESTILOS DEL CAPTCHA DINÁMICO --- */

.captcha-img-container {
    background: #000;
    border: 1px solid var(--neon-cyan); /* Borde neón */
    border-radius: 6px;
    padding: 0;
    cursor: pointer; /* Manito al pasar el mouse */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-width: 120px; /* Ancho mínimo para que se vea */
    height: 52px; /* Altura igual a los inputs */
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 234, 255, 0.1);
}

.captcha-img-container:hover {
    box-shadow: 0 0 15px rgba(0, 234, 255, 0.4); /* Brillo al pasar el mouse */
    border-color: #fff;
}

.captcha-img-container img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Ajusta la imagen SVG dentro */
}

/* Ajuste para que el input de al lado se vea bien */
.captcha-group {
    gap: 10px; /* Espacio entre la imagen y el input */
}

/* =========================================
   CORRECCIÓN RESPONSIVE PARA CAPTCHA (V2 - IMAGEN GRANDE)
   ========================================= */
@media screen and (max-width: 768px) {
    
    /* 1. Estructura vertical (Input abajo de imagen) */
    .captcha-group {
        display: flex;
        flex-direction: column; 
        align-items: center;
        gap: 15px;
        margin-bottom: 25px; /* Un poco más de espacio abajo */
    }

    /* 2. El contenedor de la imagen ahora ocupa todo el ancho */
    .captcha-img-container {
        display: flex;
        justify-content: center;
        align-items: center;
        background: rgba(0, 0, 0, 0.2); 
        padding: 8px; /* Padding pequeño para no desperdiciar espacio */
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        
        /* Aseguramos una altura mínima para que se vea imponente */
        min-height: 80px; 
    }

    /* 3. ¡AQUÍ ESTÁ EL CAMBIO IMPORTANTE PARA LA IMAGEN! */
    #captcha-img {
        width: 100%;       /* Ocupa todo el ancho del contenedor */
        height: auto;      /* La altura crece automáticamente */
        min-height: 60px;  /* Evita que se vea muy delgada */
        max-height: 120px; /* (Opcional) Limite para que no sea gigante en tablets */
        object-fit: contain; /* Clave: Agranda sin cortar nada de la imagen */
        display: block;    /* Quita espacios extraños debajo de la imagen */
    }

    /* 4. Input ocupando todo el ancho (esto ya estaba bien) */
    .captcha-input {
        width: 100% !important;
        margin: 0 !important;
    }

    .captcha-input input {
        text-align: center;
        width: 100%;
    }
}

/* =========================================
   BARRA DE SEGURIDAD DE CONTRASEÑA
   ========================================= */
.strength-container {
    margin-bottom: 15px;
}

.strength-bar-bg {
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

.strength-bar-fill {
    height: 100%;
    width: 0%;
    background: #ff4444; /* Rojo por defecto */
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
}

.strength-text {
    display: block;
    font-size: 0.8rem;
    margin-top: 5px;
    text-align: right;
    color: #888;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Niveles de Seguridad */
.strength-weak { 
    background: #ff4444 !important; /* Rojo */
    box-shadow: 0 0 10px #ff4444 !important;
}
.strength-medium { 
    background: #ffbb33 !important; /* Amarillo */
    box-shadow: 0 0 10px #ffbb33 !important;
}
.strength-strong { 
    background: #00C851 !important; /* Verde */
    box-shadow: 0 0 10px #00C851 !important;
}

/* =========================================
   ANIMACIÓN DE IMAGEN FLOTANTE (LOGIN/REGISTRO)
   ========================================= */

/* 1. Definimos los pasos de la animación */
@keyframes cyber-float-glow {
    0% {
        /* Posición inicial (abajo) */
        transform: translateY(0px);
        /* Sombra azul neón pegada a la imagen */
        filter: drop-shadow(0 5px 10px rgba(0, 234, 255, 0.5));
    }
    50% {
        /* Punto más alto (sube 20 pixeles) */
        transform: translateY(-20px);
        /* La sombra se aleja, se agranda y se vuelve más difusa */
        filter: drop-shadow(0 25px 25px rgba(0, 234, 255, 0.3));
    }
    100% {
        /* Vuelve a la posición inicial */
        transform: translateY(0px);
        filter: drop-shadow(0 5px 10px rgba(0, 234, 255, 0.5));
    }
}

/* 2. Aplicamos la animación a la imagen */
/* Usamos .login-image-panel img para asegurar que le afecte */
.login-image-panel img {
    /* Esto ayuda al navegador a optimizar el movimiento */
    will-change: transform;
    
    /* APLICAR LA ANIMACIÓN:
       - Nombre: cyber-float-glow
       - Duración: 4 segundos (para que sea lento y suave)
       - Efecto: ease-in-out (acelera y frena suavemente)
       - Repetición: infinite (nunca se detiene)
    */
    animation: cyber-float-glow 4s ease-in-out infinite;
    
    /* Aseguramos que la imagen no se salga de su contenedor al moverse */
    max-height: 90%; /* Un poco menos del 100% para dar espacio al movimiento */
    width: auto;
    object-fit: contain;
}