/* ── Fondo animado ── */
html, body {
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: var(--font-main);
}

body {
    background: linear-gradient(135deg, #0a1628 0%, #001a3a 30%, #004a99 70%, #0066cc 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Elementos decorativos — solo visuales, no aportan info */
body::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99,179,237,0.15) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    animation: float 8s ease-in-out infinite;
    pointer-events: none;
}

body::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0,74,153,0.2) 0%, transparent 70%);
    bottom: -150px;
    left: -150px;
    animation: float 10s ease-in-out infinite reverse;
    pointer-events: none;
}

@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes float {
    0%, 100% { transform: translate(0,0) scale(1); }
    50%       { transform: translate(20px,-30px) scale(1.05); }
}

/* ── Skip link de accesibilidad ── */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    background: var(--brand);
    color: white;
    padding: 10px 18px;
    border-radius: 0 0 var(--radius) var(--radius);
    font-weight: 700;
    font-size: 14px;
    z-index: 9999;
    text-decoration: none;
    transition: top 0.2s;
}
.skip-link:focus { top: 0; outline: 3px solid var(--brand-accent); outline-offset: 2px; }

/* ── Contenedor ── */
.login-container {
    width: 100%;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* ── Tarjeta glassmorphism ── */
.login-box {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 48px 40px;
    border-radius: var(--radius-xl);
    box-shadow:
        0 25px 60px rgba(0,0,0,0.3),
        0 0 0 1px rgba(255,255,255,0.1),
        inset 0 1px 0 rgba(255,255,255,0.2);
    width: 100%;
    max-width: 420px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.18);
    animation: scaleIn 0.6s var(--transition-spring);
    position: relative;
    overflow: hidden;
}

/* Línea decorativa superior */
.login-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--brand), var(--brand-accent), var(--brand));
    background-size: 200% 100%;
    animation: shimmer 3s infinite;
}

/* ── Logo ── */
.logo-img {
    max-width: 160px;
    height: auto;
    margin-bottom: 20px;
    filter: drop-shadow(0 4px 8px rgba(0,74,153,0.15));
    transition: transform var(--transition-base);
}
.logo-img:hover { transform: scale(1.05); }

/* ── Títulos ── */
.login-box h1 {
    color: var(--brand);
    margin-bottom: 6px;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.login-box .subtitle {
    color: var(--text-muted);
    margin-bottom: 36px;
    font-size: 15px;
    font-weight: 500;
}

/* ── Grupos de formulario ── */
.form-group {
    text-align: left;
    margin-bottom: 20px;
    position: relative;
}
.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group label i { color: var(--brand); font-size: 14px; }

.input-wrapper { position: relative; }
.input-wrapper .field-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 15px;
    transition: color var(--transition-fast);
    pointer-events: none; /* no interfiere con clics en el input */
}
.input-wrapper:focus-within .field-icon { color: var(--brand); }

.form-group input {
    width: 100%;
    padding: 14px 14px 14px 42px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    transition: all var(--transition-base);
    background: var(--white);
}
.form-group input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(0,74,153,0.1);
    outline: none;
}
/* FIX ACCESIBILIDAD: outline visible cuando no hay box-shadow (ej. forced-colors) */
@media (forced-colors: active) {
    .form-group input:focus { outline: 3px solid ButtonText; }
}

/* ── Botón principal ── */
.btn-login {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--brand) 0%, #0066cc 100%);
    color: white;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,74,153,0.35);
    margin-top: 10px;
    border: none;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-login::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s;
}
.btn-login:hover  { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,74,153,0.45); }
.btn-login:hover::before { left: 100%; }
.btn-login:active { transform: translateY(0) scale(0.98); }
.btn-login:disabled {
    background: linear-gradient(135deg, #a0aec0, #cbd5e0);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}
.btn-login:disabled::before { display: none; }

/* Spinner dentro del botón */
.btn-login .spinner {
    display: none;
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
.btn-login.loading .spinner    { display: inline-block; }
.btn-login.loading .btn-label  { display: none; }

/* ── Mensaje de error ── */
#error-msg {
    background: linear-gradient(135deg, var(--danger-bg), #fff5f5);
    color: var(--danger-text);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-top: 20px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--danger);
    border-left: 4px solid var(--danger);
    text-align: left;
    display: none; /* valor base */
    align-items: center;
    gap: 10px;
}
/* Clase .visible activa el display */
#error-msg.visible {
    display: flex;
    animation: shake 0.5s ease;
}
#error-msg i { font-size: 16px; flex-shrink: 0; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-8px); }
    40%       { transform: translateX(8px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

/* ── Footer de versión ── */
.login-footer {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: #767676;
}
.login-footer .version {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 600;
}
.login-footer .version i { color: var(--success); font-size: 8px; }

/* ── Responsive ── */
@media (max-width: 30em) {
    .login-box { padding: 36px 24px; border-radius: var(--radius-lg); }
    .login-box h1 { font-size: 22px; }
    body::before, body::after { display: none; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}