/*
 * Login page — split-screen, mobile-friendly, theme-aware.
 *
 * Dedicated pre-auth sheet (linked only from login.html / password-reset.html).
 *
 * Colours flow through LOCAL custom properties (--lp-*) defined on .login-page.
 * Their light defaults pull from the dynamic-theme tokens (--surface-background-color,
 * --primary-color, ...) so each client's palette is respected without the SCSS
 * compiler / a restart. A `prefers-color-scheme: dark` block re-points the same
 * --lp-* vars to a hand-tuned dark palette, so we OWN dark mode instead of letting
 * Chrome's "Auto Dark Mode" half-invert the page (which left autofilled inputs an
 * ugly light-blue on a force-darkened panel). `color-scheme` tells the browser we
 * handle both, so native widgets (autofill, scrollbars, checkbox) render correctly.
 *
 * Everything is scoped under .login-page so it overrides the global app.css rules
 * (e.g. `button { display:grid }`) that would otherwise mangle the form.
 */

.login-page {
    /* Light palette (default). These are EXPLICIT light values, intentionally NOT
       sourced from the dynamic-theme tokens (--surface-background-color, ...): those
       follow the app's stored ThemeService preference, which would make the login
       page track the *app theme* instead of the *device*. The pre-auth login page is
       device-driven only — light here + the prefers-color-scheme:dark block below.
       The client's brand colour (--primary-color) is still honoured for accents. */
    --lp-bg: #ffffff;
    --lp-panel: #ffffff;
    --lp-field: #ffffff;
    --lp-field-border: #d6d9e0;
    --lp-text: #1a1a1a;
    --lp-muted: #6b7280;
    --lp-panel-border: #e2e5ec;
    --lp-arch: 36px;

    color-scheme: light dark;
    margin: 0;
    min-height: 100vh;
    background: var(--lp-bg);
    color: var(--lp-text);
    font-family: 'Roboto', system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
    .login-page {
        --lp-bg: #0f1115;
        --lp-panel: #16181d;
        --lp-field: #1e2127;
        --lp-field-border: #2a2e37;
        --lp-text: #f3f4f6;
        --lp-muted: #9aa0aa;
        --lp-panel-border: #2a2e37;
    }
}

/* ---- Split layout ---------------------------------------------------- */

.login-page .login-split {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    min-height: 100vh;
}

/* ---- Brand / background half ---------------------------------------- */

.login-page .login-brand {
    position: relative;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.login-page .login-brand__scrim {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.7) 100%),
        linear-gradient(120deg,
            color-mix(in srgb, var(--primary-color, #007fff) 55%, transparent) 0%,
            transparent 60%);
}

.login-page .login-brand__content {
    position: relative;
    z-index: 1;
    padding: 56px;
    color: #fff;
    max-width: 520px;
}

.login-page .login-brand__logo {
    height: 56px;
    width: auto;
    margin-bottom: 28px;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.4));
}

.login-page .login-brand__title {
    font-size: 2.6rem;
    font-weight: 700;
    margin: 0 0 12px;
    line-height: 1.1;
}

.login-page .login-brand__tagline {
    font-size: 1.05rem;
    line-height: 1.6;
    margin: 0;
    color: rgba(255, 255, 255, 0.85);
}

/* ---- Form half ------------------------------------------------------- */

.login-page .login-form-panel {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: var(--lp-panel);

    /* Pull left so the panel "slots onto" the background image, with a border and
       arched top-left / bottom-left corners that read against the artwork. */
    margin-left: -52px;
    border: 1px solid var(--lp-panel-border);
    border-right: none;
    border-radius: var(--lp-arch) 0 0 var(--lp-arch);
    box-shadow: -18px 0 40px rgba(0, 0, 0, 0.28);
}

.login-page .login-card {
    width: 100%;
    max-width: 400px;
}

.login-page .login-card__logo {
    display: none; /* shown only on mobile, when the brand panel is hidden */
    height: 48px;
    width: auto;
    margin: 0 auto 24px;
}

.login-page .login-card__heading {
    font-size: 1.9rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--lp-text);
}

.login-page .login-card__sub {
    margin: 0 0 32px;
    color: var(--lp-muted);
    font-size: 0.95rem;
}

/* ---- Fields ---------------------------------------------------------- */

.login-page .field {
    display: block;
    margin-bottom: 20px;
}

.login-page .field__label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 8px;
    color: var(--lp-muted);
}

.login-page .field__control {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    height: 50px;
    border: 1px solid var(--lp-field-border);
    border-radius: 12px;
    background: var(--lp-field);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-page .field__control:focus-within {
    border-color: var(--primary-color, #007fff);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-color, #007fff) 22%, transparent);
}

.login-page .field__icon {
    color: var(--lp-muted);
    font-size: 1rem;
    flex: 0 0 auto;
}

.login-page .field__input {
    flex: 1 1 auto;
    height: 100%;
    border: none !important;
    outline: none;
    background: transparent;
    box-shadow: none !important;
    margin: 0;
    font-size: 1rem;
    color: var(--lp-text);
}

.login-page .field__input::placeholder {
    color: var(--lp-muted);
    opacity: 0.7;
}

/* Kill Chrome's autofill background (the "ugly white") — paint the field colour
   over it via an inset shadow and keep the text legible in either scheme. */
.login-page .field__input:-webkit-autofill,
.login-page .field__input:-webkit-autofill:hover,
.login-page .field__input:-webkit-autofill:focus,
.login-page .field__input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--lp-text);
    -webkit-box-shadow: 0 0 0 1000px var(--lp-field) inset;
    caret-color: var(--lp-text);
    transition: background-color 9999s ease-out 0s;
}

.login-page .field__toggle {
    flex: 0 0 auto;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--lp-muted);
    padding: 6px;
    display: flex;
    margin: 0;
    height: auto;
}

.login-page .field__toggle:hover {
    color: var(--primary-color, #007fff);
}

/* ---- Remember / submit ---------------------------------------------- */

.login-page .login-form__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 26px;
}

.login-page .remember {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--lp-muted);
    font-size: 0.9rem;
}

.login-page .remember input[type="checkbox"] {
    position: static;
    opacity: 1;
    pointer-events: auto;
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary-color, #007fff);
}

/* Suppress Materialize's fake checkbox pseudo-elements — we show the native box. */
.login-page .remember span {
    padding-left: 0;
}

.login-page .remember span::before,
.login-page .remember span::after {
    display: none !important;
}

.login-page .login-form__submit {
    width: 100%;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #fff;
    background: var(--primary-color, #007fff);
    box-shadow: 0 8px 24px color-mix(in srgb, var(--primary-color, #007fff) 38%, transparent);
    transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.15s ease;
}

.login-page .login-form__submit:hover {
    filter: brightness(1.05);
    box-shadow: 0 12px 30px color-mix(in srgb, var(--primary-color, #007fff) 48%, transparent);
}

.login-page .login-form__submit:active {
    transform: translateY(1px);
}

.login-page .login-form__submit .material-icons {
    font-size: 1.25rem;
}

.login-page .login-form__error {
    margin: 18px 0 0;
    padding: 12px 14px;
    border-radius: 10px;
    background: color-mix(in srgb, #e53935 12%, transparent);
    color: #e53935;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
}

.login-page .login-card__apply {
    margin: 26px 0 0;
    padding-top: 22px;
    border-top: 1px solid var(--lp-field-border);
    text-align: center;
    font-size: 0.9rem;
    color: var(--lp-muted);
}

.login-page .login-card__apply a {
    color: var(--primary-color, #007fff);
    font-weight: 600;
    text-decoration: none;
}

.login-page .login-card__apply a:hover {
    text-decoration: underline;
}

.login-page .login-form-panel__copy {
    position: absolute;
    bottom: 18px;
    margin: 0;
    font-size: 0.8rem;
    color: var(--lp-muted);
}

/* ---- Mobile ---------------------------------------------------------- */

@media (max-width: 860px) {
    .login-page .login-split {
        grid-template-columns: 1fr;
    }

    /* The heavy background image is dropped on phones — the form panel takes
       over full-width and the logo appears inside the card instead. */
    .login-page .login-brand {
        display: none;
    }

    .login-page .login-card__logo {
        display: block;
    }

    /* Reset the desktop "slotted" treatment so the panel fills the screen. */
    .login-page .login-form-panel {
        min-height: 100vh;
        padding: 32px 20px 64px;
        margin-left: 0;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }
}

@media (max-width: 400px) {
    .login-page .login-card__heading {
        font-size: 1.6rem;
    }
}
