:root {
    --primary: #0d6efd;
    --primary-hover: #3b82f6;
    --dark: #0f172a;
    --glass: rgba(255, 255, 255, .12);
    --border: rgba(255, 255, 255, .25);
}

* {
    box-sizing: border-box;
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    /* Solid fallback paints immediately - no flash of white while the
       background photo is still downloading */
    background-color: var(--dark);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}


/* Background photo lives in its own layer, decoupled from first paint.
   login.js flips .is-loaded on once the image has actually downloaded,
   so the page never blocks on it. */

.bg-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(rgba(4, 18, 38, .75), rgba(4, 18, 38, .85)), url("https://sa.facilitymanagerpro.com/_global/img/lax-night-50.webp");
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity .8s ease;
}

.bg-layer.is-loaded {
    opacity: 1;
}

.login-container {
    width: 100%;
    max-width: 430px;
    padding: 20px;
}

.login-card {
    background: var(--glass);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px 35px;
    color: white;
    box-shadow: 0 25px 50px rgba(0, 0, 0, .45);
    /* Crossfade + subtle scale on load */
    opacity: 0;
    transform: scale(.96);
    animation: cardEnter .6s cubic-bezier(.22, 1, .36, 1) forwards;
}

@keyframes cardEnter {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.logo-wrap {
    text-align: center;
}

.logo {
    width: 180px;
    max-width: 80%;
    margin-bottom: 20px;
}

h1 {
    margin: 0 0 10px;
    font-size: 28px;
    text-align: center;
}

.subtitle {
    color: #d1d5db;
    margin: 0 0 30px;
    text-align: center;
}

.form-group {
    margin-bottom: 18px;
}

label {
    display: block;
    font-size: 14px;
    margin-bottom: 6px;
    color: #e5e7eb;
}

input {
    width: 100%;
    padding: 14px 15px;
    border-radius: 12px;
    border: 2px solid transparent;
    outline: none;
    font-size: 16px;
    background: white;
    color: #111827;
    transition: border-color .2s ease, box-shadow .2s ease;
}

input:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .25);
}

.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #555;
    cursor: pointer;
    opacity: 1;
    transition: opacity .3s ease;
}

.password-toggle:hover,
.password-toggle:focus-visible {
    opacity: .7;
}

.password-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.eye-icon {
    width: 24px;
    height: 24px;
}

.eye-slash {
    opacity: 0;
    transform: scale(.5) rotate(-15deg);
    transform-origin: center;
    transition: opacity .3s ease, transform .3s ease;
}


/* Password currently visible -> slash draws smoothly across the eye */

.password-toggle[aria-pressed="true"] .eye-slash {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

button.btn-submit {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    background: var(--primary);
    color: white;
    font-size: 17px;
    font-weight: 700;
    transition: background .25s ease, transform .25s ease;
}

button.btn-submit:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

button.btn-submit:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

.request-link {
    text-align: center;
    margin-top: 25px;
    font-size: 15px;
}

.request-link a {
    color: #93c5fd;
    text-decoration: none;
    font-weight: bold;
}

.alert {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 15px;
}

.alert.error {
    background: #991b1b;
}

.alert.note {
    background: #0369a1;
}

.security-note {
    margin: 25px 0 0;
    font-size: 12px;
    color: #cbd5e1;
    text-align: center;
}

@media (max-width: 480px) {
    .login-card {
        padding: 30px 20px;
    }
    h1 {
        font-size: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .login-card {
        animation: none;
        opacity: 1;
        transform: none;
    }
    .bg-layer,
    .password-toggle,
    .eye-slash,
    input,
    button.btn-submit {
        transition: none;
    }
}