/* ============================================================
   Auth pages stylesheet (sign in, MFA, forgot / reset / change password, error)

   Visual language: the Asset Shaastra web app's. Every value below is taken from
     enterprise-solutions/asset-shaastra/src/shared/styles/
       theme.css      palette (petrol primary, slate ink) and the Manrope font
       token-map.css  semantic colours: surfaces, borders, text, status
       tokens.css     type scale, radii, elevation, control + button metrics
   and from the SPA's own FormField / Button / Checkbox / Alert / ThemeToggle components
   (src/shared/components), so an input, a button and a checkbox here are the same size,
   radius, weight and colour as the ones behind the sign-in.

   The values are DUPLICATED here rather than imported: auth-service is a separately
   deployed Thymeleaf app with no build step shared with the SPA, so there is no way to
   reference the app's tokens. If the palette or font in those files changes, change them here
   too — nothing will tell you otherwise. (This file was once left on the earlier teal palette
   and the Stack Sans Text font after the SPA moved to petrol + Manrope; that drift is what
   this header exists to prevent.)

   The font is loaded by a <link> in each template's <head> (Google Fonts, allowed by the
   CSP's style-src / font-src), the same family and weight range the SPA's index.html loads.

   Every functional behaviour (form submission, CSRF, capslock detection, password toggle,
   remember-me, SSO, language switching) is unchanged; only colour, typography, sizing and
   shadow are touched.

   Light is the default palette. The OS dark-mode preference is NOT followed; the dark palette
   applies only when the user has chosen it with the toggle (#themeToggle in login.js, stored
   by theme-init.js), which stamps data-theme="light"/"dark" on <html>. The @media block below
   is only the fallback for a page that carries no data-theme attribute at all.
   ============================================================ */

/* ---------- CSS Variables (light — default) ---------- */
:root {
    color-scheme: light;

    /* Typography — theme.css --font-sans */
    --rw-font: "Manrope", system-ui, -apple-system, sans-serif;

    /* Surfaces */
    --rw-page-bg: oklch(0.9731 0.0041 91.45);            /* --bg-app: warm off-white canvas */
    --rw-card-bg: oklch(1 0 0);                          /* --card */
    --rw-bg-sunken: color-mix(in oklab, oklch(0.9548 0.0054 95.1) 95%, oklch(0.3178 0.0343 247.33)); /* --bg-sunken */
    --rw-card-border: oklch(0.9136 0.006 239.83);        /* --border-default: decorative hairline */

    /* Brand */
    --rw-primary: oklch(0.4813 0.0664 218.12);           /* --primary: petrol */
    --rw-on-primary: oklch(1 0 0);                       /* --primary-foreground */
    --rw-primary-dark: color-mix(in oklab, oklch(0.4813 0.0664 218.12) 85%, oklch(0.3178 0.0343 247.33)); /* --primary-hover */
    --rw-primary-active: color-mix(in oklab, oklch(0.4813 0.0664 218.12) 70%, oklch(0.3178 0.0343 247.33)); /* --primary-active */
    --rw-accent: oklch(0.4813 0.0664 218.12);
    --rw-accent-hover: color-mix(in oklab, oklch(0.4813 0.0664 218.12) 85%, oklch(0.3178 0.0343 247.33));

    /* Text */
    --rw-text-primary: oklch(0.3178 0.0343 247.33);      /* --foreground */
    --rw-text-secondary: oklch(0.4195 0.0309 245.04);    /* --text-secondary */
    --rw-text-muted: oklch(0.5193 0.0283 242.74);        /* --muted-foreground */

    /* Controls */
    --rw-input-bg: oklch(1 0 0);                         /* --input-bg */
    --rw-input-border: oklch(0.627 0.0206 243.14);       /* --border-control */
    --rw-button-secondary-border: color-mix(in oklab, oklch(0.627 0.0206 243.14) 50%, oklch(0.5193 0.0283 242.74));
    --rw-input-focus: oklch(0.4813 0.0664 218.12);
    --rw-focus-ring: color-mix(in srgb, oklch(0.4813 0.0664 218.12) 25%, transparent); /* control focus ring */
    --rw-button-focus-ring: oklch(0.4813 0.0664 218.12);

    /* Status */
    --rw-danger: oklch(0.4607 0.1117 25.92);             /* --destructive */
    --rw-danger-ring: color-mix(in srgb, oklch(0.4607 0.1117 25.92) 18%, transparent);
    --rw-alert-danger-bg: oklch(0.9657 0.0109 24.32);
    --rw-alert-danger-text: oklch(0.4607 0.1117 25.92);
    --rw-alert-success-bg: oklch(0.964 0.0102 145.5);
    --rw-alert-success-text: oklch(0.4611 0.0682 148.89);
    --rw-alert-warning-bg: oklch(0.9715 0.0171 84.59);
    --rw-alert-warning-text: oklch(0.53 0.0959 78.02);
    --rw-alert-info-bg: oklch(0.9635 0.0076 228.85);
    --rw-alert-info-text: oklch(0.4286 0.0517 228.68);
    --rw-capslock: oklch(0.53 0.0959 78.02);

    /* Elevation — tokens.css --shadow-sm / --shadow-lg */
    --rw-shadow-sm: 0 1px 2px rgba(36, 52, 67, 0.04), 0 4px 16px rgba(36, 52, 67, 0.05);
    --rw-shadow-lg: 0 12px 40px rgba(36, 52, 67, 0.16);

    /* Shape — tokens.css --radius-* / --button-radius, FormField control radius */
    --rw-radius-card: 16px;
    --rw-radius: 8px;       /* buttons and inputs */
    --rw-radius-sm: 6px;    /* alerts, small controls */
    --rw-control-height: 36px;
    --rw-transition: background-color 140ms ease, border-color 120ms ease, color 120ms ease, box-shadow 140ms ease;
}

/* ---------- CSS Variables (dark) ---------- */
/* Fallback only: a page with no data-theme attribute follows the OS. Every template stamps
   data-theme="light" (and theme-init.js overrides it to "dark" on a stored choice), so in
   practice the explicit [data-theme="dark"] block below is what applies. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;

        --rw-page-bg: oklch(0.141 0.005 285.823);
        --rw-card-bg: oklch(0.21 0.006 285.885);
        --rw-bg-sunken: color-mix(in oklab, oklch(0.141 0.005 285.823) 90%, oklch(0 0 0));
        --rw-card-border: oklch(0.31 0.008 286);
        --rw-primary: oklch(0.72 0.08 218);
        --rw-on-primary: oklch(0.25 0.03 218);
        --rw-primary-dark: color-mix(in oklab, oklch(0.72 0.08 218) 85%, oklch(0.985 0 0));
        --rw-primary-active: color-mix(in oklab, oklch(0.72 0.08 218) 70%, oklch(0.985 0 0));
        --rw-accent: oklch(0.72 0.08 218);
        --rw-accent-hover: color-mix(in oklab, oklch(0.72 0.08 218) 85%, oklch(0.985 0 0));
        --rw-text-primary: oklch(0.985 0 0);
        --rw-text-secondary: oklch(0.845 0.0075 286.07);
        --rw-text-muted: oklch(0.705 0.015 286.067);
        --rw-input-bg: oklch(0.141 0.005 285.823);
        --rw-input-border: oklch(0.552 0.016 285.938);
        --rw-button-secondary-border: color-mix(in oklab, oklch(0.552 0.016 285.938) 50%, oklch(0.705 0.015 286.067));
        --rw-input-focus: oklch(0.72 0.08 218);
        --rw-focus-ring: color-mix(in srgb, oklch(0.72 0.08 218) 25%, transparent);
        --rw-button-focus-ring: oklch(0.72 0.08 218);
        --rw-danger: oklch(0.704 0.191 22.216);
        --rw-danger-ring: color-mix(in srgb, oklch(0.704 0.191 22.216) 22%, transparent);
        --rw-alert-danger-bg: oklch(0.2552 0.0573 21.95);
        --rw-alert-danger-text: oklch(0.8077 0.1035 19.57);
        --rw-alert-success-bg: oklch(0.2903 0.0508 158.98);
        --rw-alert-success-text: oklch(0.8412 0.1439 157.67);
        --rw-alert-warning-bg: oklch(0.2969 0.05 80.26);
        --rw-alert-warning-text: oklch(0.879 0.1534 91.61);
        --rw-alert-info-bg: oklch(0.2762 0.0422 226.98);
        --rw-alert-info-text: oklch(0.8276 0.1013 230.32);
        --rw-capslock: oklch(0.879 0.1534 91.61);
        --rw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --rw-shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.65), 0 8px 20px -6px rgba(0, 0, 0, 0.5);
    }
}

/* Explicit dark theme (manual toggle) */
:root[data-theme="dark"] {
    color-scheme: dark;

    --rw-page-bg: oklch(0.141 0.005 285.823);            /* --background */
    --rw-card-bg: oklch(0.21 0.006 285.885);             /* --card */
    --rw-bg-sunken: color-mix(in oklab, oklch(0.141 0.005 285.823) 90%, oklch(0 0 0));
    --rw-card-border: oklch(0.31 0.008 286);             /* --border-default (dark) */
    --rw-primary: oklch(0.72 0.08 218);
    --rw-on-primary: oklch(0.25 0.03 218);
    --rw-primary-dark: color-mix(in oklab, oklch(0.72 0.08 218) 85%, oklch(0.985 0 0));
    --rw-primary-active: color-mix(in oklab, oklch(0.72 0.08 218) 70%, oklch(0.985 0 0));
    --rw-accent: oklch(0.72 0.08 218);
    --rw-accent-hover: color-mix(in oklab, oklch(0.72 0.08 218) 85%, oklch(0.985 0 0));
    --rw-text-primary: oklch(0.985 0 0);
    --rw-text-secondary: oklch(0.845 0.0075 286.07);
    --rw-text-muted: oklch(0.705 0.015 286.067);
    --rw-input-bg: oklch(0.141 0.005 285.823);           /* an input is a well cut into the panel */
    --rw-input-border: oklch(0.552 0.016 285.938);       /* --border-control (dark) = --ring */
    --rw-button-secondary-border: color-mix(in oklab, oklch(0.552 0.016 285.938) 50%, oklch(0.705 0.015 286.067));
    --rw-input-focus: oklch(0.72 0.08 218);
    --rw-focus-ring: color-mix(in srgb, oklch(0.72 0.08 218) 25%, transparent);
    --rw-button-focus-ring: oklch(0.72 0.08 218);
    --rw-danger: oklch(0.704 0.191 22.216);
    --rw-danger-ring: color-mix(in srgb, oklch(0.704 0.191 22.216) 22%, transparent);
    --rw-alert-danger-bg: oklch(0.2552 0.0573 21.95);
    --rw-alert-danger-text: oklch(0.8077 0.1035 19.57);
    --rw-alert-success-bg: oklch(0.2903 0.0508 158.98);
    --rw-alert-success-text: oklch(0.8412 0.1439 157.67);
    --rw-alert-warning-bg: oklch(0.2969 0.05 80.26);
    --rw-alert-warning-text: oklch(0.879 0.1534 91.61);
    --rw-alert-info-bg: oklch(0.2762 0.0422 226.98);
    --rw-alert-info-text: oklch(0.8276 0.1013 230.32);
    --rw-capslock: oklch(0.879 0.1534 91.61);
    --rw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --rw-shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.65), 0 8px 20px -6px rgba(0, 0, 0, 0.5);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
}

/* Bootstrap's reboot sets its own body font, size and colour; these three lines are what make the
   page read as the SPA's body text (global.css `body`: Manrope, --text-sm 14px / 20px, ink colour). */
body {
    min-height: 100vh;
    margin: 0;
    font-family: var(--rw-font);
    font-size: 14px;
    line-height: 20px;
    font-weight: 400;
    color: var(--rw-text-primary);
    background-color: var(--rw-page-bg);
    -webkit-font-smoothing: antialiased;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow-y: auto;
}

/* Form controls and buttons take the page font explicitly: browsers give <select>, <input> and
   <button> their own system font unless told to inherit, and Bootstrap's reboot only does this
   for some of them. */
button,
input,
select,
textarea {
    font-family: inherit;
}

/* global.css: headings are semibold with slightly tightened tracking. */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--rw-font);
    font-weight: 600;
    letter-spacing: -0.01em;
}

::selection {
    background: color-mix(in oklab, var(--rw-primary) 10%, var(--rw-card-bg));
    color: color-mix(in oklab, var(--rw-primary) 80%, var(--rw-text-primary));
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--rw-card-border) transparent;
}

/* ---------- Login Container ---------- */
/* Top padding always reserves room for the fixed .lang-selector so the card
   never slides up under it on short/narrow viewports (it sits outside this
   wrapper in the DOM, so flex centering alone can't account for its space). */
.login-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 20px 24px;
    box-sizing: border-box;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--rw-card-bg);
    border: 1px solid var(--rw-card-border);
    border-radius: var(--rw-radius-card);
    box-shadow: var(--rw-shadow-lg);
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Card Header / Branding ---------- */
.login-header {
    padding: 32px 24px 0;
    text-align: center;
}

.login-logo {
    max-height: 50px;
    max-width: 100%;
    width: auto;
    margin: 0 auto 16px;
    display: block;
    transition: var(--rw-transition);
}

/* Card title = the SPA's page title (--text-xl 20px / 28px, semibold); subtitle = body text. */
.login-header h4 {
    color: var(--rw-text-primary);
    font-weight: 600;
    font-size: 20px;
    line-height: 28px;
    margin: 0 0 4px;
}

.login-header p {
    color: var(--rw-text-secondary);
    font-size: 14px;
    line-height: 20px;
    margin: 0;
}

/* ---------- Card Body / Form ---------- */
.login-body {
    padding: 24px 24px 32px;
}

/* ---------- Alert / Error Messages ---------- */
/* The SPA's <Alert>: 12px 16px, 6px radius, 8px gap, 14px/20px text, a 1px border at 30% of the
   status colour, an 18px icon. */
.login-alert {
    border: 1px solid transparent;
    border-radius: var(--rw-radius-sm);
    padding: 12px 16px;
    font-size: 14px;
    line-height: 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: shakeIn 0.4s ease;
}

.login-alert i {
    font-size: 18px;
    line-height: 20px;
    flex-shrink: 0;
}

.login-alert.alert-danger {
    background: var(--rw-alert-danger-bg);
    border-color: color-mix(in srgb, var(--rw-alert-danger-text) 30%, transparent);
    color: var(--rw-alert-danger-text);
}

.login-alert.alert-success {
    background: var(--rw-alert-success-bg);
    border-color: color-mix(in srgb, var(--rw-alert-success-text) 30%, transparent);
    color: var(--rw-alert-success-text);
}

.login-alert.alert-warning {
    background: var(--rw-alert-warning-bg);
    border-color: color-mix(in srgb, var(--rw-alert-warning-text) 30%, transparent);
    color: var(--rw-alert-warning-text);
}

.login-alert.alert-info {
    background: var(--rw-alert-info-bg);
    border-color: color-mix(in srgb, var(--rw-alert-info-text) 30%, transparent);
    color: var(--rw-alert-info-text);
}

@keyframes shakeIn {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* ---------- Form Groups ---------- */
.form-floating-group {
    position: relative;
    margin-bottom: 22px;
}

.form-floating-group .input-icon {
    position: absolute;
    left: 14px;
    /* Fixed to half the .form-control height (36px), not 50% of the wrapper —
       the wrapper also contains the validation message below the input, so a
       50% top would recentre on the taller wrapper and drift the icon upward
       whenever that message is shown. */
    top: calc(var(--rw-control-height) / 2);
    transform: translateY(-50%);
    color: var(--rw-text-muted);
    font-size: 16px;
    line-height: 1;
    z-index: 2;
    transition: var(--rw-transition);
    pointer-events: none;
}

/* The SPA's FormField control: h-9 (36px), 8px radius, 14px text, 1px control-weight border,
   focus = primary border + 3px ring at 25%. */
.form-floating-group .form-control {
    height: var(--rw-control-height);
    padding: 8px 12px 8px 40px;
    border: 1px solid var(--rw-input-border);
    border-radius: var(--rw-radius);
    font-size: 14px;
    line-height: 20px;
    color: var(--rw-text-primary);
    background-color: var(--rw-input-bg);
    transition: var(--rw-transition);
}

.form-floating-group .form-control::placeholder {
    color: var(--rw-text-muted);
    opacity: 1;
}

.form-floating-group .form-control:focus {
    border-color: var(--rw-input-focus);
    box-shadow: 0 0 0 3px var(--rw-focus-ring);
    outline: none;
    background-color: var(--rw-input-bg);
    color: var(--rw-text-primary);
}

/* A browser-autofilled field (saved sign-in) otherwise paints the browser's own pale blue/yellow
   over the input, which is what made a filled username/password look unlike every other field. */
.form-floating-group .form-control:-webkit-autofill,
.form-floating-group .form-control:-webkit-autofill:hover,
.form-floating-group .form-control:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--rw-text-primary);
    caret-color: var(--rw-text-primary);
    -webkit-box-shadow: 0 0 0 1000px var(--rw-input-bg) inset;
    transition: background-color 9999s ease-out 0s;
}
.form-floating-group .form-control:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--rw-input-bg) inset, 0 0 0 3px var(--rw-focus-ring);
}

.form-floating-group .form-control:focus ~ .input-icon {
    color: var(--rw-input-focus);
}

.form-floating-group .form-control.is-invalid {
    border-color: var(--rw-danger);
    box-shadow: 0 0 0 3px var(--rw-danger-ring);
}

/* Password toggle */
.password-toggle {
    position: absolute;
    right: 14px;
    /* See .input-icon above: fixed to the .form-control height, not the wrapper's. */
    top: calc(var(--rw-control-height) / 2);
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--rw-text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    z-index: 2;
    transition: var(--rw-transition);
    line-height: 1;
}

.password-toggle:hover {
    color: var(--rw-primary);
}

/* Validation feedback */
.invalid-feedback {
    font-size: 12px;
    line-height: 16px;
    margin-top: 6px;
    padding-left: 2px;
    color: var(--rw-danger);
}

/* ---------- Remember & Forgot Row ---------- */
.login-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding-left: 0;
}

/* The SPA's <Checkbox>: 18px box, 5px radius, 1.5px control border, primary fill when checked. */
.form-check .form-check-input {
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
    background-color: var(--rw-input-bg);
    border: 1.5px solid var(--rw-input-border);
    border-radius: 5px;
    cursor: pointer;
    transition: var(--rw-transition);
    float: none;
}

/* Bootstrap draws the tick as a white SVG; in dark the primary is light, so the tick has to be
   dark (--primary-foreground) to stay readable. A data-URI cannot read a CSS variable, hence one
   rule per theme. */
.form-check .form-check-input:checked {
    background-color: var(--rw-primary);
    border-color: var(--rw-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.6' d='m5.5 10.5 3 3 6-6.5'/%3E%3C/svg%3E");
    background-position: center;
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

:root[data-theme="dark"] .form-check .form-check-input:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%2314262c' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.6' d='m5.5 10.5 3 3 6-6.5'/%3E%3C/svg%3E");
}

.form-check .form-check-input:focus {
    border-color: var(--rw-primary);
    box-shadow: 0 0 0 3px var(--rw-focus-ring);
}

/* SPA checkbox label: text-sm, ink colour. */
.form-check-label {
    font-size: 14px;
    line-height: 20px;
    color: var(--rw-text-primary);
    cursor: pointer;
    user-select: none;
    vertical-align: middle;
}

.forgot-link {
    font-size: 14px;
    line-height: 20px;
    color: var(--rw-accent);
    text-decoration: none;
    font-weight: 500;
    transition: var(--rw-transition);
}

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

/* ---------- Submit Button ---------- */
/* The SPA's primary <Button> at full width: 8px radius, weight 600, 6px icon gap, flat (no shadow),
   hover = --primary-hover, active = --primary-active. Taller than an input (40px) because it is
   the page's one call to action; the SPA's "lg" size does the same (17px type there, 15px here to
   suit a 380px card). */
.btn-login {
    width: 100%;
    height: 40px;
    background-color: var(--rw-primary);
    color: var(--rw-on-primary);
    border: 1px solid var(--rw-primary);
    border-radius: var(--rw-radius);
    font-size: 15px;
    line-height: 22px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--rw-transition);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-login:hover,
.btn-login:focus-visible {
    background-color: var(--rw-primary-dark);
    border-color: var(--rw-primary-dark);
    color: var(--rw-on-primary);
}

.btn-login:active {
    background-color: var(--rw-primary-active);
    border-color: var(--rw-primary-active);
    color: var(--rw-on-primary);
}

.btn-login:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Loading spinner */
.btn-login .spinner-border {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.btn-text,
.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-loading {
    display: none;
}

.btn-login.loading .btn-text {
    display: none;
}

.btn-login.loading .btn-loading {
    display: flex;
}

/* ---------- Error page timestamp ---------- */
/* CSP (style-src 'self', no 'unsafe-inline') blocks inline style attributes,
   so this must live in the stylesheet rather than error.html. */
.error-timestamp {
    color: var(--rw-text-secondary);
}

/* ---------- SSO providers ---------- */
.sso-providers {
    margin-top: 20px;
}

.sso-divider {
    text-align: center;
    font-size: 12px;
    line-height: 16px;
    color: var(--rw-text-muted);
    margin-bottom: 14px;
    position: relative;
}

.sso-divider::before,
.sso-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--rw-card-border);
}

.sso-divider::before { left: 0; }
.sso-divider::after { right: 0; }

/* The SPA's secondary <Button>: card fill, mixed control border, secondary-ink text; hover lifts
   to the subtle surface and the text to full ink. */
.sso-providers .btn-outline-secondary {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--rw-card-bg);
    border: 1px solid var(--rw-button-secondary-border);
    border-radius: var(--rw-radius);
    color: var(--rw-text-secondary);
    font-size: 14px;
    line-height: 22px;
    font-weight: 600;
    transition: var(--rw-transition);
}

.sso-providers .btn-outline-secondary:hover,
.sso-providers .btn-outline-secondary:focus-visible,
.sso-providers .btn-outline-secondary:active {
    background-color: color-mix(in oklab, var(--rw-card-bg) 60%, var(--rw-bg-sunken));
    border-color: var(--rw-button-secondary-border);
    color: var(--rw-text-primary);
}

/* ---------- Card Footer ---------- */
.login-footer {
    padding: 16px 24px 24px;
    text-align: center;
    border-top: 1px solid var(--rw-card-border);
}

.login-footer p {
    margin: 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--rw-text-muted);
}

.login-footer a {
    color: var(--rw-accent);
    text-decoration: none;
    font-weight: 500;
}

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

/* ---------- Capslock Warning ---------- */
.capslock-warning {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    line-height: 16px;
    color: var(--rw-capslock);
    margin-top: 6px;
    padding-left: 2px;
}

.capslock-warning.show {
    display: flex;
}

/* ---------- Theme Toggle ---------- */
/* The SPA's <ThemeToggle>: a pill (sunken fill) holding a sun and a moon, the current one raised on
   a card-coloured disc in the primary colour. Still ONE <button id="themeToggle">: login.js flips
   the theme on click, and this block only draws which half is current from data-theme. */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 132px;
    z-index: 10;
}

.theme-toggle button {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    height: 32px;
    background-color: var(--rw-bg-sunken);
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    line-height: 1;
}

.theme-toggle button i {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    font-size: 14px;
    color: var(--rw-text-muted);
    background-color: transparent;
    transition: var(--rw-transition);
}

.theme-toggle button:hover i {
    color: var(--rw-text-primary);
}

/* The current theme's half: raised, primary. Light = sun, dark = moon. */
:root:not([data-theme="dark"]) .theme-toggle .bi-sun,
:root[data-theme="dark"] .theme-toggle .bi-moon {
    background-color: var(--rw-card-bg);
    color: var(--rw-primary);
    box-shadow: var(--rw-shadow-sm);
}

.theme-toggle button:focus-visible {
    outline: 2px solid var(--rw-button-focus-ring);
    outline-offset: 2px;
}

.rtl .theme-toggle {
    left: 132px;
    right: auto;
}

/* ---------- Language Selector ---------- */
.lang-selector {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10;
    max-width: calc(50% - 24px);
}

.lang-selector .form-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: var(--rw-card-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%237e8a94' d='M4 6l4 4.5L12 6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 13px;
    border: 1px solid var(--rw-input-border);
    color: var(--rw-text-secondary);
    font-size: 12px;
    font-weight: 500;
    /* height matches .theme-toggle button (32px, same border-box sizing) — vertical
       padding is 0 so the select's own line-height centers the text in that box. */
    height: 32px;
    padding: 0 26px 0 10px;
    border-radius: var(--rw-radius);
    transition: var(--rw-transition);
    min-width: 100px;
    cursor: pointer;
}

.lang-selector .form-select:focus {
    background-color: var(--rw-input-bg);
    border-color: var(--rw-input-focus);
    color: var(--rw-text-primary);
    box-shadow: 0 0 0 3px var(--rw-focus-ring);
    outline: none;
}

.lang-selector .form-select:hover {
    background-color: var(--rw-input-bg);
    color: var(--rw-text-primary);
}

.lang-selector .form-select option {
    background: var(--rw-card-bg);
    color: var(--rw-text-primary);
    padding: 4px 8px;
}

/* RTL support */
.rtl .lang-selector {
    left: 16px;
    right: auto;
}

.rtl .lang-selector .form-select {
    background-position: left 8px center;
    padding: 4px 8px 4px 26px;
}

.rtl .login-wrapper {
    direction: rtl;
}

.rtl .form-floating-group .input-icon {
    left: auto;
    right: 14px;
}

.rtl .form-floating-group .form-control {
    padding-left: 12px;
    padding-right: 40px;
}

.rtl .password-toggle {
    left: 14px;
    right: auto;
}

.rtl .login-options {
    flex-direction: row-reverse;
}

.rtl .login-footer {
    text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 576px) {
    .login-wrapper {
        padding: 56px 12px 16px;
        align-items: flex-start;
    }

    .login-card {
        max-width: 100%;
        border-radius: var(--rw-radius);
    }

    .login-header {
        padding: 24px 20px 0;
    }

    /* tokens.css scales --text-xl down to 17px/24px on a phone */
    .login-header h4 {
        font-size: 17px;
        line-height: 24px;
    }

    .login-body {
        padding: 20px 20px 24px;
    }

    .login-footer {
        padding: 14px 20px 20px;
    }

    .login-logo {
        max-height: 40px;
    }

    .lang-selector {
        top: 12px;
        right: 12px;
        max-width: calc(100% - 24px);
    }

    .lang-selector .form-select {
        min-width: 84px;
        padding: 0 22px 0 8px;
    }

    .rtl .lang-selector {
        left: 12px;
        right: auto;
    }

    .theme-toggle {
        top: 12px;
        right: 100px;
    }

    .rtl .theme-toggle {
        left: 100px;
        right: auto;
    }
}

@media (max-width: 360px) {
    .lang-selector .form-select {
        min-width: 72px;
    }
}

/* ---------- Focus-visible for Accessibility ---------- */
/* Buttons and links: the SPA's --button-focus-ring (2px, offset 2). A control already shows its
   own focus as a primary border plus a 3px ring, so it gets no second outline on top. */
.btn:focus-visible,
a:focus-visible {
    outline: 2px solid var(--rw-button-focus-ring);
    outline-offset: 2px;
}

.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible {
    outline: none;
}

/* ---------- Reduced Motion Preference ---------- */
@media (prefers-reduced-motion: reduce) {
    .login-card {
        animation: none;
    }

    .login-alert {
        animation: none;
    }

    * {
        transition-duration: 0.01ms !important;
    }
}
