/* Authenticator-app sign-in codes (ws21 UI): the setup key, the recovery codes, the sign-in step fields, the Profile
   panel and the Super Admin reset dialog. Loaded by the sign-in pages (inside _LoginMfaModal), the Profile page and the
   Users page. Buttons and links use the shared system in base.css (.btn-primary, .btn-secondary, .btn-plain); this file
   only lays things out. Every control keeps the 44px target from a11y.css and the shared focus ring. */

.authn-setup[hidden],
.authn-codes-panel[hidden],
.authn-qr[hidden],
.authn-field[hidden],
.authn-help[hidden],
[data-authn-hidden][hidden] {
    display: none !important;
}

.authn-setup,
.authn-codes-panel {
    display: block;
    margin: 18px 0 0;
    padding: 16px;
    border: 1px solid var(--slate-200, #e2e8f0);
    border-radius: var(--radius-md);
    background: var(--surface);
    text-align: left;
}

.authn-subheading {
    margin: 0 0 8px;
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--text-color);
}

.authn-steps {
    margin: 0 0 14px;
    padding-left: 22px;
    font-size: var(--text-base);
    line-height: 1.5;
}

.authn-steps li + li {
    margin-top: 6px;
}

.authn-facts {
    display: grid;
    gap: 12px;
    margin: 0 0 12px;
}

.authn-facts dt {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-color);
}

.authn-facts dd {
    margin: 2px 0 0;
    font-size: var(--text-base);
    overflow-wrap: anywhere;
}

/* The key is plain, selectable text (also for screen readers); groups of four wrap at the spaces. */
.authn-key,
.authn-link,
.authn-code-list li {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.authn-key {
    margin: 0 0 8px;
    padding: 10px 12px;
    border: 1px solid var(--line-input);
    border-radius: var(--radius-sm);
    background: var(--grey-100, #f3f4f6);
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: .06em;
    line-height: 1.6;
    overflow-wrap: anywhere;
    -webkit-user-select: all;
    user-select: all;
}

.authn-link {
    margin: 8px 0;
    padding: 10px 12px;
    border: 1px solid var(--line-input);
    border-radius: var(--radius-sm);
    background: var(--grey-100, #f3f4f6);
    font-size: var(--text-sm);
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-break: break-all;
    -webkit-user-select: all;
    user-select: all;
}

.authn-link-details {
    margin: 4px 0 12px;
}

.authn-link-title {
    margin: 12px 0 0;
    font-weight: 600;
    color: var(--blue-800);
}

/* The scannable code (qr-code.js draws an inline SVG, black on white with its own quiet zone). */
.authn-scan[hidden] {
    display: none !important;
}

.authn-scan {
    margin: 12px 0;
    text-align: center;
}

.authn-scan-heading {
    margin: 0 0 8px;
    font-weight: 600;
}

.authn-scan-code svg {
    display: block;
    width: 228px;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    border: 1px solid var(--slate-200, #e2e8f0);
}

.authn-manual > summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    color: var(--blue-800);
}

.authn-link-details summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    color: var(--blue-800);
}

.authn-help,
.authn-expiry,
.authn-note {
    margin: 6px 0 0;
    font-size: var(--text-sm);
    color: var(--ink-muted);
    line-height: 1.5;
}

.authn-expiry {
    color: var(--text-color);
}

.authn-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0 0;
}

.authn-actions > .btn-primary,
.authn-actions > .btn-secondary {
    display: inline-flex;
}

.authn-code-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    margin: 12px 0;
    padding: 0 0 0 28px;
}

.authn-code-list li {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: .05em;
    padding: 4px 0;
    -webkit-user-select: all;
    user-select: all;
}

.authn-saved {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 14px 0 0;
}

.authn-saved input[type="checkbox"] {
    flex: none;
    width: 24px;
    height: 24px;
    margin-top: 10px;
}

.authn-saved label {
    min-height: 44px;
    display: flex;
    align-items: center;
    font-size: var(--text-base);
    cursor: pointer;
}

.authn-print-only {
    display: none;
}

.authn-field {
    margin-top: 22px;
    text-align: left;
}

.authn-field .form-control {
    min-height: 44px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    letter-spacing: .06em;
}

.authn-field .form-label {
    font-weight: 600;
}

/* Sign-in step: the links row under the code field and the "low codes" and "set up" panels. */
.login-mfa-modal .authn-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 22px;
    margin-top: 10px;
}

.login-mfa-modal .authn-links[hidden],
.login-mfa-modal .login-mfa-links[hidden],
.login-mfa-modal .login-mfa-codes-view[hidden],
.login-mfa-modal .login-mfa-remaining-view[hidden],
.login-mfa-modal [data-mfa-desc][hidden],
.login-mfa-modal [data-mfa-expiry-row][hidden],
.login-mfa-modal [data-mfa-code-area][hidden] {
    display: none !important;
}

.login-mfa-modal .login-mfa-codes-view,
.login-mfa-modal .login-mfa-remaining-view {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.login-mfa-modal .login-mfa-codes-view .register-title,
.login-mfa-modal .login-mfa-remaining-view .register-title {
    text-align: center;
}

.login-mfa-modal .login-mfa-codes-view > .btn-primary,
.login-mfa-modal .login-mfa-remaining-view > .btn-primary {
    margin-top: 18px;
    width: 100%;
    justify-content: center;
}

.login-mfa-modal .modal-dialog {
    max-height: 100%;
}

.login-mfa-modal .modal-body {
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
}

/* Profile > Security panel. */
.authn-profile {
    padding: 24px 26px;
    border-radius: var(--radius-2xl);
    background: var(--grey-100);
}

.authn-profile-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
}

.authn-profile-head h3 {
    margin: 0;
    font-size: var(--text-md);
}

.authn-profile p {
    margin: 8px 0 0;
    font-size: var(--text-base);
}

.authn-profile .authn-note {
    font-size: var(--text-sm);
}

.authn-profile .authn-warning {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 10px 12px;
    border: 1px solid #fcd34d;
    border-radius: var(--radius-sm);
    background: #fffbeb;
    color: #92400e;
    font-weight: 600;
}

.authn-profile .authn-warning[hidden] {
    display: none;
}

.authn-profile-confirm {
    max-width: 360px;
    margin-top: 16px;
}

.authn-profile-confirm .form-control {
    min-height: 44px;
    font-size: 1.25rem;
    letter-spacing: .3em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.authn-profile-confirm .profile-field-error,
.authn-profile-confirm .field-error {
    display: block;
    min-height: 1.25rem;
    margin-top: 6px;
    color: var(--error-color);
    font-size: var(--text-sm);
    font-weight: 600;
}

.authn-profile .authn-message {
    min-height: 1.25rem;
    margin-top: 10px;
    font-weight: 600;
}

.authn-profile .authn-message.is-error {
    color: var(--error-color);
}

.authn-profile .authn-message.is-error::before {
    content: "! ";
}

/* Super Admin reset dialog (native <dialog>: the browser traps focus, closes on Escape and restores focus). */
.authn-reset-dialog {
    width: min(480px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 0;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 50px rgba(15, 23, 42, .35);
    color: var(--text-color);
    overflow-y: auto;
}

.authn-reset-dialog::backdrop {
    background: rgba(15, 23, 42, .55);
}

.authn-reset-form {
    display: grid;
    gap: 14px;
    padding: 22px;
}

.authn-reset-form h2 {
    margin: 0;
    font-size: 1.25rem;
}

.authn-reset-form p {
    margin: 0;
    font-size: var(--text-base);
    line-height: 1.5;
}

.authn-reset-form textarea {
    width: 100%;
    min-height: 96px;
}

.authn-reset-form .field-error,
.authn-reset-form [data-authn-reset-error] {
    min-height: 1.25rem;
    color: var(--error-color);
    font-size: var(--text-sm);
    font-weight: 600;
}

.authn-reset-form [data-authn-reset-error]:not(:empty)::before {
    content: "! ";
}

.authn-reset-form .authn-actions {
    margin: 4px 0 0;
}

.users-authn-action {
    white-space: nowrap;
}

@media (max-width: 480px) {
    .authn-code-list {
        grid-template-columns: 1fr;
    }

    .authn-setup,
    .authn-codes-panel {
        padding: 12px;
    }

    .authn-profile {
        padding: 18px 14px;
    }

    .authn-actions > .btn-primary,
    .authn-actions > .btn-secondary {
        flex: 1 1 100%;
    }

    .login-mfa-modal .modal-body {
        padding: 22px 16px;
    }
}

/* Print: only the recovery codes. The class is set on <body> by authenticator-ui.js while printing. */
@media print {
    body.authn-printing * {
        visibility: hidden !important;
    }

    body.authn-printing .modal-backdrop {
        display: none !important;
    }

    body.authn-printing .modal,
    body.authn-printing .modal-dialog,
    body.authn-printing .modal-content,
    body.authn-printing .modal-body {
        position: static !important;
        max-height: none !important;
        overflow: visible !important;
        transform: none !important;
    }

    body.authn-printing .authn-codes-panel.is-printing,
    body.authn-printing .authn-codes-panel.is-printing * {
        visibility: visible !important;
    }

    body.authn-printing .authn-codes-panel.is-printing {
        position: absolute;
        inset: 0 auto auto 0;
        width: 100%;
        border: 0;
        padding: 0;
    }

    body.authn-printing .authn-codes-panel.is-printing .authn-print-only {
        display: block;
    }

    body.authn-printing .authn-codes-panel.is-printing .authn-actions,
    body.authn-printing .authn-codes-panel.is-printing .authn-saved,
    body.authn-printing .authn-codes-panel.is-printing [data-authn-status] {
        display: none !important;
    }

    body.authn-printing .authn-code-list {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .authn-setup,
    .authn-codes-panel,
    .authn-reset-dialog {
        transition: none;
        animation: none;
    }
}

/* Copy and print feedback: the words carry the meaning; the mark is a second cue, never colour alone. */
.authn-status {
    min-height: 1.25rem;
    margin: 8px 0 0;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-color);
}

.authn-status:not(:empty)::before {
    content: "\2713\00a0";
}

.authn-status.is-error {
    color: var(--error-color);
}

.authn-status.is-error:not(:empty)::before {
    content: "!\00a0";
}

.authn-profile [hidden],
.authn-reset-dialog [hidden] {
    display: none !important;
}

.authn-facts dd > .btn-secondary,
.authn-link-details .authn-actions > a.btn-secondary {
    display: inline-flex;
}
