*,
*::before,
*::after {
    box-sizing: border-box;
}

button,
input,
select,
textarea {
    font: inherit;
}

html,
body {
    height: initial;
}

body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    background-color: var(--ds-surface, #ffffff);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Ubuntu', sans-serif;
    color: var(--ds-text, #172b4d);

    > .container {
        display: flex;
        flex-direction: column;
        width: 95%;
        max-width: 400px;
        margin: 10vh auto 0;

        @media (min-width: 576px) {
            width: 400px;
            margin-block-start: 20vh;
        }
    }

    &:has(#mobile-top-bar) {
        padding-top: 0;
    }
}

a {
    text-decoration: underline;
    color: var(--ds-link, #1868db);

    &:visited {
        color: var(--ds-link-visited, #803fa5);
    }

    &:hover {
        text-decoration: none;
    }

    &:active {
        color: var(--ds-link-pressed, #1558bc);
    }

    &:focus-visible {
        outline: 2px solid var(--ds-border-focused, #2684ff);
        outline-offset: 2px;
    }
}

main {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 32px 40px;
    border-radius: 8px;
    background-color: var(--ds-surface-overlay, #fff);
    color: var(--ds-text, #292a2e);

    @media (min-width: 576px) {
        box-shadow: var(--ds-shadow-overlay, 0 8px 9pt #1e1f2126, 0 0 1px #1e1f214f);
    }
}

.main-header {
    display: flex;
    justify-content: center;
    margin-bottom: 0;
    font-weight: 650;
    color: var(--ds-text, #292a2e);

    h1 {
        font-size: 24px;
    }
}

.auth-message {
    flex-direction: column;
    align-items: center;
    justify-content: initial;
    gap: 12px;
    font-weight: 400;
    text-align: center;

    p {
        margin: 0;
    }
}

h3 {
    margin: 5px;
    font-size: 16px;
    font-weight: 400;
    color: var(--ds-text-subtle, #505258);
}

.form-message-success {
    color: var(--ds-text-success, #4c6b1f);
}

.form-message-error {
    color: var(--ds-text-danger, #ae2e24);
}

.form-message {
    max-width: 320px;
    margin-inline: auto;
    text-align: center;

    ul {
        text-align: start;
    }
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 10px 0;

    .form-label {
        font-size: 12px;
        font-weight: 650;
        line-height: 16px;
        color: var(--ds-text-subtle, #505258);
    }

    .form-hint {
        font-size: 12px;
        line-height: 16px;
        color: var(--ds-text-subtle, #505258);
    }

    .form-control {
        display: flex;
        align-items: center;
        height: 40px;
        border: var(--ds-border-width, 1px) solid var(--ds-border-input, #8c8f97);
        border-radius: 6px;
        background-color: var(--ds-background-input, #fff);

        &:hover {
            border-color: var(--ds-border-input, #8c8f97);
            background-color: var(--ds-background-input-hovered, #f8f8f8);
        }

        &:has(input:user-invalid) {
            border-color: var(--ds-border-danger, #e2483d);
            box-shadow: inset 0 0 0 var(--ds-border-width, 1px) var(--ds-border-danger, #e2483d);
        }

        &:has(input:focus) {
            border-color: var(--ds-border-focused, #4688ec);
            background-color: var(--ds-background-input-pressed, #fff);
            box-shadow: inset 0 0 0 var(--ds-border-width, 1px) var(--ds-border-focused, #4688ec);
        }
    }

    .form-input {
        flex: 1;
        min-width: 0;
        height: 36px;
        margin: 0;
        padding-block: 8px;
        padding-inline: 6px;
        border: none;
        border-radius: 6px;
        background-color: transparent;
        font-size: 14px;
        font-weight: 400;
        line-height: 20px;
        color: var(--ds-text, #292a2e);
        outline: none;
    }

    .password-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: none;
        height: 36px;
        padding-inline: 8px;
        border: none;
        border-radius: 6px;
        background-color: transparent;
        color: var(--ds-text-subtle, #505258);
        cursor: pointer;

        &:hover {
            color: var(--ds-text, #292a2e);
        }

        &:focus-visible {
            outline: 2px solid var(--ds-border-focused, #2684ff);
            outline-offset: -2px;
        }

        .password-toggle-show,
        .password-toggle-hide {
            display: flex;
            width: 20px;
            height: 20px;
        }

        .password-toggle-hide {
            display: none;
        }

        &.is-visible {
            .password-toggle-show {
                display: none;
            }

            .password-toggle-hide {
                display: flex;
            }
        }
    }

    .form-error {
        display: none;
        align-items: center;
        gap: 4px;
        font-size: 12px;
        line-height: 16px;
        color: var(--ds-text-danger, #ae2e24);

        svg {
            flex: none;
        }
    }

    &:has(input:user-invalid) .form-error {
        display: flex;
    }

    &.form-invalid {
        .form-control {
            border-color: var(--ds-border-danger, #e2483d);
            box-shadow: inset 0 0 0 var(--ds-border-width, 1px) var(--ds-border-danger, #e2483d);
        }

        .form-error {
            display: flex;
        }
    }
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;

    .radio-option {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 16px;
        cursor: pointer;

        input[type='radio'] {
            margin: 0;
        }
    }
}

.form-actions {
    display: flex;
    flex-direction: column-reverse;
    justify-content: center;
    margin-top: 24px;

    a:not(.primary) {
        color: var(--ds-text-subtle, #505258);
    }
}

.submit-alternative {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    margin-top: 24px;
    padding-top: 24px;
    border-block-start: 1px solid var(--ds-border, #0b120e24);

    a:not(.primary) {
        color: var(--ds-text-subtle, #505258);
    }
}

.if-column-reverse {
    margin-bottom: 10px;
}

.if-column {
    display: inline-flex;
    justify-content: center;
}

.auth-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 24px;
    padding: 16px;
    border-block-start: 1px solid var(--ds-border, #0b120e24);
    font-size: 14px;
    line-height: 20px;
    color: var(--ds-text-subtle, #505258);
}

@media (min-width: 576px) {
    .container.container-wide {
        width: 475px;
    }
}
