/* ═══════════════════════════════════════════════════════════
   RESET & VARIABLES
   ═══════════════════════════════════════════════════════════ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    /* Verde olivo institucional */
    --primary-color: #556B2F;
    --primary-dark:  #2e3a17;
    --primary-light: #6B8E23;
    --primary-glow:  #9acd32;
    --accent-color:  #8FBC8F;

    --text-color:   #e8ecdf;
    --text-light:   #a8b396;
    --text-dark:    #2b3318;

    --white:        #ffffff;
    --glass-bg:     rgba(20, 30, 12, 0.72);
    --glass-border: rgba(154, 205, 50, 0.22);

    --success-color: #4caf50;
    --error-color:   #e53935;

    --sky-top:  #050810;
    --sky-mid:  #0b1424;
    --sky-bot:  #1a2408;

    --radius-card:  24px;
    --radius-input: 14px;
}

html, body { height: 100%; }

body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    position: relative;
    color: var(--text-color);
    background:
        radial-gradient(ellipse at 50% 130%, rgba(107, 142, 35, 0.30) 0%, transparent 55%),
        linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 50%, var(--sky-bot) 100%);
    -webkit-font-smoothing: antialiased;
}

/* Canvas de fondo */
#stormCanvas, #rainCanvas {
    position: fixed; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}
#stormCanvas { z-index: 0; }
#rainCanvas  { z-index: 1; opacity: 0.35; }

/* Destello de trueno */
.thunder-flash {
    position: fixed; inset: 0; z-index: 2; pointer-events: none;
    background: radial-gradient(circle at 50% 25%,
                rgba(255,255,255,0.95) 0%,
                rgba(190,220,255,0.5) 25%,
                transparent 65%);
    opacity: 0;
    mix-blend-mode: screen;
}
.thunder-flash.flash-1 { opacity: 0.9; transition: opacity 50ms; }
.thunder-flash.flash-2 { opacity: 0.35; transition: opacity 90ms; }
.thunder-flash.flash-3 { opacity: 0.15; transition: opacity 140ms; }

/* Viñeta */
.vignette {
    position: fixed; inset: 0; z-index: 3; pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.75) 100%);
}

/* ═══════════════════════════════════════════════════════════
   CONTENEDOR
   ═══════════════════════════════════════════════════════════ */
.container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 940px;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1400px;
}

/* ═══════════════════════════════════════════════════════════
   CARD · Glassmorphism + Tilt 3D
   ═══════════════════════════════════════════════════════════ */
.login-card {
    position: relative;
    display: flex;
    width: 100%;
    max-width: 880px;
    min-height: 560px;
    border-radius: var(--radius-card);
    overflow: hidden;
    background: var(--glass-bg);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    border: 1px solid var(--glass-border);
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.65),
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 0 60px rgba(154, 205, 50, 0.10);
    transform-style: preserve-3d;
    transition: transform 0.15s ease-out;
    will-change: transform;
}

/* Borde luminoso animado */
.card-glow {
    position: absolute;
    inset: -2px;
    border-radius: calc(var(--radius-card) + 2px);
    padding: 2px;
    background: conic-gradient(
        from 0deg,
        transparent 0%,
        var(--primary-glow) 10%,
        transparent 20%,
        transparent 40%,
        var(--accent-color) 50%,
        transparent 60%,
        transparent 80%,
        var(--primary-glow) 90%,
        transparent 100%
    );
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    animation: rotateGlow 6s linear infinite;
    pointer-events: none;
    opacity: 0.65;
}
@keyframes rotateGlow { to { filter: hue-rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════
   COLUMNA FORMULARIO
   ═══════════════════════════════════════════════════════════ */
.login-section {
    flex: 1 1 55%;
    padding: 44px 42px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 2;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 26px;
}
.logo-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    box-shadow:
        0 8px 20px rgba(85, 107, 47, 0.5),
        inset 0 1px 0 rgba(255,255,255,.2);
    overflow: hidden;
    transition: transform .4s cubic-bezier(.22,1,.36,1);
}
.logo:hover .logo-icon { transform: rotate(-8deg) scale(1.08); }
.logo-icon img { width: 100%; height: 100%; object-fit: cover; }

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1;
}
.logo-text span {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 1.5px;
    background: linear-gradient(90deg, var(--primary-glow), var(--accent-color));
    -webkit-background-clip: text;
            background-clip: text;
    color: transparent;
}
.logo-text small {
    font-size: 10.5px;
    letter-spacing: 3px;
    color: var(--text-light);
    margin-top: 4px;
}

/* Bienvenida */
.welcome-text { margin-bottom: 30px; }
.welcome-text h1 {
    font-size: 32px;
    font-weight: 800;
    color: var(--white);
    margin-bottom: 8px;
    text-shadow: 0 2px 20px rgba(154, 205, 50, 0.3);
}
.welcome-text p {
    color: var(--text-light);
    font-size: 14.5px;
    line-height: 1.5;
}

/* ─── Inputs ─── */
.form-group {
    position: relative;
    margin-bottom: 22px;
}
.form-group input {
    width: 100%;
    padding: 20px 52px 10px 16px;
    border: 1.5px solid rgba(154, 205, 50, 0.18);
    border-radius: var(--radius-input);
    font-size: 15px;
    color: var(--white);
    background: rgba(0, 0, 0, 0.25);
    transition: all .3s ease;
}
.form-group input::placeholder { color: transparent; }
.form-group input:focus {
    outline: none;
    border-color: var(--primary-glow);
    background: rgba(0, 0, 0, 0.4);
    box-shadow:
        0 0 0 4px rgba(154, 205, 50, 0.12),
        0 8px 24px rgba(154, 205, 50, 0.15);
}

.form-group label {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 14.5px;
    pointer-events: none;
    transition: all .25s cubic-bezier(.22,1,.36,1);
}
.form-group input:focus + label,
.form-group input:not(:placeholder-shown) + label {
    top: 12px;
    transform: translateY(0);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--primary-glow);
    text-transform: uppercase;
}

.input-icon {
    position: absolute;
    right: 48px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 15px;
    pointer-events: none;
    transition: color .25s;
    z-index: 2;   /* ← añadir esto evita que quede detrás del input */
}
.form-group input:focus ~ .input-icon { color: var(--primary-glow); }

/* Toggle password */
.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 8px;
    border-radius: 10px;
    font-size: 15px;
    transition: all .2s;
}
.toggle-password:hover,
.toggle-password:focus-visible {
    color: var(--primary-glow);
    background: rgba(154, 205, 50, 0.12);
    outline: none;
}

/* Recordar sesión */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.remember-me {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text-light);
    font-size: 13.5px;
    cursor: pointer;
    user-select: none;
    position: relative;
}
.remember-me input { position: absolute; opacity: 0; width: 0; height: 0; }
.remember-me .checkmark {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1.5px solid rgba(154, 205, 50, 0.4);
    background: rgba(0,0,0,.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .25s;
    position: relative;
}
.remember-me .checkmark::after {
    content: '✓';
    font-size: 12px;
    font-weight: 900;
    color: var(--primary-dark);
    opacity: 0;
    transform: scale(0.3);
    transition: all .2s;
}
.remember-me input:checked + .checkmark {
    background: linear-gradient(135deg, var(--primary-glow), var(--accent-color));
    border-color: var(--primary-glow);
    box-shadow: 0 0 12px rgba(154, 205, 50, 0.4);
}
.remember-me input:checked + .checkmark::after {
    opacity: 1;
    transform: scale(1);
}

/* Botón login */
.login-btn {
    position: relative;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
    border: none;
    border-radius: var(--radius-input);
    font-size: 15.5px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    overflow: hidden;
    box-shadow:
        0 10px 28px rgba(85, 107, 47, 0.55),
        inset 0 1px 0 rgba(255,255,255,.18);
    transition: transform .25s, box-shadow .25s, filter .25s;
}
.login-btn:hover {
    transform: translateY(-3px);
    box-shadow:
        0 16px 38px rgba(85, 107, 47, 0.7),
        inset 0 1px 0 rgba(255,255,255,.25);
    filter: brightness(1.08);
}
.login-btn:active { transform: translateY(-1px); }
.login-btn:focus-visible { outline: 3px solid rgba(154,205,50,.5); outline-offset: 3px; }

/* Reflejo que pasa por el botón */
.login-btn .btn-shine {
    position: absolute;
    top: 0; left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255,255,255,.35), transparent);
    transform: skewX(-20deg);
    animation: shine 3.5s ease-in-out infinite;
}
@keyframes shine {
    0%   { left: -100%; }
    55%  { left: 130%; }
    100% { left: 130%; }
}

.login-btn .btn-text { position: relative; z-index: 2; }
.login-btn .btn-loader {
    display: none;
    position: absolute;
    top: 50%; left: 50%;
    width: 20px; height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    z-index: 2;
}
.login-btn.loading .btn-text { opacity: 0; }
.login-btn.loading .btn-shine { display: none; }
.login-btn.loading .btn-loader { display: block; }
.login-btn:disabled { cursor: not-allowed; opacity: .85; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Divider y footer */
.divider {
    display: flex;
    align-items: center;
    margin: 26px 0 14px;
}
.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(154,205,50,.3), transparent);
}
.divider span {
    padding: 0 14px;
    font-size: 11px;
    font-weight: 800;
    color: var(--primary-glow);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.register-link {
    text-align: center;
    color: var(--text-light);
    font-size: 12.5px;
    line-height: 1.6;
}
.register-link a { color: var(--primary-glow); text-decoration: none; font-weight: 700; }
.register-link a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════
   COLUMNA IMAGEN
   ═══════════════════════════════════════════════════════════ */
.image-section {
    flex: 1 1 45%;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at 70% 20%, rgba(143,188,143,.30) 0%, transparent 55%),
        radial-gradient(circle at 20% 80%, rgba(154,205,50,.25) 0%, transparent 55%),
        linear-gradient(160deg, var(--primary-dark), var(--primary-color) 55%, var(--primary-light));
}
.image-section::before {
    content: '';
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
        45deg,
        rgba(255,255,255,.04) 0 2px,
        transparent 2px 16px
    );
    pointer-events: none;
}

/* Rayos rotativos del fondo */
.image-rays {
    position: absolute; inset: -50%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(255,255,255,.10) 15deg,
        transparent 30deg,
        transparent 60deg,
        rgba(255,255,255,.08) 75deg,
        transparent 90deg,
        transparent 180deg,
        rgba(255,255,255,.10) 195deg,
        transparent 210deg,
        transparent 270deg,
        rgba(255,255,255,.06) 285deg,
        transparent 300deg
    );
    animation: rotateRays 40s linear infinite;
    opacity: .55;
}
@keyframes rotateRays { to { transform: rotate(360deg); } }

.institutional-image {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    position: relative;
    z-index: 2;
}
.institution-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 20px 40px rgba(0,0,0,.5));
    animation: floatLogo 6s ease-in-out infinite;
}
@keyframes floatLogo {
    0%, 100% { transform: translateY(0) rotate(0); }
    50%      { transform: translateY(-16px) rotate(2deg); }
}

.image-placeholder {
    text-align: center;
    color: rgba(255,255,255,.95);
    padding: 8px 24px;
    position: relative;
    z-index: 2;
}
.image-placeholder p {
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: .9;
    margin-bottom: 4px;
}
.image-placeholder strong {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 1px;
    text-shadow: 0 2px 12px rgba(0,0,0,.5);
}

.image-footer {
    padding: 20px;
    text-align: center;
    position: relative;
    z-index: 2;
}
.security-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--white);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(0,0,0,.30);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,.20);
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.security-badge i { color: var(--primary-glow); }

/* ═══════════════════════════════════════════════════════════
   NOTIFICACIÓN TOAST
   ═══════════════════════════════════════════════════════════ */
.notification {
    position: fixed;
    top: 24px; right: 24px;
    max-width: 360px;
    padding: 14px 20px 14px 48px;
    border-radius: 14px;
    color: var(--white);
    font-weight: 600;
    font-size: 14px;
    background: var(--error-color);
    box-shadow: 0 16px 40px rgba(0,0,0,.5);
    transform: translateX(140%);
    transition: transform .4s cubic-bezier(.22,1,.36,1);
    z-index: 9999;
    position: fixed;
}
.notification::before {
    content: '!';
    position: absolute;
    left: 16px; top: 50%;
    transform: translateY(-50%);
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}
.notification.show { transform: translateX(0); }
.notification.success {
    background: linear-gradient(135deg, #2e7d32, var(--success-color));
}
.notification.success::before { content: '✓'; }

/* ═══════════════════════════════════════════════════════════
   SHAKE
   ═══════════════════════════════════════════════════════════ */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}
.shake { animation: shake .5s ease-in-out; }

/* ═══════════════════════════════════════════════════════════
   OVERLAY DE ÉXITO
   ═══════════════════════════════════════════════════════════ */
.alert-overlay {
    position: fixed; inset: 0;
    background: rgba(5, 10, 3, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    opacity: 0;
    animation: fadeIn .3s ease forwards;
}
@keyframes fadeIn { to { opacity: 1; } }

.success-alert {
    background: linear-gradient(160deg, #ffffff 0%, #eef4e3 100%);
    padding: 42px 36px 34px;
    border-radius: 24px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    position: relative;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,.6);
    transform: scale(.85) translateY(-40px);
    opacity: 0;
    animation: alertIn .5s cubic-bezier(.22,1,.36,1) .1s forwards;
}
@keyframes alertIn {
    to { transform: scale(1) translateY(0); opacity: 1; }
}
.success-alert::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--primary-dark), var(--primary-glow), var(--primary-dark));
    background-size: 200% 100%;
    animation: barFlow 2s linear infinite;
}
@keyframes barFlow { to { background-position: -200% 0; } }

.success-alert .alert-icon {
    width: 84px; height: 84px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 34px;
    box-shadow:
        0 15px 35px rgba(85,107,47,.5),
        0 0 0 8px rgba(154,205,50,.18);
    animation: iconPop .6s cubic-bezier(.22,1,.36,1) .3s both;
}
@keyframes iconPop {
    0%   { transform: scale(0) rotate(-180deg); }
    55%  { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0); }
}
.success-alert h3 {
    color: var(--primary-dark);
    font-size: 24px;
    font-weight: 900;
    margin-bottom: 10px;
}
.success-alert .alert-msg { color: #555; font-size: 15px; margin-bottom: 6px; }
.success-alert .alert-user {
    color: var(--primary-color);
    font-weight: 800;
    font-size: 16px;
    margin-bottom: 20px;
}
.success-alert .progress-bar {
    height: 5px;
    border-radius: 3px;
    background: #e1e5eb;
    overflow: hidden;
    margin-top: 20px;
}
.success-alert .progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-glow));
    animation: progressFill 3s linear forwards;
}
@keyframes progressFill { to { width: 100%; } }
.success-alert .redirect-hint {
    color: #999;
    font-size: 12px;
    margin-top: 10px;
    letter-spacing: .5px;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 820px) {
    .login-card {
        flex-direction: column;
        max-width: 480px;
        min-height: auto;
    }
    .image-section { display: none; }
    .login-section { padding: 36px 28px; }
    body { overflow-y: auto; padding: 16px; }
}

@media (max-width: 480px) {
    .login-section { padding: 30px 22px; }
    .welcome-text h1 { font-size: 26px; }
    .logo-text span { font-size: 16px; }
    .notification { right: 12px; left: 12px; max-width: none; }
}

/* Accesibilidad: reducir movimiento */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
    #stormCanvas, #rainCanvas { display: none; }
}