/*
 * The sign-in card (spec §7.6, approved mockup login.html, option A): one raised card
 * centred on the LEADSC brand gradient (navy into blue), the guide's half-disc pattern
 * behind it, and a one-line footer.
 * The standalone pages outside the shell load it through theme_head (['auth' => true]):
 * sign-in, the location step, OTP, maintenance and the error pages. Controls keep their
 * Metronic classes (form-control, btn btn-primary), which components.css already sizes.
 */

.ui-auth {
    position: relative;
    min-height: 100vh;
    /* Metronic's body is a full-height flex column: without this the page shrinks to the
       viewport, and a card taller than the screen is clipped with no way to scroll. */
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 32px 16px 24px;
    background: var(--ui-brand-gradient);
    color: var(--ui-text);
    font-family: var(--ui-font);
    overflow: hidden;
}

/*
 * The brand pattern behind the card (guide §05): the half-disc tile as a mask, so its
 * colour is a token. Strongest at the inline start, fading out before it reaches the card.
 * Decoration only.
 */
.ui-auth__deco {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: var(--ui-on-fill);
    opacity: 0.08;
    -webkit-mask-image: url('../../media/brand/leadsc-pattern.svg'), linear-gradient(to left, var(--ui-on-fill), transparent 70%);
    mask-image: url('../../media/brand/leadsc-pattern.svg'), linear-gradient(to left, var(--ui-on-fill), transparent 70%);
    -webkit-mask-size: 168px 168px, 100% 100%;
    mask-size: 168px 168px, 100% 100%;
    -webkit-mask-repeat: repeat, no-repeat;
    mask-repeat: repeat, no-repeat;
    -webkit-mask-composite: source-in;
    mask-composite: intersect;
}

[dir="ltr"] .ui-auth__deco {
    -webkit-mask-image: url('../../media/brand/leadsc-pattern.svg'), linear-gradient(to right, var(--ui-on-fill), transparent 70%);
    mask-image: url('../../media/brand/leadsc-pattern.svg'), linear-gradient(to right, var(--ui-on-fill), transparent 70%);
}

.ui-auth__card {
    position: relative;
    width: 100%;
    max-width: 420px;
    padding: 32px 36px 28px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-r-lg);
    background: var(--ui-raised);
    box-shadow: var(--ui-sh-md);
}

.ui-auth__card--wide {
    max-width: 480px;
}

.ui-auth__logo {
    display: block;
    height: 38px;
    max-width: 180px;
    margin: 0 auto 22px;
    object-fit: contain;
}

/* Dark: the navy logo would vanish on the dark card — a light mark, as the shell's logo is. */
[data-bs-theme="dark"] .ui-auth__logo {
    filter: brightness(0) invert(1) opacity(.9);
}

/* A round icon tile above the title (OTP, maintenance, errors), in a tone's soft fill and ink. */
.ui-auth__icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--ui-tone-primary-soft);
    color: var(--ui-tone-primary-ink);
    font-size: 22px;
}

.ui-auth__icon--success { background: var(--ui-tone-success-soft); color: var(--ui-tone-success-ink); }
.ui-auth__icon--warning { background: var(--ui-tone-warning-soft); color: var(--ui-tone-warning-ink); }
.ui-auth__icon--danger { background: var(--ui-tone-danger-soft); color: var(--ui-tone-danger-ink); }

/* Metronic also sizes every icon 1rem; the tile's glyph takes the tile's size. */
.ui-auth__icon i { font-size: inherit; }

/* Metronic colours every Font Awesome icon --bs-text-muted (style.bundle:
   i[class*=" fa-"]); icons inside these components take their component's colour. */
.ui-auth__icon i,
.ui-auth__btn i,
.ui-auth__toggle i,
.ui-auth__alert i,
.ui-auth__disclosure i,
.ui-auth__foot i { color: inherit; }

/* An HTTP status number above an error page's title (404, 403). */
.ui-auth__status {
    margin: 0 0 6px;
    color: var(--ui-text-2);
    font-size: 44px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
}

.ui-auth__title {
    margin: 0 0 6px;
    color: var(--ui-text);
    font-size: 24px;
    font-weight: 600;
    text-align: center;
}

.ui-auth__lead {
    margin: 0 0 24px;
    color: var(--ui-text-2);
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
}

.ui-auth__field {
    margin-bottom: 16px;
}

.ui-auth__label {
    display: block;
    margin-bottom: 6px;
    color: var(--ui-text);
    font-size: 14px;
    font-weight: 500;
}

/* A 40px field with a leading icon and, for a password, a trailing show/hide toggle. */
.ui-auth__input {
    position: relative;
}

.ui-auth__input > i {
    position: absolute;
    top: 50%;
    inset-inline-start: 12px;
    transform: translateY(-50%);
    color: var(--ui-text-2);
    pointer-events: none;
}

.ui-auth__input .form-control {
    height: 40px;
    padding-block: 0;
    padding-inline: 38px 12px;
    font-size: 14px;
}

.ui-auth__input--toggle .form-control {
    padding-inline-end: 40px;
}

.ui-auth__toggle {
    position: absolute;
    top: 50%;
    inset-inline-end: 6px;
    transform: translateY(-50%);
    padding: 4px 6px;
    border: 0;
    background: transparent;
    color: var(--ui-text-2);
    cursor: pointer;
}

.ui-auth__toggle:hover { color: var(--ui-text); }

.ui-auth__btn.btn {
    width: 100%;
    height: 40px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 15px;
}

/* The loading state: scripts set data-kt-indicator="on"; the progress span carries an inline display:none. */
.ui-auth__btn[data-kt-indicator="on"] > .indicator-progress {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Messages above a form: a tone's soft fill, its ink, and a quiet border. */
.ui-auth__alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px 14px;
    border: 1px solid color-mix(in srgb, var(--ui-tone-danger-bg) 30%, var(--ui-panel));
    border-radius: var(--ui-r-md);
    background: var(--ui-tone-danger-soft);
    color: var(--ui-tone-danger-ink);
    font-size: 13px;
    line-height: 1.6;
}

.ui-auth__alert--warning {
    border-color: color-mix(in srgb, var(--ui-tone-warning-bg) 40%, var(--ui-panel));
    background: var(--ui-tone-warning-soft);
    color: var(--ui-tone-warning-ink);
}

.ui-auth__alert i { margin-top: 3px; }

/* The collapsible "more" row under a form. */
.ui-auth__disclosure {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 22px;
    padding: 4px;
    border: 0;
    background: transparent;
    color: var(--ui-text-2);
    font-size: 13px;
    cursor: pointer;
}

.ui-auth__disclosure:hover { color: var(--ui-text); }

/* Only the chevron is small; the leading icon matches the text. */
.ui-auth__disclosure .toggle-icon { font-size: 10px; }

/* A secondary action under the main button (OTP, errors). */
.ui-auth__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.ui-auth__link {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ui-link);
    font-weight: 500;
    text-decoration: none;
}

.ui-auth__link:hover { text-decoration: underline; }

/* Said instead of a link when the action behind it is off — e.g. no reset by email. */
.ui-auth__hint {
    color: var(--ui-text-2);
    font-weight: 500;
}

/* R-01 — "forgot your password?" under the password field, and a form's own spacing
   on the account pages (a <form> sits where the fields sit on the sign-in). */
.ui-auth__forgot {
    display: flex;
    justify-content: flex-end;
    margin: -4px 0 12px;
    font-size: 13px;
}

.ui-auth__card form {
    display: flex;
    flex-direction: column;
}

.ui-auth__link:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    text-decoration: none;
}

/* The card's bare buttons (no border, no fill) show a ring when focused from the keyboard. */
.ui-auth__toggle:focus-visible,
.ui-auth__disclosure:focus-visible,
.ui-auth__link:focus-visible {
    outline: 2px solid var(--ui-primary);
    outline-offset: 2px;
    border-radius: var(--ui-r-sm);
}

.ui-auth__back {
    display: block;
    margin-top: 10px;
    color: var(--ui-text-2);
    font-size: 13px;
    text-align: center;
    text-decoration: none;
}

.ui-auth__back:hover { color: var(--ui-text); text-decoration: underline; }

/* The six one-character OTP boxes, always left to right. */
.ui-auth__code {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 18px 0 14px;
    direction: ltr;
}

/* Below 360px the six boxes shrink together, so the row stays inside the card. */
.ui-auth__code .form-control {
    flex: 0 1 42px;
    min-width: 0;
    width: 42px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    font-size: 20px;
    font-weight: 500;
    text-align: center;
}

/* A start/end pair of small facts (maintenance window). */
.ui-auth__facts {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.ui-auth__facts span {
    padding: 6px 10px;
    border: 1px solid var(--ui-border-soft);
    border-radius: var(--ui-r-sm);
    background: var(--ui-sunken);
    color: var(--ui-text);
    font-size: 12px;
}

/* The footer sits on the brand gradient, not on a panel: the on-fill white, softened. */
.ui-auth__foot {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: color-mix(in srgb, var(--ui-on-fill) 82%, transparent);
    font-size: 12px;
    text-align: center;
}

.ui-auth__foot a {
    color: inherit;
    text-decoration: none;
}

.ui-auth__foot a:hover { text-decoration: underline; }

@media (max-width: 575.98px) {
    .ui-auth__card {
        padding: 24px 20px 20px;
    }
}

/*
 * Motion on the sign-in page: the page root carries .ui-auth--motion, and login.js adds the
 * state classes (is-shaking on the card, is-open on a reveal, is-leaving on the root).
 * Every movement here is vertical or symmetric, so none needs a [dir="ltr"] twin.
 */

/* The page opens: the card rises, then its rows follow in a short stagger. */
.ui-auth--motion .ui-auth__card {
    animation: ui-auth-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.ui-auth--motion .ui-auth__card > * {
    animation: ui-auth-row 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.08s backwards;
}

.ui-auth--motion .ui-auth__card > :nth-child(n+4) { animation-delay: 0.14s; }
.ui-auth--motion .ui-auth__card > :nth-child(n+6) { animation-delay: 0.2s; }
.ui-auth--motion .ui-auth__card > :nth-child(n+9) { animation-delay: 0.26s; }

/* A refused sign-in: the card shakes once. The rise stays first in the list, so adding
   the shake never replays it. */
.ui-auth--motion .ui-auth__card.is-shaking {
    animation-name: ui-auth-rise, ui-auth-shake;
    animation-duration: 0.5s, 0.42s;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1), ease-in-out;
    animation-delay: 0s, 0s;
    animation-fill-mode: backwards, none;
}

/* A focused field: the ring fades in and the leading icon takes the link colour. */
.ui-auth--motion .ui-auth__input .form-control {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ui-auth--motion .ui-auth__input > i {
    transition: color 0.2s ease;
}

.ui-auth--motion .ui-auth__input:focus-within > i {
    color: var(--ui-link);
}

.ui-auth--motion .ui-auth__btn.btn {
    transition: background-color 0.2s ease, transform 0.12s ease;
}

.ui-auth--motion .ui-auth__btn.btn:active:not(:disabled) {
    transform: scale(0.98);
}

/* The wait: four small diamonds, the shapes of the LEADSC mark, pulsing in turn. */
.ui-auth__dots {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-inline-start: 4px;
}

.ui-auth__dots span {
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: currentColor;
    transform: rotate(45deg);
    animation: ui-auth-pulse 1s ease-in-out infinite;
}

/* The welcome's own diamonds wait until it is on screen. */
.ui-auth:not(.is-leaving) .ui-auth__welcome .ui-auth__dots span {
    animation-play-state: paused;
}

.ui-auth__dots span:nth-child(2) { animation-delay: 0.15s; }
.ui-auth__dots span:nth-child(3) { animation-delay: 0.3s; }
.ui-auth__dots span:nth-child(4) { animation-delay: 0.45s; }

/* A block that opens and closes by height: the live message above the button, and the
   disclosure's content. Closed, it is out of the tab order and unseen by a screen reader. */
.ui-auth__reveal {
    display: grid;
    grid-template-rows: 0fr;
    visibility: hidden;
    transition: grid-template-rows 0.3s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.3s;
}

.ui-auth__reveal.is-open {
    grid-template-rows: 1fr;
    visibility: visible;
    transition: grid-template-rows 0.3s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s;
}

.ui-auth__reveal > * {
    min-height: 0;
    overflow: hidden;
}

.ui-auth__reveal .ui-auth__alert {
    margin: 2px 0 8px;
}

.ui-auth__disclosure .toggle-icon {
    transition: transform 0.25s ease;
}

.ui-auth__disclosure[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

/* Signed in: the card lifts away and the mark takes the screen until the platform opens. */
.ui-auth__welcome {
    position: fixed;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    color: var(--ui-on-fill);
    text-align: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}

.ui-auth.is-leaving .ui-auth__welcome {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.35s ease 0.18s, visibility 0s;
}

.ui-auth.is-leaving .ui-auth__card,
.ui-auth.is-leaving .ui-auth__foot {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.ui-auth.is-leaving .ui-auth__card {
    transform: translateY(-14px) scale(0.98);
}

.ui-auth__welcome-mark {
    width: 76px;
    height: auto;
    margin-bottom: 10px;
}

.ui-auth__welcome-mark path {
    fill: currentColor;
    transform-box: fill-box;
    transform-origin: center;
}

.ui-auth.is-leaving .ui-auth__welcome-mark path {
    animation: ui-auth-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s backwards;
}

.ui-auth.is-leaving .ui-auth__welcome-mark path:nth-child(2) { animation-delay: 0.28s; }
.ui-auth.is-leaving .ui-auth__welcome-mark path:nth-child(3) { animation-delay: 0.36s; }
.ui-auth.is-leaving .ui-auth__welcome-mark path:nth-child(4) { animation-delay: 0.44s; }

.ui-auth__welcome-title {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
}

.ui-auth__welcome-text {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    color: color-mix(in srgb, var(--ui-on-fill) 82%, transparent);
    font-size: 14px;
    line-height: 1.7;
}

@keyframes ui-auth-rise {
    from { opacity: 0; transform: translateY(14px); }
}

@keyframes ui-auth-row {
    from { opacity: 0; transform: translateY(8px); }
}

@keyframes ui-auth-shake {
    20% { transform: translateX(-7px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@keyframes ui-auth-pulse {
    0%, 100% { opacity: 0.35; transform: rotate(45deg) scale(0.8); }
    50% { opacity: 1; transform: rotate(45deg) scale(1); }
}

@keyframes ui-auth-pop {
    from { opacity: 0; transform: scale(0); }
}

/* Reduced motion: every state still changes, at once. */
@media (prefers-reduced-motion: reduce) {
    .ui-auth--motion,
    .ui-auth--motion * {
        animation: none !important;
        transition: none !important;
    }
}
