/* ============================================
   SGTI - Login Screen (Diseño SaaS moderno)
   Glassmorphism · Aurora gradient · Animaciones suaves
   ============================================ */

/* Ocultar el shell de la app hasta estar autenticado */
body:not(.authenticated) .sidebar,
body:not(.authenticated) .main-content {
    display: none !important;
}

.login-screen {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow: hidden;
    background: #0a0f1e;
}

/* ---------- Fondo animado ---------- */
.login-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% -10%, rgba(46, 134, 171, 0.35), transparent 60%),
        radial-gradient(ellipse 70% 55% at 85% 110%, rgba(46, 196, 182, 0.22), transparent 60%),
        linear-gradient(160deg, #0a0f1e 0%, #0f1b33 45%, #0a1628 100%);
}

.aurora {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.5;
    will-change: transform;
}

.aurora-1 {
    width: 480px;
    height: 480px;
    background: linear-gradient(135deg, #2e86ab, #1b4965);
    top: -140px;
    left: -120px;
    animation: drift1 18s ease-in-out infinite alternate;
}

.aurora-2 {
    width: 420px;
    height: 420px;
    background: linear-gradient(135deg, #2ec4b6, #0f7b6c);
    bottom: -160px;
    right: -100px;
    animation: drift2 22s ease-in-out infinite alternate;
}

.aurora-3 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #5f6df3, #2e86ab);
    top: 40%;
    left: 55%;
    opacity: 0.28;
    animation: drift3 26s ease-in-out infinite alternate;
}

@keyframes drift1 {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(90px, 60px) scale(1.15); }
}

@keyframes drift2 {
    0%   { transform: translate(0, 0) scale(1.1); }
    100% { transform: translate(-80px, -70px) scale(0.95); }
}

@keyframes drift3 {
    0%   { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-60px, 50px) rotate(40deg); }
}

.login-grid-overlay {
    position: absolute;
    inset: 0;
    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: 44px 44px;
    mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black, transparent 75%);
}

/* ---------- Tarjeta glassmorphism ---------- */
.login-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 0 20px;
    padding: 44px 40px 36px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: cardIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(28px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card.shake {
    animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-7px); }
    40%, 60% { transform: translateX(7px); }
}

/* ---------- Marca ---------- */
.login-brand {
    text-align: center;
    margin-bottom: 34px;
}

.login-logo {
    width: 68px;
    height: 68px;
    margin: 0 auto 18px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: #fff;
    background: linear-gradient(135deg, #2e86ab 0%, #2ec4b6 100%);
    box-shadow:
        0 12px 28px rgba(46, 134, 171, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    animation: logoFloat 5s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

.login-title {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    background: linear-gradient(90deg, #ffffff 0%, #9fd8e8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    margin: 8px 0 0;
    font-size: 0.86rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.02em;
}

/* ---------- Inputs flotantes ---------- */
.float-field {
    position: relative;
    margin-bottom: 18px;
}

.float-field .field-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.25s ease;
    pointer-events: none;
    z-index: 2;
}

.float-field input {
    width: 100%;
    padding: 24px 44px 8px 44px;
    height: 58px;
    font-size: 0.95rem;
    font-family: inherit;
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    outline: none;
    transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
    box-sizing: border-box;
}

.float-field input:focus {
    border-color: rgba(46, 196, 182, 0.65);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 4px rgba(46, 196, 182, 0.12);
}

.float-field input:focus ~ .field-icon,
.float-field input:not(:placeholder-shown) ~ .field-icon {
    color: #2ec4b6;
}

.float-field label {
    position: absolute;
    left: 44px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.42);
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.float-field input:focus ~ label,
.float-field input:not(:placeholder-shown) ~ label {
    top: 14px;
    transform: none;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #2ec4b6;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.95rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: color 0.2s ease, background 0.2s ease;
    z-index: 2;
}

.toggle-password:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

/* ---------- Error ---------- */
.login-error {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 16px;
    padding: 11px 14px;
    font-size: 0.85rem;
    color: #ffb4b4;
    background: rgba(230, 57, 70, 0.14);
    border: 1px solid rgba(230, 57, 70, 0.35);
    border-radius: 12px;
    animation: errorIn 0.3s ease both;
}

@keyframes errorIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Botón con estados ---------- */
.login-button {
    position: relative;
    width: 100%;
    height: 54px;
    margin-top: 8px;
    border: none;
    border-radius: 14px;
    font-size: 0.98rem;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0.03em;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #2e86ab 0%, #2ec4b6 100%);
    background-size: 160% 160%;
    box-shadow: 0 10px 28px rgba(46, 134, 171, 0.4);
    transition: transform 0.2s ease, box-shadow 0.25s ease, background-position 0.4s ease;
    overflow: hidden;
}

.login-button:hover:not(:disabled) {
    transform: translateY(-2px);
    background-position: 100% 100%;
    box-shadow: 0 14px 34px rgba(46, 196, 182, 0.45);
}

.login-button:active:not(:disabled) {
    transform: translateY(0);
}

.login-button:disabled {
    cursor: not-allowed;
    opacity: 0.9;
}

.login-button .btn-arrow {
    font-size: 0.9rem;
    transition: transform 0.25s ease;
}

.login-button:hover:not(:disabled) .btn-arrow {
    transform: translateX(4px);
}

/* Spinner (oculto por defecto) */
.btn-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-check {
    display: none;
    font-size: 1.1rem;
    animation: checkPop 0.35s cubic-bezier(0.68, -0.55, 0.27, 1.55) both;
}

@keyframes checkPop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* Estado loading */
.login-button.loading span,
.login-button.loading .btn-arrow {
    display: none;
}

.login-button.loading .btn-spinner {
    display: block;
}

/* Estado success */
.login-button.success {
    background: linear-gradient(135deg, #2ec4b6 0%, #1f9d8f 100%);
    box-shadow: 0 12px 30px rgba(46, 196, 182, 0.5);
}

.login-button.success .btn-arrow {
    display: none;
}

.login-button.success .btn-check {
    display: block;
}

/* ---------- Footer ---------- */
.login-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 26px;
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.38);
    letter-spacing: 0.02em;
}

.login-footer i {
    color: rgba(46, 196, 182, 0.7);
    font-size: 0.85rem;
}

.login-copyright {
    position: relative;
    margin-top: 26px;
    font-size: 0.74rem;
    color: rgba(255, 255, 255, 0.28);
    letter-spacing: 0.05em;
    animation: cardIn 0.7s 0.15s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .login-card {
        padding: 36px 26px 30px;
        border-radius: 20px;
        margin: 0 16px;
    }

    .login-title {
        font-size: 1.7rem;
    }

    .login-logo {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
}

/* Accesibilidad: respetar usuarios con movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    .aurora, .login-logo, .login-card, .login-copyright {
        animation: none !important;
    }
}
