/*
Copyright 2019, 2020 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

.mx_InviteDialog_transferWrapper .mx_Dialog {
    padding-bottom: 16px;
}

.mx_InviteDialog_addressBar {
    display: flex;
    flex-direction: row;
    // Right margin for the design. We could apply this to the whole dialog, but then the scrollbar
    // for the user section gets weird.
    margin: 8px 45px 0 0;

    .mx_InviteDialog_editor {
        flex: 1;
        width: 100%; // Needed to make the Field inside grow
        background-color: $user-tile-hover-bg-color;
        border-radius: 4px;
        min-height: 25px;
        padding-left: 8px;
        overflow-x: hidden;
        overflow-y: auto;
        display: flex;
        flex-wrap: wrap;

        .mx_InviteDialog_userTile {
            margin: 6px 6px 0 0;
            display: inline-block;
            min-width: max-content; // prevent manipulation by flexbox
        }

        // Mostly copied from AddressPickerDialog; overrides bunch of our default text input styles
        > input[type="text"] {
            margin: 6px 0 !important;
            height: 24px;
            line-height: $font-24px;
            font-size: $font-14px;
            padding-left: 12px;
            border: 0 !important;
            outline: 0 !important;
            resize: none;
            box-sizing: border-box;
            min-width: 40%;
            flex: 1 !important;
            color: $primary-content !important;
        }
    }

    .mx_InviteDialog_goButton {
        min-width: 48px;
        margin-left: 10px;
        height: 25px;
        line-height: $font-25px;
    }

    .mx_InviteDialog_buttonAndSpinner {
        .mx_Spinner {
            // Width and height are required to trick the layout engine.
            width: 20px;
            height: 20px;
            margin-left: 5px;
            display: inline-block;
            vertical-align: middle;
        }
    }
}

.mx_InviteDialog_section {
    padding-bottom: 4px;

    h3 {
        font-size: $font-12px;
        color: $muted-fg-color;
        font-weight: bold;
        text-transform: uppercase;
    }

    > p {
        margin: 0;
    }

    > span {
        color: $primary-content;
    }

    .mx_InviteDialog_subname {
        margin-bottom: 10px;
        margin-top: -10px; // HACK: Positioning with margins is bad
        font-size: $font-12px;
        color: $muted-fg-color;
    }
}

.mx_InviteDialog_section_hidden_suggestions_disclaimer {
    padding: 8px 0 16px 0;
    font-size: $font-14px;

    > span {
        color: $primary-content;
        font-weight: 600;
    }

    > p {
        margin: 0;
    }
}

.mx_InviteDialog_footer {
    border-top: 1px solid $input-border-color;

    > h3 {
        margin: 12px 0;
        font-size: $font-12px;
        color: $muted-fg-color;
        font-weight: bold;
        text-transform: uppercase;
    }

    .mx_InviteDialog_footer_link {
        display: flex;
        justify-content: space-between;
        border-radius: 4px;
        border: solid 1px $light-fg-color;
        padding: 8px;

        > a {
            text-decoration: none;
            flex-shrink: 1;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    }

    .mx_InviteDialog_footer_link_copy {
        flex-shrink: 0;
        cursor: pointer;
        margin-left: 20px;
        display: inherit;

        > div {
            mask-image: url($copy-button-url);
            background-color: $message-action-bar-fg-color;
            margin-left: 5px;
            width: 20px;
            height: 20px;
            background-repeat: no-repeat;
        }
    }
}

.mx_InviteDialog_roomTile {
    cursor: pointer;
    padding: 5px 10px;

    &:hover {
        background-color: $user-tile-hover-bg-color;
        border-radius: 4px;
    }

    * {
        vertical-align: middle;
    }

    .mx_InviteDialog_roomTile_avatarStack {
        display: inline-block;
        position: relative;
        width: 36px;
        height: 36px;

        & > * {
            position: absolute;
            top: 0;
            left: 0;
        }
    }

    .mx_InviteDialog_roomTile_selected {
        width: 36px;
        height: 36px;
        border-radius: 36px;
        background-color: $username-variant1-color;
        display: inline-block;
        position: relative;

        &::before {
            content: "";
            width: 24px;
            height: 24px;
            grid-column: 1;
            grid-row: 1;
            mask-image: url("$(res)/img/feather-customised/check.svg");
            mask-size: 100%;
            mask-repeat: no-repeat;
            position: absolute;
            top: 6px; // 50%
            left: 6px; // 50%
            background-color: #ffffff; // this is fine without a var because it's for both themes
        }
    }

    .mx_InviteDialog_roomTile_nameStack {
        display: inline-block;
        overflow: hidden;
    }

    .mx_InviteDialog_roomTile_name {
        font-weight: 600;
        font-size: $font-14px;
        color: $primary-content;
        margin-left: 7px;
    }

    .mx_InviteDialog_roomTile_userId {
        font-size: $font-12px;
        color: $muted-fg-color;
        margin-left: 7px;
    }

    .mx_InviteDialog_roomTile_name,
    .mx_InviteDialog_roomTile_userId {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mx_InviteDialog_roomTile_time {
        text-align: right;
        font-size: $font-12px;
        color: $muted-fg-color;
        float: right;
        line-height: $font-36px; // Height of the avatar to keep the time vertically aligned
    }

    .mx_InviteDialog_roomTile_highlight {
        font-weight: 900;
    }
}

// Many of these styles are stolen from mx_UserPill, but adjusted for the invite dialog.
.mx_InviteDialog_userTile {
    margin-right: 8px;

    .mx_InviteDialog_userTile_pill {
        background-color: $username-variant1-color;
        border-radius: 12px;
        display: inline-block;
        height: 24px;
        line-height: $font-24px;
        padding-left: 8px;
        padding-right: 8px;
        color: #ffffff; // this is fine without a var because it's for both themes

        .mx_InviteDialog_userTile_avatar {
            border-radius: 20px;
            position: relative;
            left: -5px;
            top: 2px;
        }

        img.mx_InviteDialog_userTile_avatar {
            vertical-align: top;
        }

        .mx_InviteDialog_userTile_name {
            vertical-align: top;
        }

        .mx_InviteDialog_userTile_threepidAvatar {
            background-color: #ffffff; // this is fine without a var because it's for both themes
        }
    }

    .mx_InviteDialog_userTile_remove {
        display: inline-block;
        margin-left: 4px;
    }
}

.mx_InviteDialog_other {
    // Prevent the dialog from jumping around randomly when elements change.
    height: 600px;
    padding-left: 20px; // the design wants some padding on the left

    .mx_InviteDialog_userSections {
        height: calc(100% - 115px); // mx_InviteDialog's height minus some for the upper and lower elements
    }
}

.mx_InviteDialog_content {
    height: calc(100% - 36px); // full height minus the size of the header
    overflow: hidden;
}

.mx_InviteDialog_transfer {
    width: 496px;
    height: 466px;
    flex-direction: column;

    .mx_InviteDialog_content {
        flex-direction: column;

        .mx_TabbedView {
            height: calc(100% - 60px);
        }
        overflow: visible;
    }

    .mx_InviteDialog_addressBar {
        margin-top: 8px;
    }

    input[type="checkbox"] {
        margin-right: 8px;
    }
}

.mx_InviteDialog_userSections {
    margin-top: 4px;
    overflow-y: auto;
    padding: 0 45px 4px 0;
}

.mx_InviteDialog_hasFooter .mx_InviteDialog_userSections {
    height: calc(100% - 175px);
}

.mx_InviteDialog_helpText {
    margin: 0;
}

.mx_InviteDialog_helpText .mx_AccessibleButton_kind_link {
    padding: 0;
}

.mx_InviteDialog_dialPad .mx_InviteDialog_dialPadField {
    border-top: 0;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    margin-top: 0;
    border-color: $quaternary-content;

    input {
        font-size: 18px;
        font-weight: 600;
        padding-top: 0;
    }
}

.mx_InviteDialog_dialPad .mx_InviteDialog_dialPadField:focus-within {
    border-color: $accent-color;
}

.mx_InviteDialog_dialPadField .mx_Field_postfix {
    /* Remove border separator between postfix and field content */
    border-left: none;
}

.mx_InviteDialog_dialPad {
    width: 224px;
    margin-top: 16px;
    margin-left: auto;
    margin-right: auto;
}

.mx_InviteDialog_dialPad .mx_DialPad {
    row-gap: 16px;
    column-gap: 48px;

    margin-left: auto;
    margin-right: auto;
}

.mx_InviteDialog_transferConsultConnect {
    padding-top: 16px;
    /* This wants a drop shadow the full width of the dialog, so relative-position it
     * and make it wider, then compensate with padding
     */
    position: relative;
    width: 496px;
    left: -24px;
    padding-left: 24px;
    padding-right: 24px;
    border-top: 1px solid $message-body-panel-bg-color;

    display: flex;
    flex-direction: row;
    align-items: center;
}

.mx_InviteDialog_transferConsultConnect_pushRight {
    margin-left: auto;
}

.mx_InviteDialog_userDirectoryIcon::before {
    mask-image: url('$(res)/img/voip/tab-userdirectory.svg');
}

.mx_InviteDialog_dialPadIcon::before {
    mask-image: url('$(res)/img/voip/tab-dialpad.svg');
}

.mx_InviteDialog_multiInviterError {
    > h4 {
        font-size: $font-15px;
        line-height: $font-24px;
        color: $secondary-content;
        font-weight: normal;
    }

    > div {
        .mx_InviteDialog_multiInviterError_entry {
            margin-bottom: 24px;

            .mx_InviteDialog_multiInviterError_entry_userProfile {
                .mx_InviteDialog_multiInviterError_entry_name {
                    margin-left: 6px;
                    font-size: $font-15px;
                    line-height: $font-24px;
                    font-weight: $font-semi-bold;
                    color: $primary-content;
                }

                .mx_InviteDialog_multiInviterError_entry_userId {
                    margin-left: 6px;
                    font-size: $font-12px;
                    line-height: $font-15px;
                    color: $tertiary-content;
                }
            }

            .mx_InviteDialog_multiInviterError_entry_error {
                margin-left: 32px;
                font-size: $font-15px;
                line-height: $font-24px;
                color: $notice-primary-color;
            }
        }
    }
}
