/* ==========================================================================
   KL Security — Login page
   Scoped under .kl-login-page so nothing here leaks into the rest of the app.
   ========================================================================== */

.kl-login-page {
    --kl-navy: #172039;
    --kl-navy-2: #212b4d;
    --kl-accent: #9bc336;
    --kl-accent-2: #7ca62b;
    --kl-text-muted: #8a90a6;

    position: relative;
    min-height: 100vh;
    width: 100%;
    display: flex;
    background: var(--kl-navy);
    overflow-x: hidden;
}

/* ---------- Full-bleed background photo ---------- */

.kl-bg-photo {
    position: fixed;
    inset: -20px;
    z-index: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(5px) brightness(.85) saturate(1.05);
    transform: scale(1.04);
}

.kl-bg-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: linear-gradient(155deg, rgba(23, 32, 57, .55) 0%, rgba(33, 43, 77, .42) 55%, rgba(78, 98, 27, .48) 100%);
}

.kl-blob {
    position: fixed;
    z-index: 1;
    border-radius: 50%;
    filter: blur(60px);
    opacity: .5;
    mix-blend-mode: screen;
    pointer-events: none;
    animation: kl-drift 16s ease-in-out infinite;
}

.kl-blob--1 {
    width: 380px;
    height: 380px;
    top: -80px;
    left: -100px;
    background: radial-gradient(circle at 30% 30%, var(--kl-accent), transparent 70%);
    animation-duration: 18s;
}

.kl-blob--2 {
    width: 320px;
    height: 320px;
    bottom: -100px;
    right: -80px;
    background: radial-gradient(circle at 60% 40%, var(--kl-accent-2), transparent 70%);
    animation-duration: 22s;
    animation-delay: -6s;
}

.kl-blob--3 {
    width: 220px;
    height: 220px;
    bottom: 20%;
    left: 8%;
    background: radial-gradient(circle at 50% 50%, #ffffff, transparent 70%);
    opacity: .1;
    animation-duration: 14s;
    animation-delay: -3s;
}

@keyframes kl-drift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(30px, -24px) scale(1.08); }
}

@keyframes kl-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
}

/* ---------- Intro splash (welcome page only) ---------- */

.kl-splash {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #fff;
    animation: kl-splash-out .6s ease-in 1.3s forwards;
}

/* Difuminado verde de fondo, en vez de recolorear el logo (que se queda
   navy, igual que en el resto de la app). */
.kl-splash::before,
.kl-splash::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    pointer-events: none;
}

.kl-splash::before {
    width: 480px;
    height: 480px;
    top: -120px;
    left: -140px;
    background: radial-gradient(circle, var(--kl-accent), transparent 70%);
    opacity: .5;
}

.kl-splash::after {
    width: 420px;
    height: 420px;
    bottom: -140px;
    right: -120px;
    background: radial-gradient(circle, var(--kl-accent-2), transparent 70%);
    opacity: .45;
}

.kl-splash__logo {
    position: relative;
    z-index: 1;
    width: 140px;
    height: 140px;
    object-fit: contain;
    opacity: 0;
    filter: drop-shadow(0 6px 16px rgba(23, 32, 57, .18));
    animation:
        kl-splash-logo-in .6s ease-out forwards,
        kl-splash-logo-zoom .6s cubic-bezier(.5, 0, 1, 1) 1.25s forwards;
}

@keyframes kl-splash-logo-in {
    from { opacity: 0; transform: scale(.7); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes kl-splash-logo-zoom {
    to { opacity: 0; transform: scale(7); }
}

@keyframes kl-splash-out {
    to { opacity: 0; visibility: hidden; pointer-events: none; }
}

/* ---------- Centered card wrapper ---------- */

.kl-login-form {
    position: relative;
    z-index: 2;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.25rem;
}

.kl-login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 26px;
    padding: 2.75rem 2.25rem;
    box-shadow: 0 30px 70px -18px rgba(8, 10, 30, .55);
}

.kl-login-card--welcome {
    text-align: center;
}

.kl-card-logo {
    width: 100px;
    height: 100px;
    margin: 0 auto 1.5rem;
    animation: kl-float 5s ease-in-out infinite;
}

.kl-card-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 18px rgba(23, 32, 57, .25));
}

.kl-fade-in {
    opacity: 0;
    transform: translateY(16px);
    animation: kl-fade-up .55s ease-out forwards;
}

.kl-fade-in--1 { animation-delay: .05s; }
.kl-fade-in--2 { animation-delay: .15s; }
.kl-fade-in--3 { animation-delay: .25s; }
.kl-fade-in--4 { animation-delay: .35s; }

@keyframes kl-fade-up {
    to { opacity: 1; transform: translateY(0); }
}

.kl-login-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: 2rem;
}

.kl-login-brand img {
    height: 46px;
    width: 46px;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(23, 32, 57, .12);
}

.kl-login-brand span {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--kl-navy);
}

.kl-login-brand span b {
    color: inherit;
    font-weight: 700;
}

.kl-login-card h2 {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--kl-navy);
    margin-bottom: .35rem;
}

.kl-login-card .kl-subtitle {
    color: var(--kl-text-muted);
    font-size: .92rem;
    margin-bottom: 1.75rem;
}

/* Floating-label fields */

.kl-field {
    position: relative;
    margin-bottom: 1.35rem;
}

.kl-field__icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--kl-text-muted);
    font-size: .9rem;
    transition: color .2s ease;
    pointer-events: none;
}

.kl-input {
    width: 100%;
    height: 54px;
    padding: 1.1rem 1rem .35rem 2.6rem;
    border: 1.5px solid #e6e8f0;
    border-radius: 12px;
    background: #fafbfe;
    font-size: .95rem;
    color: var(--kl-navy);
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.kl-input::placeholder {
    color: transparent;
}

.kl-input:focus {
    outline: none;
    border-color: var(--kl-accent-2);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(124, 166, 43, .18);
}

.kl-input:focus ~ .kl-field__icon {
    color: var(--kl-accent-2);
}

.kl-field label {
    position: absolute;
    left: 2.6rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: .95rem;
    color: var(--kl-text-muted);
    background: transparent;
    padding: 0 .2rem;
    margin: 0;
    pointer-events: none;
    transition: all .18s ease;
}

.kl-input:focus + label,
.kl-input:not(:placeholder-shown) + label {
    top: 0;
    left: 2.3rem;
    font-size: .72rem;
    font-weight: 600;
    color: var(--kl-accent-2);
    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    padding: 0 .4rem;
    border-radius: 4px;
}

.kl-input.is-invalid:focus + label,
.kl-input.is-invalid:not(:placeholder-shown) + label {
    color: #e2554f;
    background: rgba(255, 246, 246, .82);
}

.kl-input.is-invalid {
    border-color: #e2554f;
    background: #fff6f6;
}

.kl-input.is-invalid ~ .kl-field__icon {
    color: #e2554f;
}

.kl-field__error {
    display: block;
    margin-top: .4rem;
    font-size: .78rem;
    color: #e2554f;
}

.kl-toggle-pass {
    position: absolute;
    right: .9rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--kl-text-muted);
    font-size: .9rem;
    cursor: pointer;
    padding: .3rem;
    line-height: 1;
    transition: color .2s ease;
}

.kl-toggle-pass:hover {
    color: var(--kl-navy);
}

.kl-toggle-pass:focus {
    outline: none;
}

/* Remember / forgot row */

.kl-field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.kl-switch {
    display: flex;
    align-items: center;
    gap: .55rem;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.kl-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.kl-switch .track {
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: #e2e5ef;
    transition: background .2s ease;
    flex: none;
}

.kl-switch .track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .2s ease;
}

.kl-switch input:checked + .track {
    background: linear-gradient(135deg, var(--kl-accent-2), var(--kl-accent));
}

.kl-switch input:checked + .track::after {
    transform: translateX(16px);
}

.kl-switch span.label-text {
    font-size: .85rem;
    color: var(--kl-navy);
}

.kl-forgot {
    font-size: .85rem;
    font-weight: 600;
    color: var(--kl-accent-2);
    text-decoration: none;
}

.kl-forgot:hover {
    color: var(--kl-accent);
    text-decoration: underline;
}

/* Submit button */

.kl-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 52px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--kl-navy) 0%, var(--kl-navy-2) 65%, var(--kl-accent) 220%);
    background-size: 160% 160%;
    background-position: 0% 50%;
    color: #fff;
    font-weight: 600;
    font-size: .98rem;
    letter-spacing: .01em;
    text-decoration: none;
    cursor: pointer;
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease, background-position .4s ease;
    box-shadow: 0 10px 22px -8px rgba(23, 32, 57, .55);
}

.kl-btn:hover {
    transform: translateY(-2px);
    background-position: 100% 50%;
    box-shadow: 0 14px 26px -8px rgba(23, 32, 57, .5);
    color: #fff;
}

.kl-btn:active {
    transform: translateY(0);
}

.kl-btn:disabled {
    cursor: progress;
    opacity: .85;
    transform: none;
}

.kl-btn .spinner {
    display: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    animation: kl-spin .7s linear infinite;
    margin-right: .55rem;
    vertical-align: -3px;
}

.kl-btn.is-loading .spinner {
    display: inline-block;
}

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

.kl-login-footer {
    text-align: center;
    margin-top: 1.75rem;
    font-size: .85rem;
    color: var(--kl-text-muted);
}

/* Flash messages */

.kl-login-page .alert {
    border: none;
    border-radius: 10px;
    font-size: .85rem;
    padding: .7rem 1rem;
    margin-bottom: 1.25rem;
}

.kl-login-page .invalid-feedback.error {
    display: block;
}

@media (max-width: 480px) {
    .kl-login-card {
        padding: 2.25rem 1.5rem;
        border-radius: 20px;
    }
}
