#conversejs {
    .chatbox-navback {
        display: none;
    }
    .flyout {
        border-radius: $chatbox-border-radius;
        position: absolute;

        @media screen and (max-height: $mobile-landscape-height) {
            border-radius: 0;
        }
        @media screen and (max-width: $mobile-portrait-length) {
            border-radius: 0;
        }

        @media screen and (max-height: $mobile-landscape-height) {
            bottom: 0;
        }
        @media screen and (max-width: $mobile-portrait-length) {
            bottom: 0;
        }
    }

    .chatbox-btn {
        border-radius: 25%;
        border: none;
        cursor: pointer;
        font-size: $chatbox-button-size;
        margin: 0 0.2em;
        padding: 0 0 0 0.5em;
        text-decoration: none;

        &:active {
            position: relative;
            top: 1px;
        }
    }

    .chat-head {
        flex-wrap: nowrap;
        color: #ffffff;
        font-size: 100%;
        margin: 0;
        padding: 0.5em;
        position: relative;

        &.chat-head-chatbox {
            background-color: $chat-head-color;
        }

        .avatar {
            height: 36px;
            width: 36px;
            margin-right: 0.5em;
        }

        .chatbox-title {
            .chatroom-description {
                font-size: 80%;
            }
        }
        .chatbox-buttons {
            flex-direction: row-reverse;
            padding: 0;
        }

        .user-custom-message {
            color: white;
            font-size: 75%;
            font-style: italic;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            margin: 0;
            padding-top: 0.2em;
        }

        a, a:visited, a:hover, a:not([href]):not([tabindex]) {
            &.chatbox-btn {
                &.fa {
                    color: white;
                    &.button-on:before {
                        padding: 0.2em;
                        background-color: $chat-head-text-color;
                        color: $chat-head-color;
                    }
                }
            }
        }

        .chatbox-btn {
            color: white;
            &.fa  {
                color: white;
            }
            &:active {
                position: relative;
                top: 1px;
            }
            &.button-on:before {
                border-radius: 5%;
                background-color: $chat-head-text-color;
                color: $chat-head-color;
            }
        }
    }

    .chatbox {
        text-align: left;
        margin: 0 $chat-gutter;

        @media screen and (max-height: $mobile-landscape-height) {
            margin: 0;
            width: $mobile-chat-width;
        }
        @media screen and (max-width: $mobile-portrait-length) {
            margin: 0;
            width: $mobile-chat-width;
        }

        .box-flyout {
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            background-color: $chat-head-color;
            box-shadow: 1px 3px 5px 3px rgba(0, 0, 0, 0.4);
            z-index: 1;
            overflow-y: scroll;
            width: 100%;

            @media screen and (max-height: $mobile-landscape-height) {
                height: $mobile-chat-height;
                width: $mobile-chat-width;
                height: 100vh;
            }
            @media screen and (max-width: $mobile-portrait-length) {
                height: $mobile-chat-height;
                width: $mobile-chat-width;
                height: 100vh;
            }
        }
        .chat-title {
            font-family: $heading-font;
            color: white;
            display: block;
            line-height: $line-height-large;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            a {
                color: $chat-head-text-color;
                width: 100%;
            }
        }
        .chat-body {
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            height: 100%;
            background-color: $chat-head-color;
            border-bottom-left-radius: $chatbox-border-radius;
            border-bottom-right-radius: $chatbox-border-radius;

            @media screen and (max-height: $mobile-landscape-height) {
                border-bottom-left-radius: 0;
                border-bottom-right-radius: 0;
            }
            @media screen and (max-width: $mobile-portrait-length) {
                border-bottom-left-radius: 0;
                border-bottom-right-radius: 0;
            }
            border-top: 0;
            p {
                color: $text-color;
                font-size: $message-font-size;
                margin: 0;
                padding: 5px;
            }
        }
        .new-msgs-indicator {
            position: relative;
            width: 100%;
            cursor: pointer;
            background-color: $chat-head-color;
            color: $light-background-color;
            padding: 0.5em;
            font-size: 0.9em;
            text-align: center;
            z-index: 20;
            white-space: nowrap;
            margin-bottom: 0.25em;
        }
        .chat-content {
            height: 100%;
            font-size: $message-font-size;
            color: $text-color;
            overflow-y: auto;
            border: 0;
            background-color: #ffffff;
            line-height: 1.3em;

            video {
                width: 100%
            }
            progress {
                margin: 0.5em 0;
                width: 100%
            }
        }
        .chat-content-sendbutton {
            height: calc(100% - #{$chat-textarea-height + $send-button-height + 2*$send-button-margin});
        }

        .dropdown { /* status dropdown styles */
            background-color: $light-background-color;
            dd {
                margin: 0;
                padding: 0;
                position: relative;
            }
        }

        .sendXMPPMessage {
            -moz-background-clip: padding;
            -webkit-background-clip: padding-box;
            @include border-bottom-radius($chatbox-border-radius);
            background-clip: padding-box;
            background-color: white;
            border: 0;
            margin: 0;
            padding: 0;
            @media screen and (max-height: $mobile-landscape-height) {
                width: 100%;
            }
            @media screen and (max-width: $mobile-portrait-length) {
                width: 100%;
            }

            .spoiler-hint {
                width: 100%;
            }

            .chat-textarea {
                border-top-left-radius: 0;
                border-top-right-radius: 0;
                @include border-bottom-radius($chatbox-border-radius);
                padding: 0.5em;
                width: 100%;
                border: none;
                min-height: $chat-textarea-height;
                margin-bottom: -4px; // Not clear why this is necessar :(
                &.spoiler {
                    height: 42px;
                }
            }

            .send-button {
                position: absolute;
                left: $send-button-margin;
                @include calc(width, '100% - #{2*$send-button-margin}');
                background-color: $chat-head-color;
                color: $inverse-link-color;
                font-size: 80%;
                height: $send-button-height;
                bottom: -$send-button-height - $send-button-margin;

            }
            .chat-toolbar {
                box-sizing: border-box;
                margin: 0;
                padding: 0.25em;
                display: block;
                border-top: 8px solid $chat-head-color;
                background-color: white;
                color: $chat-head-color;
                .fa, .fa:hover {
                    color: $chat-head-color;
                    font-size: $font-size-large;
                }
                .unencrypted a,
                .unencrypted {
                    color: $text-color;
                    .toolbar-menu {
                        a {
                            color: $link-color;
                        }
                    }
                }
                .unverified a,
                .unverified {
                    color: #cf5300;
                }
                .private a,
                .private {
                    color: #4b7003;
                }
                .toggle-occupants {
                    float: right;
                }
                li {
                    cursor: pointer;
                    display: inline-block;
                    list-style: none;
                    padding: 0 0.5em;
                    &:hover {
                        cursor: pointer;
                    }
                    .toolbar-menu {
                        background-color: #fff;
                        bottom: 2rem;
                        box-shadow: -1px -1px 2px 0 rgba(0, 0, 0, 0.4);
                        margin-bottom: 0;
                        min-width: 20rem;
                        position: absolute;
                        right: 0;
                        top: auto;
                        z-index: $zindex-dropdown;

                        &.otr-menu {
                            left: -6em;
                            min-width: 15rem;

                            &.show {
                                display: flex;
                                flex-direction: column;
                            }
                        }

                        a {
                            color: $link-color;
                        }
                        ul {
                            &.emoji-picker {
                                overflow: scroll;
                                padding: 0.5em;
                            }
                            li {
                                margin-left: 0;
                                cursor: pointer;
                                list-style: none;
                                position: relative;
                                &.emoji-skintone {
                                }
                                &.insert-emoji {
                                    padding: 0.2em;
                                    &.picked {
                                        background-color: $highlight-color;
                                    }
                                    &:hover {
                                        background-color: $highlight-color;
                                    }
                                    a {
                                        font-size: $font-size-huge;
                                        &:hover {
                                            color: #8f2831;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    &.toggle-smiley {
                        a.toggle-smiley {
                            padding: 0;
                        }
                        .emoji-toolbar {
                            box-shadow: 0 -1px 1px 0 rgba(0, 0, 0, 0.4);

                            .emoji-category-picker {
                                padding-top: 0.5em;
                                ul {
                                    display: flex;
                                    flex-direction: row;
                                    justify-content: space-between;
                                }
                            }

                            .emoji-category-picker,
                            .emoji-skintone-picker {
                                li {
                                    padding: 0.2em;
                                    font-size: $font-size-huge;
                                    &:hover {
                                        background-color: $highlight-color;
                                    }
                                }
                            }
                        }
                    }
                    &.toggle-otr {
                        ul {
                            z-index: 99;
                            li {
                                &:hover {
                                    background-color: $highlight-color;
                                }
                                display: block;
                                padding: 7px;
                                a {
                                    display: block;
                                }
                            }
                        }
                    }
                }
            }
        }
        .dragresize {
            background: transparent;
            border: 0;
            margin: 0;
            position: absolute;
            top: 0;
            z-index: 20;
            &-top {
                cursor: n-resize;
                height: 5px;
                width: 100%;
            }
            &-left {
                cursor: w-resize;
                width: 5px;
                height: 100%;
                left: 0;
            }
            &-topleft {
                cursor: nw-resize;
                width: 15px;
                height: 15px;
                top: 0;
                left: 0;
            }
        }
    }
}

/* ******************* Overlay and embedded styles *************************** */

#conversejs.converse-embedded,
#conversejs.converse-overlayed {
    .chat-head {
        border-top-left-radius: $chatbox-border-radius;
        border-top-right-radius: $chatbox-border-radius;
        @media screen and (max-height: $mobile-landscape-height) {
            border-top-left-radius: 0;
            border-top-right-radius: 0;
        }
        @media screen and (max-width: $mobile-portrait-length) {
            border-top-left-radius: 0;
            border-top-right-radius: 0;
        }
        .chatbox-title {
            @include make-col(8);
        }
        .chatbox-buttons {
            @include make-col(4);
        }
    }

    .chatbox {
        min-width: $overlayed-chat-width!important;
        width: $overlayed-chat-width;

        .box-flyout {
            min-width: $overlayed-chat-width!important;
            width: $overlayed-chat-width;
        }

        .chat-body {
            .chat-message {
                line-height: $line-height-large;
                .chat-msg-author {
                    line-height: $line-height-large;
                }
                .chat-msg-content {
                    line-height: $line-height-large;
                    .emojione {
                        margin-bottom: -5px;
                    }
                }
            }
        }
    }
    .chatbox {
        form.sendXMPPMessage {
            .chat-toolbar {
                li {
                    .toolbar-menu {
                        min-width: 235px;

                        ul {
                            &.emoji-toolbar {
                                width: 100%;
                                .emoji-category {
                                    float: left;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

#conversejs.converse-overlayed  {
    .flyout {
        bottom: $overlayed-chatbox-hover-height;
    }
    .box-flyout {
        height: $overlayed-chat-height;
        min-height: $overlayed-chat-height/2;
    }
    .chat-head {
        height: $overlayed-chat-head-height;
    }
    .chat-textarea {
        max-height: $overlayed-max-chat-textarea-height;
    }
    .emoji-picker {
        height: $overlayed-emoji-picker-height;
    }
}

@include media-breakpoint-down(sm) {
	#conversejs.converse-overlayed {
		> .row {
			flex-direction: column;

            &.no-gutters {
                margin: -1em;
            }
		}
	}
}

/* ******************* Fullpage styles *************************** */

#conversejs.converse-fullscreen  {
    .flyout {
        border-radius: 0;
        border-top: 0.8em solid $chat-head-color;
        border: $flyout-padding solid $chat-head-color;
        bottom: 0;
    }
    .chatbox-btn {
        font-size: $fullpage-chatbox-button-size;
        margin: 0 0.3em;
    }
    .chat-head {
        height: $fullpage-chat-head-height;
        font-size: $font-size-huge;
        padding: 0;
        .user-custom-message {
            font-size: 50%;
            height: auto;
            line-height: $line-height;
        }
        .chatbox-title {
            @include make-col(10);
        }
        .chatbox-buttons {
            @include make-col(2);
        }
    }
    .chat-textarea {
        max-height: $fullpage-max-chat-textarea-height;
    }
    .emoji-picker {
        height: $fullpage-emoji-picker-height;
    }

    .chatbox {
        width: 100%;
        height: 100%;
        margin: 0;

        @include make-col-ready();
        @include media-breakpoint-up(md) {
            @include make-col(8);
        }
        @include media-breakpoint-up(lg) {
            @include make-col(9);
        }
        @include media-breakpoint-up(xl) {
            @include make-col(10);
        }

        .box-flyout {
            background-color: $chat-head-color;
            box-shadow: none;
            height: $fullpage-chat-height;
            min-height: $fullpage-chat-height/2;
            width: $fullpage-chat-width;
        }
        .chat-body {
            background-color: $chat-head-color;
            border-top-left-radius: $chatbox-border-radius;
            border-top-right-radius: $chatbox-border-radius;

            .chat-message {
                line-height: $line-height;
                font-size: $font-size-small;
                .chat-msg-author {
                    line-height: $line-height;
                }
                .chat-msg-content {
                    line-height: $line-height;
                    .emojione {
                        height: $line-height;
                        margin-bottom: -$line-height/4;
                    }
                }
            }
        }
        .chat-content {
            border-top-left-radius: $chatbox-border-radius;
            border-top-right-radius: $chatbox-border-radius;
        }
        .chat-title {
            font-size: $font-size-huge;
            line-height: $line-height-huge;
        }
        .sendXMPPMessage {
            ul {
                width: 100%;
            }
            .toggle-smiley {
                ul {
                    &.emoji-toolbar {
                        .emoji-category-picker {
                            margin-right: 5em;
                        }
                        .emoji-category {
                            padding-left: 10px;
                            padding-right: 10px;
                        }
                    }
                }
            }
        }
    }
}

@include media-breakpoint-down(sm) {
    #conversejs:not(.converse-embedded)  {
        > .row {
            flex-direction: row-reverse;
        }
        #converse-login-panel {
            .converse-form {
                padding: 3em 2em 3em;
            }
        }
        .chatbox {
            width: calc(100% - 50px);
            .row {
                .box-flyout {
                    left: 50px;
                    bottom: 0;
                    height: 100vh;
                    box-shadow: none;
                }
            }
        }
    }

    #conversejs.converse-mobile,
    #conversejs.converse-overlayed,
    #conversejs.converse-embedded,
    #conversejs.converse-fullscreen {
        .chatbox {
            .box-flyout {
                .chatbox-navback {
                    display: flex;
                    @include make-col(2);
                    .fa-arrow-left {
                        &:before {
                            color: white;
                        }
                    }
                }
                .chatbox-title {
                    @include make-col(7);
                }
                .chatbox-buttons {
                    @include make-col(3);
                }
            }
        }
    }
}
