/* The sign-in pages (auth/: Login, ForgotPassword, ResetPassword, Welcome) and their shared components
   (AuthHeading, BackLink, EmailField, PasswordField, NewPasswordFields), styled to the "Sign in" mockups.
   Plain inputs (Blazor's InputText) rather than MudTextField, because they post as normal HTML form fields on a
   static SSR page. Each page wraps its content in .auth-form. Colours come from the MudBlazor theme variables. */

.auth-form {
    --auth-radius: 12px;
    --auth-control-height: 52px;    /* fields and buttons: comfortable touch targets */
    --auth-brand-soft: color-mix(in srgb, var(--mud-palette-primary) 7%, var(--mud-palette-surface));
    --auth-success-soft: color-mix(in srgb, var(--mud-palette-success) 14%, var(--mud-palette-surface));
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.auth-form form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Heading block (AuthHeading): optional icon tile, title, explanation */
.auth-heading {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-heading h1 {
    margin: 0;
    font-size: 1.625rem;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--mud-palette-text-primary);
}

.auth-heading p {
    margin: 0;
    font-size: .9375rem;
    line-height: 1.55;
    color: var(--mud-palette-text-secondary);
}

.auth-heading strong {
    color: var(--mud-palette-text-primary);
    overflow-wrap: anywhere;        /* long email addresses wrap instead of widening the page */
}

.auth-tile {
    width: 56px;
    height: 56px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    color: var(--mud-palette-primary);
    background: var(--auth-brand-soft);
}

.auth-tile-success {
    color: var(--mud-palette-success);
    background: var(--auth-success-soft);
}

@media (min-width: 960px) {
    .auth-heading h1 {
        font-size: 1.875rem;
        font-weight: 700;
    }
}

/* "‹ Back" link (BackLink). Prefixed with .auth-form so it beats the red ".auth-form a" link colour below */
.auth-form .back-link {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    margin: -8px 0 -8px -6px;       /* line the chevron up with the content edge */
    padding: 0 10px 0 4px;
    border-radius: 10px;
    font-size: .875rem;
    font-weight: 600;
    color: var(--mud-palette-text-secondary);
    text-decoration: none;
}

.auth-form .back-link:hover {
    color: var(--mud-palette-text-primary);
    background: var(--mud-palette-action-default-hover);
}

/* Fields */
.auth-form .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-form .field-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.auth-form .field label {
    font-size: .875rem;
    font-weight: 600;
    color: var(--mud-palette-text-primary);
}

.auth-form a,
.auth-form .field-link {
    font-weight: 600;
    color: var(--mud-palette-primary);
}

.auth-form .field-link {
    font-size: .875rem;
}

.auth-form .input {
    width: 100%;
    height: var(--auth-control-height);
    padding: 0 14px;
    font: inherit;
    font-size: 1rem;                /* 16px or more stops iOS zooming in on focus */
    color: var(--mud-palette-text-primary);
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: var(--auth-radius);
    box-sizing: border-box;
}

.auth-form .input::placeholder {
    color: var(--mud-palette-text-secondary);
    opacity: .7;
}

.auth-form .input:focus {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 1px;
    border-color: var(--mud-palette-primary);
}

/* Blazor adds .invalid to a field that failed validation (overrides the template outline in app.css) */
.auth-form .input.invalid {
    outline: none;
    border-color: var(--mud-palette-error);
}

.auth-form .input.invalid:focus {
    outline: 2px solid var(--mud-palette-error);
}

.auth-form .validation-message {
    font-size: .8125rem;
    color: var(--mud-palette-error);
}

/* Input with an icon inside its left edge (envelope, padlock) */
.auth-form .input-wrap {
    position: relative;
}

.auth-form .input-wrap .input {
    padding-left: 44px;
}

.auth-form .input-wrap .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--mud-palette-text-secondary);
    pointer-events: none;           /* clicks go through to the input */
}

/* Password: also the show/hide button inside the right-hand edge */
.auth-form .password-wrap .input {
    padding-right: 52px;
}

.auth-form .password-toggle {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: var(--mud-palette-text-secondary);
    background: none;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.auth-form .password-toggle:hover {
    color: var(--mud-palette-text-primary);
}

.auth-form .password-toggle:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
}

/* One eye icon at a time: "show" while hidden, "hide" while showing */
.auth-form .password-toggle .icon-hide,
.auth-form .password-toggle[aria-pressed="true"] .icon-show {
    display: none;
}

.auth-form .password-toggle[aria-pressed="true"] .icon-hide {
    display: inline-block;
}

/* The big centred code box on the code step */
.auth-form .code-input {
    height: 64px;
    padding: 0 0 0 .5em;            /* balances the letter spacing after the last digit */
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: .5em;
    text-align: center;
}

/* New password rules checklist; JavaScript adds .met as each is satisfied */
.auth-form .password-rules {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: .8125rem;
    color: var(--mud-palette-text-secondary);
}

.auth-form .password-rules li,
.auth-form .password-match {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
}

.auth-form .password-rules li::before,
.auth-form .password-match::before {
    content: "○";
    width: 1em;
    text-align: center;
}

.auth-form .password-rules li.met,
.auth-form .password-match.met {
    color: var(--mud-palette-success);
}

.auth-form .password-rules li.met::before,
.auth-form .password-match.met::before {
    content: "✓";
}

.auth-form .password-match {
    margin: 0;
    font-size: .8125rem;
    color: var(--mud-palette-text-secondary);
}

.auth-form .password-match[hidden] {
    display: none;
}

/* Tick boxes: welcome page agreement, "trust this device" */
.auth-form .checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    font-size: .875rem;
    cursor: pointer;
}

.auth-form .checkbox input {
    flex: none;
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--mud-palette-primary);
}

/* Welcome page: the user agreement opens in place (<details>) */
.auth-form .agreement {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--auth-radius);
    background: var(--mud-palette-surface);
}

.auth-form .agreement summary {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-size: .875rem;
    font-weight: 600;
    color: var(--mud-palette-primary);
    cursor: pointer;
}

.auth-form .agreement-text {
    max-height: 320px;              /* long agreements scroll inside the box */
    overflow-y: auto;
    padding: 0 14px 14px;
    font-size: .875rem;
    color: var(--mud-palette-text-primary);
}

/* Buttons: MudButton with Class="auth-btn" (filled red) or "auth-btn auth-btn-secondary" (white, outlined).
   Three classes so these win over MudBlazor's own button styles. */
.auth-form .mud-button-root.auth-btn {
    width: 100%;
    height: var(--auth-control-height);
    border-radius: var(--auth-radius);
    font-size: 1rem;
    font-weight: 700;
    box-shadow: none;
}

.auth-form .mud-button-root.auth-btn-secondary {
    color: var(--mud-palette-text-primary);
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-inputs);
}

.auth-form .mud-button-root.auth-btn-secondary:hover {
    background: var(--mud-palette-action-default-hover);
}

/* Small grey text under a form, e.g. "No account yet?" */
.auth-note {
    margin: 0;
    font-size: .8125rem;
    line-height: 1.5;
    color: var(--mud-palette-text-secondary);
}

/* "Didn't get it? Resend code" row on the code step */
.resend-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    font-size: .875rem;
    color: var(--mud-palette-text-secondary);
}

.resend-row form {
    display: contents;              /* the form is just a wrapper for the button */
}

.link-button {
    min-height: 44px;
    padding: 0 8px;
    font: inherit;
    font-weight: 700;
    color: var(--mud-palette-primary);
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.link-button:hover {
    text-decoration: underline;
}

.link-button[hidden] {
    display: none;
}
