/*
 * AppKit theme overrides for the SMM panel.
 * Loaded after AppKit's bootstrap.css and style.css.
 *
 * Brand colours live ONLY in the :root block below. To recolour the theme,
 * override --brand-primary (and optionally --brand-primary-light/-dark) on :root,
 * e.g. from an admin colour setting or a user colour picker:
 *   <style>:root{--brand-primary:#16a34a}</style>
 * The shades are derived with color-mix(), so overriding --brand-primary alone works.
 */

/* ---------- Fonts (self-hosted Inter, SIL OFL 1.1 - see ../fonts/inter/OFL.txt) ---------- */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/inter/inter-latin-400-normal.woff2") format("woff2");
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/inter/inter-latin-500-normal.woff2") format("woff2");
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/inter/inter-latin-600-normal.woff2") format("woff2");
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/inter/inter-latin-700-normal.woff2") format("woff2");
}

/* ---------- Design tokens: the one place colours are defined ---------- */
:root {
    --rm-accent: #314EDB; /* the Indigo accent; auth-accent.js replaces it inline when this browser has another saved colour */
    --brand-primary: var(--rm-accent);
    --brand-primary-light: color-mix(in srgb, var(--brand-primary) 90%, #ffffff); /* white on this stop: 5.1:1 or better for all 8 colours (82% gave 4.31 on Teal and Yellow) */
    --brand-primary-dark: color-mix(in srgb, var(--brand-primary) 80%, #000000);
    --brand-primary-soft: color-mix(in srgb, var(--brand-primary) 12%, transparent);
    --brand-on-primary: #ffffff;

    --page-bg: #eef2f1;
    --surface: #ffffff;
    --text-strong: #1f1f1f;
    --text: #727272;
    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.3);

    --danger: #da4453;
    --danger-soft: color-mix(in srgb, var(--danger) 10%, transparent);
    --success: #8cc152;
    --success-soft: color-mix(in srgb, var(--success) 12%, transparent);
    --warning: #f6bb42;
    --warning-soft: color-mix(in srgb, var(--warning) 16%, transparent);

    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- AppKit "highlight" classes, driven by the brand tokens ---------- */
/* Replaces AppKit's styles/highlights/highlight_*.css colour packs. */
.color-highlight {
    color: var(--brand-primary) !important;
}

.bg-highlight {
    background-color: var(--brand-primary) !important;
    color: var(--brand-on-primary) !important;
}

.border-highlight {
    border-color: var(--brand-primary) !important;
}

.gradient-highlight {
    background-image: linear-gradient(to bottom, var(--brand-primary-light), var(--brand-primary)) !important;
    color: var(--brand-on-primary) !important;
}

/* ---------- Sign-in (L1): v2 look. The only colour source is --rm-accent. ---------- */
:root {
    --auth-err: #B42318;                                   /* semantic error text, about 6.5:1 on white */
    --auth-err-soft: #FDECEA;
    --auth-band-a: var(--brand-primary);
    --auth-band-b: var(--brand-primary-light);
    --auth-accent-text: var(--brand-primary);              /* brand colour used AS text / icon / outline on the card; css/auth-dark.css swaps in a light tint */
    --auth-band-b-src: var(--brand-primary-light);         /* the lighter band stop, named here so css/auth-dark.css can darken it without reading --brand-primary-light itself */
    --auth-card-shadow: 0 18px 40px rgba(17, 24, 50, .12);
}

body.appkit-auth {
    font-family: var(--font-sans) !important;
    color: var(--text-strong) !important;
    background-color: var(--page-bg);
}

body.appkit-auth a {
    text-decoration: none;
}

body.appkit-auth :focus-visible {
    outline: 3px solid var(--auth-accent-text);
    outline-offset: 2px;
}

/* checkbox.css draws the checkbox ring from --brand-accent / --brand-primary; here it follows the same token as every other ring on this sheet (identical in light) */
body.appkit-auth input[type="checkbox"]:focus-visible {
    outline-color: var(--auth-accent-text) !important;
}

/* native controls (scrollbars, the picker's search caret) follow the dark theme set by css/auth-dark.css */
html[data-rm-theme="dark"] body.appkit-auth {
    color-scheme: dark;
}

.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.auth-band {
    position: relative;
    overflow: hidden;
    color: #fff;
    padding: calc(22px + env(safe-area-inset-top)) 22px 64px;
    background: linear-gradient(160deg, var(--auth-band-a), var(--auth-band-b));
}

.auth-band::before {
    content: "";
    position: absolute;
    right: -70px;
    top: -60px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .10);
}

.auth-band::after {
    content: "";
    position: absolute;
    left: -50px;
    bottom: -70px;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .07);
}

.auth-brand {
    position: relative;
    display: inline-flex;
    padding: 6px 10px;
    background: #fff;
    border-radius: 12px;
    z-index: 1;
}

.auth-brand img {
    height: 48px;
    max-height: 48px;
    max-width: 220px;
    width: auto;
    display: block;
}

.auth-band-text {
    position: relative;
    z-index: 1;
    margin-top: 24px;
}

.auth-eyebrow {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, .9);
}

.auth-title {
    margin: 2px 0 0;
    font-size: 30px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -.6px;
    color: #fff;
}

body.appkit-auth h1.auth-title {
    color: #fff;
}

.auth-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 16px calc(20px + env(safe-area-inset-bottom));
}

.auth-card {
    position: relative;
    margin: -40px auto 0;
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 26px;
    padding: 22px 20px 20px;
    box-shadow: var(--auth-card-shadow);
}

.auth-subtitle {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
}

.auth-footer-note {
    margin: auto 0 0;
    padding-top: 22px;
    text-align: center;
    font-size: 12px;
    color: var(--text);
}

.auth-field {
    margin-bottom: 14px;
}

.auth-field > label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-strong);
}

.auth-control {
    position: relative;
}

.auth-control > i:first-child {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--auth-accent-text);
    pointer-events: none;
}

.auth-control input.form-control {
    width: 100%;
    height: 50px;
    padding: 0 14px 0 42px;
    font-size: 15px;
    color: var(--text-strong);
    background: #fff;
    border: 1.5px solid var(--border-strong) !important;
    border-radius: 14px;
    box-shadow: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.auth-control input.form-control:focus {
    border-color: var(--auth-accent-text) !important;
    box-shadow: 0 0 0 4px var(--brand-primary-soft);
    outline: none;
}

.auth-field.has-toggle input.form-control {
    padding-right: 50px;
}

.auth-field.is-invalid input.form-control {
    border-color: var(--auth-err) !important;
}

.auth-field.is-invalid input.form-control:focus {
    box-shadow: 0 0 0 4px var(--auth-err-soft);
}

.auth-toggle-password {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    display: grid;
    place-items: center;
}

.auth-control .auth-toggle-password i {
    position: static;
    transform: none;
    color: inherit;
    pointer-events: none;
}

.auth-error {
    display: block;
    margin: 6px 2px 0;
    font-size: 12.5px;
    line-height: 18px;
    font-weight: 500;
    color: var(--auth-err);
}

/* ---------- Flash alerts (also used by partials/flash.blade.php) ---------- */
.auth-alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 13px;
    margin-bottom: 16px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.4;
}

.auth-alert i {
    margin-top: 2px;
}

.auth-alert--error {
    background-color: var(--auth-err-soft);
    color: var(--auth-err);
    font-weight: 500;
}

.auth-alert--success {
    background-color: var(--success-soft);
    color: var(--text-strong);
}

.auth-alert--success i {
    color: var(--success);
}

.auth-alert--warning {
    background-color: var(--warning-soft);
    color: var(--text-strong);
}

.auth-alert--warning i {
    color: var(--warning);
}

/* ---------- Captcha ---------- */
.auth-captcha {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.auth-captcha img {
    border-radius: 12px;
    border: 1px solid var(--border);
    max-width: 100%;
}

.auth-captcha-refresh {
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--auth-accent-text);
    cursor: pointer;
}

.auth-recaptcha {
    margin-bottom: 14px;
    container-type: inline-size;
    overflow: hidden;
}

/* The Google widget is a fixed 304px: on a narrower container scale it down (steps, a container query cannot divide) and pull the layout gap back. */
.auth-recaptcha > .g-recaptcha { transform-origin: 0 0; }
@container (max-width: 303px) { .auth-recaptcha > .g-recaptcha { transform: scale(.9); margin-bottom: -8px; } }
@container (max-width: 273px) { .auth-recaptcha > .g-recaptcha { transform: scale(.8); margin-bottom: -16px; } }
@container (max-width: 243px) { .auth-recaptcha > .g-recaptcha { transform: scale(.7); margin-bottom: -23px; } }

/* ---------- Remember me / forgot ---------- */
.auth-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 4px 12px;
    margin: 2px 0 6px;
}

.auth-options .form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 0;
    padding-left: 0;
    margin-bottom: 0;
}

.auth-options .form-check .form-check-input {
    float: none;
    margin: 0;
}

.auth-options .form-check-label {
    font-size: 13.5px;
    color: var(--text-strong);
}

.auth-options > a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--auth-accent-text);
}

/* the checkbox box itself, its tick, focus ring and 44px target come from checkbox.css (CheckboxStyleTest): not restyled here */

/* ---------- Buttons ---------- */
.auth-submit {
    display: block;
    width: 100%;
    height: 52px;
    margin-top: 4px;
    border: 0;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 700;
    color: var(--brand-on-primary);
    cursor: pointer;
    background: linear-gradient(180deg, var(--auth-band-b), var(--auth-band-a));
    box-shadow: 0 8px 18px color-mix(in srgb, var(--brand-primary) 30%, transparent);
    transition: filter 150ms ease, transform 150ms ease;
}

.auth-submit:hover {
    filter: brightness(1.05);
}

.auth-submit:active {
    transform: translateY(1px);
}

/* Google + Fingerprint: one row under Sign In. Two = equal halves, one = full width. */
.auth-alt-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.auth-alt-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 0 10px;
    border: 1.5px solid var(--border-strong);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text-strong);
    font: inherit;
    font-size: 14.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.auth-alt-btn:hover {
    border-color: var(--brand-primary);
}

.auth-alt-btn--passkey i {
    color: var(--auth-accent-text);
    font-size: 18px;
}

.auth-alt-link {
    margin: 16px 0 0;
    text-align: center;
    font-size: 14px;
    color: var(--text);
}

.auth-alt-link a {
    color: var(--auth-accent-text);
    font-weight: 700;
}

/* Desktop: ONE centred, rounded shell (band panel left, form side right), as in Login.dc.html. */
@media (min-width: 760px) {
    body.appkit-auth {
        min-height: 100vh;
        min-height: 100dvh;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 24px;
    }

    .auth-shell {
        flex: 0 1 980px;
        width: min(980px, 100%);
        min-height: 620px;
        flex-direction: row;
        border-radius: 28px;
        overflow: hidden;
        background: var(--page-bg);
        box-shadow: 0 10px 30px rgba(16, 21, 33, .18);
    }

    .auth-band {
        flex: 1 1 46%;
        min-width: 0;
        align-self: stretch;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        padding: 40px;
    }

    .auth-title {
        font-size: 38px;
    }

    .auth-main {
        flex: 1 1 54%;
        min-width: 0;
        justify-content: center;
        align-items: center;
        padding: 28px;
    }

    .auth-card {
        margin: 0 auto;
    }

    .auth-footer-note {
        margin: 18px 0 0;
        padding: 0;
    }
}
/* ---------- Register (L4a): colours come from the tokens above only ---------- */
.auth-card--wide {
    max-width: 480px;
}

.auth-row2 {
    display: flex;
    gap: 10px;
}

.auth-row2 > .auth-field {
    flex: 1 1 0;
    min-width: 0;
}

@media (max-width: 479px) {
    .auth-row2 {
        flex-direction: column;
        gap: 0;
    }
}

.auth-sponsor {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px 13px;
    border-radius: 14px;
    background: var(--brand-primary-soft);
    font-size: 13.5px;
    color: var(--text-strong);
}

.auth-sponsor i,
.auth-sponsor b {
    color: var(--auth-accent-text);
}

.auth-sponsor b {
    overflow-wrap: anywhere;
}

.auth-hint {
    margin: 6px 2px 0;
    font-size: 12.5px;
    line-height: 18px;
    color: var(--text);
}

/* Phone: country button + number */
.auth-phone-row {
    display: flex;
    gap: 8px;
}

.auth-phone-row .auth-control {
    flex: 1 1 auto;
    min-width: 0;
}

.auth-phone-row .auth-control input.form-control {
    padding-left: 14px;
}

.auth-cc-wrap {
    flex: 0 0 auto;
}

.auth-cc,
.auth-cc-fallback {
    min-width: 96px;
    height: 50px;
    border: 1.5px solid var(--border-strong);
    border-radius: 14px;
    background: var(--surface);
    font: inherit;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text-strong);
}

.auth-cc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 10px;
    cursor: pointer;
}

.auth-cc[hidden],
.auth-cc-fallback[hidden] {
    display: none;
}

.auth-cc i {
    font-size: 11px;
}

.auth-cc img,
.auth-picker-name img {
    width: 22px;
    height: 16px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid var(--border);
}

.auth-cc-fallback {
    max-width: 150px;
    padding: 0 8px;
}

.auth-picker {
    margin-top: 8px;
    border: 1.5px solid var(--border-strong);
    border-radius: 14px;
    background: var(--surface);
    overflow: hidden;
    box-shadow: 0 12px 28px rgba(17, 24, 50, .14);
}

.auth-picker[hidden] {
    display: none;
}

.auth-picker-search {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-strong);
    font: inherit;
    font-size: 14.5px;
    outline: none;
}

.auth-picker ul {
    list-style: none;
    margin: 0;
    padding: 4px;
    max-height: 200px;
    overflow: auto;
}

.auth-picker li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
}

.auth-picker li[hidden] {
    display: none;
}

.auth-picker li:hover,
.auth-picker li:focus-visible {
    background: var(--brand-primary-soft);
}

.auth-picker li[aria-selected="true"] {
    background: var(--brand-primary-soft);
    font-weight: 700;
    color: var(--auth-accent-text);
}

.auth-picker li > span:last-child {
    color: var(--text);
}

.auth-picker-name {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.auth-picker-empty {
    margin: 0;
    padding: 12px 14px;
    font-size: 13.5px;
    color: var(--text);
}

.auth-picker-empty[hidden] {
    display: none;
}

/* Password strength: client-only hint */
.auth-meter {
    display: flex;
    gap: 4px;
    margin: 8px 2px 0;
}

.auth-meter i {
    flex: 1;
    height: 5px;
    border-radius: 3px;
    background: var(--border);
}

.auth-meter.m1 i:nth-child(-n+1) { background: var(--auth-err); }
.auth-meter.m2 i:nth-child(-n+2) { background: var(--warning); }
.auth-meter.m3 i:nth-child(-n+3) { background: var(--brand-primary); }
.auth-meter.m4 i { background: var(--success); }

.auth-meter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 7px 2px 0;
}

.auth-meter-row .auth-meter {
    flex: 1;
    margin: 0;
}

.auth-meter-word {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 18px;
    font-size: 12.5px;
    line-height: 18px;
    font-weight: 600;
    color: var(--text);
    text-align: right;
}

/* Visually hidden, still in the DOM and linked through for/id */
.auth-sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Register only (scoped with :has so the shared layout and the sign-in page are untouched): compact band, tighter form */
.auth-shell:has(.auth-card--register) .auth-band {
    padding: calc(14px + env(safe-area-inset-top)) 18px 46px;
}

.auth-shell:has(.auth-card--register) .auth-band-text {
    margin-top: 10px;
}

.auth-shell:has(.auth-card--register) .auth-title {
    font-size: 24px;
}

.auth-card--register {
    margin-top: -34px;
    padding: 16px 16px 14px;
}

.auth-card--register .auth-subtitle {
    margin-bottom: 12px;
}

.auth-card--register .auth-field {
    margin-bottom: 10px;
}

.auth-card--register .auth-control input.form-control,
.auth-card--register .auth-cc,
.auth-card--register .auth-cc-fallback {
    height: 46px;
}

.auth-card--register .auth-toggle-password {
    top: 1px;
}

.auth-card--register .auth-submit {
    height: 48px;
    margin-top: 6px;
}

.auth-card--register .auth-alt-row {
    margin-top: 10px;
}

.auth-card--register .auth-alt-btn {
    min-height: 46px;
}

.auth-card--register .auth-alt-link {
    margin-top: 12px;
}

.auth-card--register .auth-sponsor {
    margin-bottom: 12px;
    padding: 8px 12px;
}

@media (min-width: 760px) {
    /* Fits 1366x768 (about 640px of viewport) without scrolling when there is no captcha, still centred like the sign-in. */
    body.appkit-auth:has(.auth-card--register) {
        /* 24px page margin above and below the shell. */
        padding: 24px;
        /* --rm-u scales the extra breathing room with the viewport height: 1px at 640px tall or more, 0 at 560px or less, so a short window
           falls back to the compact spacing instead of scrolling. At 1366x768 (about 640px of viewport) the shell grows by about 54px. */
        --rm-u: calc(clamp(0px, calc(100vh - 560px), 80px) / 80);
    }

    .auth-card--register {
        padding: calc(16px + var(--rm-u) * 6) 16px calc(14px + var(--rm-u) * 6);
    }

    .auth-card--register .auth-subtitle {
        margin-bottom: calc(12px + var(--rm-u) * 6);
    }

    .auth-card--register .auth-field {
        margin-bottom: calc(10px + var(--rm-u) * 5);
    }

    .auth-card--register .auth-meter-row {
        margin: calc(7px + var(--rm-u) * 2) 2px calc(var(--rm-u) * 2);
    }

    .auth-card--register .auth-submit {
        margin-top: calc(6px + var(--rm-u) * 6);
    }

    .auth-card--register .auth-alt-row {
        margin-top: calc(10px + var(--rm-u) * 3);
    }

    .auth-card--register .auth-alt-link {
        margin-top: calc(12px + var(--rm-u) * 3);
    }

    .auth-shell:has(.auth-card--register) {
        min-height: 0;
    }

    .auth-shell:has(.auth-card--register) .auth-band {
        padding: 40px;
    }

    .auth-shell:has(.auth-card--register) .auth-title {
        font-size: 36px;
    }

    .auth-shell:has(.auth-card--register) .auth-main {
        padding: 18px 28px;
    }

    .auth-card--register {
        margin: 0 auto;
    }

    .auth-shell:has(.auth-card--register) .auth-footer-note {
        margin-top: 10px;
    }
}

/* ---------- Forgot / reset (L4b) ---------- */
.auth-control input.form-control[readonly] {
    background: var(--page-bg);
    color: var(--text);
}

/* ---------- Verification code pages (L4c) ---------- */
.auth-sent {
    color: var(--text-strong);
    font-weight: 700;
    overflow-wrap: anywhere;
}

.auth-control input.form-control.auth-code {
    height: 60px;
    padding: 0 14px;
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: .5em;
    text-indent: .5em;
    font-variant-numeric: tabular-nums;
}

.auth-control input.form-control.auth-code::placeholder {
    color: var(--border-strong);
    font-weight: 400;
}

.auth-resend-note {
    margin: 14px 0 0;
}

.auth-resend {
    line-height: 1.5;
}

.auth-resend-hint {
    display: block;
    margin-top: 2px;
    font-size: 12.5px;
}

.auth-signout {
    margin: 14px 0 0;
    text-align: center;
}

.auth-link-btn {
    padding: 8px 12px;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    text-decoration: underline;
    cursor: pointer;
}

.auth-link-btn:hover {
    color: var(--text-strong);
}

/* Dark-mode logo (AppkitLogo::dark()): the band is an accent gradient in both themes, so the light-ink logo replaces the white chip. No dark logo = no --duo class = the chip above. */
.auth-brand--duo { padding: 0; background: transparent; }
.auth-brand--duo .auth-lg-light { display: none; }
.auth-brand--duo .auth-lg-dark { display: block; height: 48px; max-height: 48px; max-width: 220px; width: auto; }
