/* ==========================================================================
   Smart Logistics Platform — Keycloak Login Theme
   ==========================================================================
   Layout note
   -----------
   This theme intentionally ships CSS + progressive-enhancement JS only; no
   FreeMarker template is overridden, so a styling mistake can never take the
   identity provider down. The split-screen layout is built by turning <body>
   into a two-column grid where the left column is a pseudo-element (the brand
   panel) and the right column is Keycloak's own `.login-pf-page` container.

   DOM assumed (Keycloak 24, parent theme `keycloak`):
     html.login-pf > body > div.login-pf-page > #kc-header + div.card-pf
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
    /* Brand ramp */
    --sl-brand-900: #081a33;
    --sl-brand-800: #0d2b52;
    --sl-brand-700: #123f76;
    --sl-brand-600: #1565c0;
    --sl-brand-500: #1976d2;
    --sl-brand-400: #42a5f5;
    --sl-brand-100: #e3f2fd;

    /* Semantic */
    --sl-success: #2e7d32;
    --sl-success-bg: #e8f5e9;
    --sl-warning: #b26a00;
    --sl-warning-bg: #fff4e5;
    --sl-danger: #c62828;
    --sl-danger-bg: #fdecec;
    --sl-info: #0277bd;
    --sl-info-bg: #e5f4fd;

    /* Surfaces (light) */
    --sl-page: #eef3fa;
    --sl-surface: #ffffff;
    --sl-surface-2: #f7f9fc;
    --sl-border: #dde5ee;
    --sl-border-strong: #c6d2e0;
    --sl-text: #0f1f38;
    --sl-text-2: #566579;
    --sl-text-3: #8d9bad;

    /* Focus ring */
    --sl-ring: rgba(25, 118, 210, 0.22);

    /* Geometry */
    --sl-radius: 14px;
    --sl-radius-sm: 10px;
    --sl-radius-xs: 8px;
    --sl-field-h: 48px;

    /* Elevation */
    --sl-shadow-sm: 0 1px 2px rgba(15, 31, 56, 0.06);
    --sl-shadow: 0 12px 32px -12px rgba(15, 31, 56, 0.18),
                 0 2px 8px rgba(15, 31, 56, 0.05);
    --sl-shadow-lg: 0 28px 64px -24px rgba(15, 31, 56, 0.28);

    /* Type */
    --sl-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, 'Noto Sans', sans-serif;

    /* Copy that lives in CSS because no FreeMarker template is overridden.
       Localised via the html[lang] rule further down. */
    /* `\A ` is a newline; the trailing space terminates the escape so the next
       character is not swallowed as another hex digit. */
    --sl-panel-headline: 'One identity for\A every logistics system.';
    --sl-panel-features: 'Single sign-on across WMS, TMS, OMS & FFS\A'
                         'Role-based access, centrally governed\A'
                         'Session and audit trail on every login';
    --sl-panel-footnote: '© Smart Logistics Platform';
    --sl-social-divider: 'or continue with';
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Makes native controls (checkbox, scrollbars) render dark too. */
        color-scheme: dark;

        --sl-page: #070d18;
        --sl-surface: #0f1826;
        --sl-surface-2: #151f30;
        --sl-border: #23324a;
        --sl-border-strong: #33455f;
        --sl-text: #e9eff8;
        --sl-text-2: #9db0c8;
        --sl-text-3: #6b7d95;

        --sl-success-bg: #12291a;
        --sl-warning-bg: #2c2011;
        --sl-danger-bg: #2e1618;
        --sl-info-bg: #0e2537;
        --sl-success: #81c784;
        --sl-warning: #ffb74d;
        --sl-danger: #ef9a9a;
        --sl-info: #64b5f6;

        --sl-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.7),
                     0 2px 8px rgba(0, 0, 0, 0.4);
        --sl-shadow-lg: 0 28px 64px -24px rgba(0, 0, 0, 0.8);
        --sl-ring: rgba(66, 165, 245, 0.3);
    }

    /* #1565c0 does not carry enough contrast against a near-black surface. */
    a,
    .btn-link,
    #kc-form-options a,
    #kc-registration a,
    #kc-info-wrapper a {
        color: var(--sl-brand-400) !important;
    }

    a:hover,
    #kc-form-options a:hover,
    #kc-registration a:hover {
        color: #90caf9 !important;
    }
}

/* Vietnamese brand-panel copy (requires realm internationalization). */
html[lang^='vi'] {
    --sl-panel-headline: 'Một danh tính cho\A mọi hệ thống logistics.';
    --sl-panel-features: 'Đăng nhập một lần cho WMS, TMS, OMS & FFS\A'
                         'Phân quyền theo vai trò, quản trị tập trung\A'
                         'Ghi nhận phiên và nhật ký mọi lần đăng nhập';
    --sl-social-divider: 'hoặc đăng nhập bằng';
}

/* --------------------------------------------------------------------------
   2. Page shell — two-column split
   -------------------------------------------------------------------------- */
html.login-pf,
html.login-pf body {
    height: auto !important;
    min-height: 100%;
}

html.login-pf {
    background: var(--sl-page) !important;
    background-image: none !important;
    -webkit-text-size-adjust: 100%;
}

body {
    position: relative;
    display: grid;
    grid-template-columns: minmax(440px, 46fr) minmax(0, 54fr);
    align-items: stretch;
    min-height: 100vh;
    margin: 0;
    background: var(--sl-page) !important;
    background-image: none !important;
    font-family: var(--sl-font) !important;
    color: var(--sl-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Left column: brand panel --------------------------------------------
   The stacked wordmark is painted as a background layer because a pseudo
   element can only carry one text run (the headline). `--sl-logo-h` is the
   rendered height of that 360x230 artwork and has to track `--sl-logo-w`,
   since `background-size: <w> auto` gives no way to query it back.
   -------------------------------------------------------------------------- */
body::before {
    --sl-logo-w: clamp(240px, 27vw, 360px);
    --sl-logo-h: clamp(153px, 17.25vw, 230px);
    --sl-logo-top: clamp(40px, 9vh, 104px);

    content: var(--sl-panel-headline);
    grid-column: 1;
    display: block;
    box-sizing: border-box;
    padding: 0 clamp(40px, 5vw, 88px);
    /* Clear the artwork, then a fixed optical gap below it. */
    padding-top: calc(var(--sl-logo-top) + var(--sl-logo-h) + clamp(28px, 5vh, 52px));
    white-space: pre-line;
    text-align: center;
    font-size: clamp(26px, 2.4vw, 38px);
    font-weight: 700;
    line-height: 1.22;
    letter-spacing: -0.02em;
    color: #ffffff;
    background:
        /* stacked wordmark, centred in the panel */
        url('../img/logo-stacked-light.svg') no-repeat
            center var(--sl-logo-top) / var(--sl-logo-w) auto,
        /* hairline grid */
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44'%3E%3Cpath d='M44 0H0v44' fill='none' stroke='%23ffffff' stroke-opacity='.05' stroke-width='1'/%3E%3C/svg%3E") repeat 0 0,
        /* glow accents */
        radial-gradient(900px 520px at 82% 8%, rgba(66, 165, 245, 0.30), transparent 62%),
        radial-gradient(760px 620px at 8% 96%, rgba(21, 101, 192, 0.42), transparent 60%),
        /* base */
        linear-gradient(155deg, var(--sl-brand-900) 0%, var(--sl-brand-800) 46%, var(--sl-brand-700) 100%);
}

/* --- Left column: feature list + footnote, pinned to the bottom ----------- */
body::after {
    content: var(--sl-panel-features) '\A\A' var(--sl-panel-footnote);
    position: absolute;
    left: 0;
    bottom: clamp(32px, 5vh, 60px);
    box-sizing: border-box;
    /* Mirrors the grid track below so the text stays inside the panel. */
    width: max(440px, 46%);
    padding: 0 clamp(40px, 5vw, 88px);
    white-space: pre-line;
    text-align: center;
    font-size: 14.5px;
    line-height: 2.05;
    color: rgba(255, 255, 255, 0.74);
    pointer-events: none;
}

/* --- Right column: Keycloak's own container ------------------------------- */
.login-pf-page {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
    max-width: none !important;
    min-height: 100vh;
    margin: 0 !important;
    padding: 48px clamp(24px, 4vw, 64px) !important;
    background: var(--sl-page);
}

/* The realm-name header block is redundant next to the brand panel. */
#kc-header {
    display: none !important;
}

/* --------------------------------------------------------------------------
   3. Card
   -------------------------------------------------------------------------- */
.login-pf-page .card-pf,
.card-pf {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 448px !important;
    margin: 0 auto !important;
    padding: clamp(28px, 3vw, 40px) !important;
    background: var(--sl-surface) !important;
    border: 1px solid var(--sl-border) !important;
    border-top: 1px solid var(--sl-border) !important;
    border-radius: var(--sl-radius) !important;
    box-shadow: var(--sl-shadow) !important;
}

/* PatternFly puts a coloured rule on top of .card-pf — remove it. */
.card-pf::before,
.card-pf::after {
    display: none !important;
}

.login-pf-header,
#kc-content,
#kc-content-wrapper {
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
}

/* The gap between the page title and whatever the flow renders first — an
   alert, an instruction, or the form itself. */
#kc-content-wrapper {
    display: block !important;
    padding-top: 22px !important;
}

/* --------------------------------------------------------------------------
   4. Titles
   -------------------------------------------------------------------------- */
#kc-page-title {
    margin: 0 !important;
    font-family: var(--sl-font) !important;
    font-size: 25px !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    letter-spacing: -0.015em;
    color: var(--sl-text) !important;
    text-align: left !important;
}

/* Sub-copy shown under the title on most flows. */
.instruction,
#kc-info-message p.instruction,
.login-pf-page .instruction {
    margin: 0 0 26px !important;
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--sl-text-2);
    text-align: left;
}

/* "Sign in as user@example.com" chip on re-auth screens. */
#kc-username {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 20px;
    padding: 10px 14px;
    background: var(--sl-surface-2);
    border: 1px solid var(--sl-border);
    border-radius: var(--sl-radius-sm);
    font-size: 14px;
    color: var(--sl-text-2);
}

#kc-username #reset-login {
    flex: none;
}

/* --------------------------------------------------------------------------
   5. Alerts / feedback
   -------------------------------------------------------------------------- */
.alert,
.login-pf .alert {
    display: flex !important;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 20px !important;
    padding: 12px 14px !important;
    border: 1px solid transparent !important;
    border-radius: var(--sl-radius-sm) !important;
    font-size: 14px !important;
    line-height: 1.5;
    text-align: left;
    background-image: none !important;
    box-shadow: none !important;
}

/* PatternFly absolutely positions the status glyph over a 42px left padding
   that this theme removes — put it back in flow as the first flex item. */
.alert > .pficon,
.alert > [class*='pficon-'] {
    position: static !important;
    top: auto !important;
    left: auto !important;
    flex: none;
    line-height: 1.5;
}

.alert .kc-feedback-text {
    flex: 1 1 auto;
    min-width: 0;
}

.alert-error,
.alert-danger {
    background: var(--sl-danger-bg) !important;
    border-color: color-mix(in srgb, var(--sl-danger) 26%, transparent) !important;
    color: var(--sl-danger) !important;
}

.alert-warning {
    background: var(--sl-warning-bg) !important;
    border-color: color-mix(in srgb, var(--sl-warning) 26%, transparent) !important;
    color: var(--sl-warning) !important;
}

.alert-success {
    background: var(--sl-success-bg) !important;
    border-color: color-mix(in srgb, var(--sl-success) 26%, transparent) !important;
    color: var(--sl-success) !important;
}

.alert-info {
    background: var(--sl-info-bg) !important;
    border-color: color-mix(in srgb, var(--sl-info) 26%, transparent) !important;
    color: var(--sl-info) !important;
}

/* Per-field validation text rendered by Keycloak. */
.kc-feedback-text,
#input-error,
#input-error-username,
#input-error-password,
#input-error-email,
span.pf-c-form__helper-text {
    display: block;
    font-size: 13px;
    line-height: 1.45;
    color: var(--sl-danger);
}

#input-error,
#input-error-username,
#input-error-password,
#input-error-email {
    margin-top: 6px;
}

/* --------------------------------------------------------------------------
   6. Form fields
   -------------------------------------------------------------------------- */
#kc-form,
#kc-form-wrapper,
form.form-horizontal {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.form-group {
    margin: 0 0 18px !important;
    padding: 0 !important;
}

/* PatternFly's grid columns force awkward widths inside a 448px card. */
.form-group > [class*='col-'],
#kc-form-options,
#kc-form-buttons {
    width: 100% !important;
    max-width: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    float: none !important;
}

label,
.control-label,
.pf-c-form__label {
    display: block !important;
    margin: 0 0 7px !important;
    font-family: var(--sl-font) !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    line-height: 1.4;
    color: var(--sl-text) !important;
    text-align: left !important;
}

input[type='text'],
input[type='password'],
input[type='email'],
input[type='tel'],
input[type='number'],
select,
textarea,
.form-control {
    box-sizing: border-box !important;
    display: block !important;
    width: 100% !important;
    height: var(--sl-field-h) !important;
    padding: 12px 14px !important;
    font-family: var(--sl-font) !important;
    /* 16px keeps iOS Safari from zooming the viewport on focus. */
    font-size: 16px !important;
    line-height: 1.4 !important;
    color: var(--sl-text) !important;
    background: var(--sl-surface) !important;
    background-image: none !important;
    border: 1.5px solid var(--sl-border-strong) !important;
    border-radius: var(--sl-radius-xs) !important;
    outline: none !important;
    box-shadow: none !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input::placeholder,
textarea::placeholder {
    color: var(--sl-text-3) !important;
    opacity: 1;
}

input[type='text']:hover,
input[type='password']:hover,
input[type='email']:hover,
.form-control:hover {
    border-color: var(--sl-brand-400) !important;
}

input[type='text']:focus,
input[type='password']:focus,
input[type='email']:focus,
input[type='tel']:focus,
input[type='number']:focus,
select:focus,
textarea:focus,
.form-control:focus {
    border-color: var(--sl-brand-500) !important;
    box-shadow: 0 0 0 4px var(--sl-ring) !important;
}

/* Fields Keycloak marked invalid. */
input.error,
.form-control.error,
input[aria-invalid='true'] {
    border-color: var(--sl-danger) !important;
}

input.error:focus,
.form-control.error:focus,
input[aria-invalid='true']:focus {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--sl-danger) 20%, transparent) !important;
}

input:disabled,
.form-control[disabled] {
    background: var(--sl-surface-2) !important;
    color: var(--sl-text-3) !important;
    cursor: not-allowed;
}

/* Chrome autofill repaints the field yellow — force it back onto the palette. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--sl-text);
    -webkit-box-shadow: 0 0 0 1000px var(--sl-surface) inset;
    caret-color: var(--sl-text);
    transition: background-color 100000s ease-in-out 0s;
}

/* --------------------------------------------------------------------------
   7. Password field + visibility toggle
   -------------------------------------------------------------------------- */
.pf-c-input-group,
.kc-input-group {
    position: relative;
    display: block !important;
    width: 100%;
}

.pf-c-input-group input[type='password'],
.pf-c-input-group input[type='text'],
.kc-input-group input {
    padding-right: 48px !important;
}

.pf-c-input-group .pf-c-button.pf-m-control,
button[data-password-toggle],
.sl-password-toggle {
    position: absolute !important;
    top: 50% !important;
    right: 4px !important;
    transform: translateY(-50%);
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px !important;
    height: 40px !important;
    min-width: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: var(--sl-radius-xs) !important;
    color: var(--sl-text-3) !important;
    font-size: 15px;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.pf-c-input-group .pf-c-button.pf-m-control:hover,
button[data-password-toggle]:hover,
.sl-password-toggle:hover {
    color: var(--sl-brand-500) !important;
    background: var(--sl-surface-2) !important;
}

.pf-c-input-group .pf-c-button.pf-m-control:focus-visible,
button[data-password-toggle]:focus-visible,
.sl-password-toggle:focus-visible {
    outline: 2px solid var(--sl-brand-500);
    outline-offset: 1px;
}

/* Caps-lock hint injected by login.js. */
.sl-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 7px;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--sl-warning);
}

.sl-hint::before {
    content: '⇪';
    font-size: 14px;
    line-height: 1;
}

/* `display: flex` above would otherwise defeat the [hidden] attribute. */
.sl-hint[hidden] {
    display: none !important;
}

/* --------------------------------------------------------------------------
   8. Options row — remember me / forgot password
   -------------------------------------------------------------------------- */
/* Remember-me on the left, forgot-password on the right. */
.login-pf-settings {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 22px !important;
    padding: 0 !important;
    min-height: 22px;
}

/* The generic 100%-width reset above would push the forgot-password link onto
   its own line, so opt this one container out of it. */
.login-pf-settings > #kc-form-options,
.login-pf-settings > div {
    width: auto !important;
    margin: 0 !important;
}

/* PatternFly hangs the box outside the label with a negative margin. */
.checkbox {
    margin: 0 !important;
    padding-left: 0 !important;
}

.checkbox input[type='checkbox'],
input#rememberMe {
    position: static !important;
    margin-left: 0 !important;
}

.checkbox label,
.login-pf-settings label {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: var(--sl-text-2) !important;
    cursor: pointer;
    user-select: none;
}

.checkbox input[type='checkbox'],
input#rememberMe {
    width: 17px !important;
    height: 17px !important;
    margin: 0 !important;
    accent-color: var(--sl-brand-500);
    cursor: pointer;
    flex: none;
}

/* --------------------------------------------------------------------------
   9. Buttons
   -------------------------------------------------------------------------- */
#kc-form-buttons {
    margin: 0 !important;
}

.btn,
input[type='submit'].btn,
button.btn {
    box-sizing: border-box;
    font-family: var(--sl-font) !important;
    border-radius: var(--sl-radius-xs) !important;
    transition: background 0.15s ease, border-color 0.15s ease,
                box-shadow 0.15s ease, transform 0.08s ease, opacity 0.15s ease;
}

.btn-primary,
input[type='submit'].btn-primary,
#kc-login {
    display: block !important;
    width: 100% !important;
    height: var(--sl-field-h) !important;
    padding: 0 20px !important;
    font-size: 15.5px !important;
    font-weight: 600 !important;
    letter-spacing: 0.005em !important;
    text-transform: none !important;
    color: #ffffff !important;
    background: linear-gradient(180deg, var(--sl-brand-500), var(--sl-brand-600)) !important;
    border: 1px solid var(--sl-brand-600) !important;
    box-shadow: 0 1px 2px rgba(21, 101, 192, 0.24),
                0 8px 18px -8px rgba(21, 101, 192, 0.55) !important;
    cursor: pointer;
}

.btn-primary:hover,
input[type='submit'].btn-primary:hover,
#kc-login:hover {
    background: linear-gradient(180deg, var(--sl-brand-600), #10529c) !important;
    box-shadow: 0 2px 4px rgba(21, 101, 192, 0.26),
                0 12px 24px -10px rgba(21, 101, 192, 0.65) !important;
}

.btn-primary:active,
#kc-login:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(21, 101, 192, 0.3) !important;
}

.btn-primary:focus-visible,
#kc-login:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--sl-brand-500);
    outline-offset: 2px;
}

.btn-primary[disabled],
.sl-is-busy,
#kc-login[disabled] {
    opacity: 0.72;
    cursor: progress;
    transform: none;
    pointer-events: none;
}

/* Indeterminate bar injected at the top of the card while a form posts. */
.sl-progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    overflow: hidden;
    border-radius: var(--sl-radius) var(--sl-radius) 0 0;
    background: color-mix(in srgb, var(--sl-brand-500) 16%, transparent);
}

.sl-progress::after {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 40%;
    background: linear-gradient(90deg, var(--sl-brand-400), var(--sl-brand-600));
    animation: sl-indeterminate 1.1s ease-in-out infinite;
}

@keyframes sl-indeterminate {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(320%); }
}

/* Secondary / cancel actions. */
.btn-default,
.btn-secondary {
    height: var(--sl-field-h) !important;
    padding: 0 18px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    color: var(--sl-text) !important;
    background: var(--sl-surface) !important;
    border: 1.5px solid var(--sl-border-strong) !important;
}

.btn-default:hover,
.btn-secondary:hover {
    background: var(--sl-surface-2) !important;
    border-color: var(--sl-text-3) !important;
}

.btn-link {
    height: auto !important;
    padding: 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--sl-brand-600) !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

/* --------------------------------------------------------------------------
   10. Links
   -------------------------------------------------------------------------- */
a {
    color: var(--sl-brand-600);
    font-weight: 600;
    text-decoration: none;
    border-radius: 3px;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--sl-brand-700);
    text-decoration: underline;
}

a:focus-visible {
    outline: 2px solid var(--sl-brand-500);
    outline-offset: 2px;
}

#kc-form-options a,
.login-pf-settings a {
    font-size: 14px;
}

/* --------------------------------------------------------------------------
   11. Social / identity providers
   -------------------------------------------------------------------------- */
#kc-social-providers {
    position: relative;
    /* PatternFly floats this section into a 50%-wide column (`max-width: 50%`)
       with side padding — none of which suits a single-column card. */
    float: none !important;
    width: 100% !important;
    max-width: none !important;
    margin-top: 28px !important;
    padding: 26px 0 0 !important;
    border: 0 !important;
    border-top: 1px solid var(--sl-border) !important;
}

/* "or continue with" label, sitting on the hairline above. */
#kc-social-providers::before {
    content: var(--sl-social-divider);
    position: absolute;
    top: -9px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0 12px;
    background: var(--sl-surface);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sl-text-3);
    white-space: nowrap;
}

#kc-social-providers h4 {
    display: none;
}

#kc-social-providers ul {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none;
}

#kc-social-providers ul li {
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
}

#kc-social-providers a,
#kc-social-providers .zocial {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100% !important;
    min-width: 0 !important;
    height: 46px !important;
    padding: 0 16px !important;
    font-family: var(--sl-font) !important;
    font-size: 14.5px !important;
    font-weight: 600 !important;
    color: var(--sl-text) !important;
    background: var(--sl-surface) !important;
    background-image: none !important;
    border: 1.5px solid var(--sl-border-strong) !important;
    border-radius: var(--sl-radius-xs) !important;
    box-shadow: none !important;
    text-shadow: none !important;
    text-decoration: none !important;
}

#kc-social-providers a:hover,
#kc-social-providers .zocial:hover {
    background: var(--sl-surface-2) !important;
    border-color: var(--sl-text-3) !important;
}

/* Two-up grid once there are several providers. */
#kc-social-providers ul.login-pf-social-double li {
    grid-column: span 1;
}

/* --------------------------------------------------------------------------
   12. Registration / info footer inside the card
   -------------------------------------------------------------------------- */
#kc-registration,
#kc-registration-container,
#kc-info,
#kc-info-wrapper {
    margin: 22px 0 0 !important;
    padding: 18px 0 0 !important;
    border-top: 1px solid var(--sl-border) !important;
    background: transparent !important;
    font-size: 14px !important;
    color: var(--sl-text-2) !important;
    text-align: center !important;
}

#kc-info,
#kc-info-wrapper {
    border-top: 0 !important;
    padding-top: 0 !important;
}

#kc-registration span,
#kc-info-wrapper span {
    color: var(--sl-text-2);
}

/* "Try another way" link on the 2FA selector. */
#try-another-way {
    font-size: 14px;
}

/* --------------------------------------------------------------------------
   13. Locale selector
   -------------------------------------------------------------------------- */
/* Keycloak renders this inside the card header. Pin it to the viewport instead
   so it reads as a page-level control and never collides with the title. */
#kc-locale {
    position: fixed;
    top: 24px;
    right: clamp(24px, 4vw, 48px);
    z-index: 20;
    float: none !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

#kc-locale-wrapper,
#kc-locale-dropdown {
    position: relative;
    display: inline-block;
}

#kc-current-locale-link,
#kc-locale-dropdown > a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    font-size: 13.5px !important;
    font-weight: 600;
    color: var(--sl-text-2) !important;
    background: var(--sl-surface);
    border: 1px solid var(--sl-border);
    border-radius: 999px;
    box-shadow: var(--sl-shadow-sm);
    cursor: pointer;
}

#kc-current-locale-link::after {
    content: '▾';
    font-size: 11px;
    opacity: 0.7;
}

#kc-current-locale-link:hover,
#kc-locale-dropdown > a:hover {
    color: var(--sl-text) !important;
    border-color: var(--sl-border-strong);
    text-decoration: none;
}

#kc-locale-dropdown ul,
#kc-locale ul {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 30;
    display: none;
    min-width: 168px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--sl-surface);
    border: 1px solid var(--sl-border);
    border-radius: var(--sl-radius-sm);
    box-shadow: var(--sl-shadow);
}

/* Without JavaScript the menu opens on hover or keyboard focus. Once login.js
   marks the document, the click handler owns the state — otherwise
   `:focus-within` would hold the menu open against an Escape press. */
html:not(.sl-js) #kc-locale-dropdown:hover ul,
html:not(.sl-js) #kc-locale-dropdown:focus-within ul,
#kc-locale-dropdown.sl-open ul {
    display: block;
}

#kc-locale-dropdown ul li a {
    display: block;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--sl-text) !important;
    border-radius: var(--sl-radius-xs);
    white-space: nowrap;
}

#kc-locale-dropdown ul li a:hover {
    background: var(--sl-surface-2);
    text-decoration: none;
}

/* --------------------------------------------------------------------------
   14. OTP / one-time-code screens
   -------------------------------------------------------------------------- */
input#otp,
input[name='otp'],
input[name='totp'],
.otp-input {
    font-size: 24px !important;
    font-weight: 600 !important;
    letter-spacing: 0.42em !important;
    text-align: center !important;
    padding-right: 0 !important;
}

/* Credential picker on multi-factor accounts. */
#kc-select-credential-form .select-auth-box-parent {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    margin-bottom: 10px;
    background: var(--sl-surface);
    border: 1.5px solid var(--sl-border-strong);
    border-radius: var(--sl-radius-sm);
    cursor: pointer;
}

#kc-select-credential-form .select-auth-box-parent:hover {
    border-color: var(--sl-brand-500);
    background: var(--sl-surface-2);
}

/* --------------------------------------------------------------------------
   15. Utilities
   -------------------------------------------------------------------------- */
.sl-visually-hidden,
.pf-screen-reader,
.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --------------------------------------------------------------------------
   16. Responsive
   -------------------------------------------------------------------------- */

/* Tablet — narrow the brand panel copy. */
@media (max-width: 1180px) {
    body {
        grid-template-columns: minmax(340px, 40fr) minmax(0, 60fr);
    }

    body::before {
        --sl-logo-w: clamp(210px, 26vw, 280px);
        --sl-logo-h: clamp(134px, 16.6vw, 179px);
        font-size: clamp(22px, 2.9vw, 30px);
    }

    body::after {
        width: max(340px, 40%);
        font-size: 13.5px;
        line-height: 1.9;
    }
}

/* Phone / small tablet — drop to a single column, keep a compact brand bar. */
@media (max-width: 900px) {
    body {
        display: block;
        min-height: 100vh;
        background:
            linear-gradient(160deg, var(--sl-brand-900) 0%, var(--sl-brand-700) 100%)
                no-repeat top center / 100% 208px,
            var(--sl-page) !important;
    }

    body::before {
        content: '';
        display: block;
        height: 268px;
        padding: 0;
        background:
            url('../img/logo-stacked-light.svg') no-repeat center 42px / 210px auto,
            url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44'%3E%3Cpath d='M44 0H0v44' fill='none' stroke='%23ffffff' stroke-opacity='.05' stroke-width='1'/%3E%3C/svg%3E") repeat 0 0,
            radial-gradient(600px 300px at 80% 0%, rgba(66, 165, 245, 0.28), transparent 65%),
            transparent;
    }

    body::after {
        content: var(--sl-panel-footnote);
        position: static;
        display: block;
        width: auto;
        padding: 24px 20px 36px;
        font-size: 12.5px;
        line-height: 1.6;
        color: var(--sl-text-3);
        text-align: center;
    }

    .login-pf-page {
        min-height: 0;
        margin-top: -68px !important;
        padding: 0 18px !important;
    }

    #kc-locale {
        top: 16px;
        right: 16px;
    }

    #kc-current-locale-link,
    #kc-locale-dropdown > a {
        color: #ffffff !important;
        background: rgba(255, 255, 255, 0.14);
        border-color: rgba(255, 255, 255, 0.24);
        box-shadow: none;
    }
}

@media (max-width: 480px) {
    .card-pf {
        padding: 24px 20px !important;
        border-radius: 12px !important;
    }

    #kc-page-title {
        font-size: 22px !important;
    }
}

/* Short viewports — don't force a full-height column. */
@media (max-height: 620px) {
    .login-pf-page {
        min-height: 0;
        padding-top: 32px !important;
        padding-bottom: 32px !important;
    }
}

/* --------------------------------------------------------------------------
   17. Motion, contrast, print
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

@media (prefers-contrast: more) {
    :root {
        --sl-border-strong: #4a5b70;
        --sl-text-2: #35455a;
    }
}

@media print {
    body::before,
    body::after,
    #kc-locale {
        display: none !important;
    }

    body {
        display: block;
        background: #ffffff !important;
    }

    .card-pf {
        box-shadow: none !important;
    }
}
