@import (reference) './avatar.less';
@import (reference) "./colortheme-all.less";

.messenger_main() {
    --LessLoader_require: LessLoader_currentFile();
};
& {
    @keyframes example {
        0% {
            background: rgba(0,0,0,0.1);
        }
        50% {
            background: rgba(0,0,0,0.3);
        }
        100% {
            background: rgba(0,0,0,0.1);
        }
    }

    @button-border: 2px;
    @bg-color: @colortheme_friends-bg;
    @color: @colortheme_friends-color;
    @room-height: 48px;

    #cp-app-contacts-container {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 0;
        &.ready {
            background-size: cover;
            background-position: center;
        }
    }

    .cp-app-contacts-spinner {
        display: none;
    }

    .cp-app-contacts-initializing {
        .cp-app-contacts-spinner {
            color: white;
            display: block;
        }
        .cp-app-contacts-info {
            display: none;
        }
        #cp-app-contacts-friendlist,
        #cp-app-contacts-messaging {
            display: flex;
            justify-content: center;
            align-items: center;
        }
    }

    #cp-app-contacts-friendlist {
        width: 200px;
        height: 100%;
        background-color: lighten(@bg-color, 10%);
        overflow-y: auto;
        display: flex;
        flex-flow: column;
        .cp-app-contacts-friend {
            background: rgba(0,0,0,0.1);
            padding: 5px;
            margin: 10px;
            margin-bottom: 0;
            cursor: pointer;
            position: relative;
            height: @room-height;
            .cp-app-contacts-right-col {
                margin-left: 5px;
                display: flex;
                flex-flow: column;
                flex: 1;
                min-width: 0;
                .cp-app-contacts-name {
                    white-space: nowrap;
                }
            }
            &:hover {
                background-color: rgba(0,0,0,0.3);
            }
            &.cp-app-contacts-notify {
                animation: example 2s ease-in-out infinite;
            }
        }
        .cp-app-contacts-remove {
            cursor: pointer;
            width: 20px;
            &:hover {
                color: darken(@color, 20%);
            }
        }

        .cp-app-contacts-category {
            display: flex;
            flex-flow: column;
            flex-grow: 0;
            flex-shrink: 0;
            .cp-app-contacts-category-title {
                order: 1;
                font-size: 18px;
                margin: 0px 5px;
                text-align: center;
                background: rgba(0,0,0,0.1);
                font-weight: bold;
                height: 22px;
                line-height: 22px;
            }
            .cp-app-contacts-category-content {
                order: 2;
                display: flex;
                flex-flow: column-reverse;
                padding-bottom: 10px;
                &:empty {
                    display: none;
                    & ~ .cp-app-contacts-category-title {
                        display: none;
                    }
                }
            }
        }
    }
    #cp-app-contacts-container.cp-app-contacts-inapp {
        #cp-app-contacts-friendlist {
            display: none;
/*
            transition: width 0.2s ease-in-out 0.2s;
            width: 68px;
            .cp-app-contacts-friend {
                .cp-app-contacts-right-col {
                    overflow: hidden;
                }
            }
            .cp-app-contacts-category-title {
                transition: font-size 0.2s ease-in-out 0.2s;
                margin: 0px 2px;
                font-size: 16px;
            }
            &:hover {
                transition-delay: 1.5s;
                width: 200px !important;
                .cp-app-contacts-category-title {
                    transition-delay: 1.5s;
                    font-size: 18px;
                }
            }
*/
        }
    }

    #cp-app-contacts-friendlist .cp-app-contacts-friend, #cp-app-contacts-messaging .cp-avatar {
        .avatar_main(30px);
        &.cp-avatar {
            display: flex;
        }
        cursor: pointer;
        color: @color;
        media-tag {
            img {
                color: #000;
            }
        }
        media-tag, .cp-avatar-default {
            //margin-right: 5px;
            flex-shrink: 0;
            z-index: 1;
            margin: 4px;
        }
        .cp-app-contacts-status {
            //width: 5px;
            display: inline-block;
            position: absolute;
            //right: 0;
            //top: 0;
            //bottom: 0;
            //opacity: 0.7;
            //background-color: #777;

/*            width: (@room-height - 6px);
            top: 3px;
            bottom: 3px;
            left: 3px;
            border-radius: 100%;
*/
            width: 10px;
            height: 10px;
            top: 0;
            right: 0;
            border-bottom-left-radius: 100%;

            &.cp-app-contacts-online {
                //background-color: green;
                //background-color: white;
                background-color: #c5ffa8;
            }
            &.cp-app-contacts-offline {
                display: none;
                //background-color: red;
            }
        }
    }

    .placeholder (@color: #bbb) {
        &::-webkit-input-placeholder { /* WebKit, Blink, Edge */
            color: @color;
        }
        &:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
            color: @color;
            opacity: 1;
        }
        &::-moz-placeholder { /* Mozilla Firefox 19+ */
            color: @color;
            opacity: 1;
        }
        &:-ms-input-placeholder { /* Internet Explorer 10-11 */
            color: @color;
        }
        &::-ms-input-placeholder { /* Microsoft Edge */
            color: @color;
        }
    }

    #cp-app-contacts-messaging {
        flex: 1;
        height: 100%;
        background-color: lighten(@bg-color, 20%);
        min-width: 0;

        .cp-app-contacts-info {
            padding: 20px;
        }
        .cp-app-contacts-header {
            background-color: lighten(@bg-color, 15%);
            padding: 0;
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 50px;

            .hover () {
                height: 100%;
                line-height: 30px;
                padding: 10px;
                &:hover {
                    background-color: rgba(50,50,50,0.3);
                }
            }

            .cp-avatar,
            .cp-app-contacts-right-col {
                 flex: 1 1 auto;
            }
            .cp-app-contacts-remove-history {
                .hover;
            }
            .cp-avatar {
                margin: 10px;
            }
            .cp-app-contacts-more-history {
                //display: none;
                .hover;
                &.cp-app-contacts-faded {
                    color: darken(@bg-color, 5%);
                }
            }

            .cp-app-contacts-header-title {
                padding: 10px;
                flex: 1;
            }
        }
        .cp-app-contacts-tips {
            margin: 1em;
            background-color: lighten(@bg-color, 15%);
            font-size: 14px;
            padding: 10px;
            position: relative;
            .cp-app-contacts-tips-close {
                cursor: pointer;
                position: absolute;
                top: 2px;
                right: 2px;
            }
        }
        .cp-app-contacts-chat {
            height: 100%;
            display: flex;
            flex-flow: column;
            .cp-app-contacts-messages {
                padding: 0 20px;
                margin: 10px 0;
                flex: 1;
                overflow-x: auto;
                .cp-app-contacts-message {
                    display: flex;
                    flex-wrap: wrap;
                    & > div {
                        padding: 0 10px;
                    }
                    .cp-app-contacts-content {
                        overflow: hidden;
                        word-wrap: break-word;
                        &> * {
                            margin: 0;
                        }
                        flex: 1;
                        min-width: 70%;
                        position: relative;
                    }
                    .cp-app-contacts-date {
                        display: none;
                        font-style: italic;
                    }
                    .cp-app-contacts-sender {
                        margin-top: 10px;
                        font-weight: bold;
                        background-color: rgba(0,0,0,0.1);
                        display: flex;
                        justify-content: space-between;
                        width: 100%;
                    }
                    .cp-app-contacts-time {
                        display: none;
                        font-size: 0.8em;
                        align-items: center;
                        color: @color;
                        font-weight: bold;
                        position: absolute;
                        right: 0;
                        top: 0;
                        bottom: 0;
                        background: rgba(0,0,0,0.3);
                        border-top-left-radius: 50%;
                        border-bottom-left-radius: 50%;
                        padding: 0 10px;
                    }
                    &:hover {
                        .cp-app-contacts-time {
                            display: flex;
                        }
                    }
                }
            }
        }
        .cp-app-contacts-input {
            background-color: lighten(@bg-color, 15%);
            height: auto;
            min-height: 50px;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0 5%;
            textarea {
                margin: 5px 0;
                padding: 5px 10px;
                border: none;
                height: 54px; // 2 lines (22px height) + 2 margins (5px)
                flex: 1;
                background-color: darken(@bg-color, 10%);
                color: @color;
                resize: none;
                overflow-y: auto;
                .placeholder(#bbb);
                &[disabled="true"] {
                    .placeholder(#999);
                }
            }
            button {
                height: 54px;
                border-radius: 0;
                border: none;
                background-color: darken(@bg-color, 15%);
                &:hover {
                    background-color: darken(@bg-color, 20%);
                }
            }
        }
    }
}
