
/* *** COLOR *** */
$primary: #2391eb;
$secondry: #d1d1d1;
$white: #fff;
$boxshadow: 0 0 13px 3px rgba(0, 0, 0, 0.1);

/* *** FONTS *** */
@font-face{
    font-family: 'vazir';
    src: url('../font/vazir-medium.ttf'), url('../font/vazir-medium.woff');
}
.font-vazir { font-family: vazir !important; }

/* *** CONFIGS *** */
.msg__body::-webkit-scrollbar{
    background-color: transparent;
    width: 5px;
}
.msg__body::-webkit-scrollbar-thumb{
    border-radius: 5px;
    background-color: $secondry;
}
.d-none {display: none !important;}
.chatapp__show { opacity: 1 !important; }
.chatapp__hide { opacity: 0 !important; }

/* *** SOURCE CODE *** */
section.chatapp {
    box-sizing: border-box;
    z-index: 9999 !important;
    font-family: vazir !important;
    scroll-behavior: smooth !important; 
    direction: rtl !important;

    .chatapp__btn {
        position: fixed;
        right: 14px;
        bottom: 14px;
        cursor: pointer;
        padding: 7px 10px;
        border-radius: 10px;
        background-color: $primary;

        & + div {
            position: relative;
        }
        img {
            height: 40px;
            width: 40px;
        }
        div#alert_msg_ctx {
            position: absolute;
            top: 13px;
            left: 14px;
            height: 19px;
            width: 22px;
            border-radius: 2px;
            background-color: $white;
            animation: blink 2s alternate infinite;
            -webkit-animation: blink 2s alternate infinite;
        }
    }

    .chatapp__msg {
        position: fixed !important;
        right: 14px;
        border-radius: 10px;
        bottom: 87px;
        box-shadow: 0 5px 13px 3px rgba(0, 0, 0, 0.1);
        transition: all 0.5s ease;
        background-color: white;
        position: relative;

        #div_spinner {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            backdrop-filter: blur(4px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 20 !important;

            .loader_spinner {    
                height: 35px;
                width: 35px;
                border-radius: 50%;
                border: 7px solid #b1b1b1;
                animation: spinner 2s linear infinite;
                transition: all 0.3s;
                pointer-events: none;
                border-top: 7px solid white;
            }
        }

        &::after {
            content: '';
            height: 0;
            width: 0;
            position: absolute;
            bottom: -9px;
            right: 22px;
            border-left: 10px solid rgba(0,0,0,0);
            border-right: 10px solid rgba(0,0,0,0);
            border-top: 10px solid white;
        }

        .msg__header {
            background-color: $primary;
            border-radius: 10px 10px 0 0;

            .msg__wrapper {
                border-radius: 10px 10px 0 0;
                padding: 10px;
                background: linear-gradient(258deg, rgba(0, 0, 0, 0.3) 0%, rgba(84, 141, 177, 0) 100%) transparent;
                display: flex;
                justify-content: space-between;
                width: 375px;
    
                .header__info {
                    display: flex;

                    img {
                        height: 45px;
                        width: 45px;
                        border-radius: 50%;
                    }
                    div {
                        display: flex;
                        flex-direction: column;
                        color: $white;
                        margin: 0 10px;
                        position: relative;
                        min-width: 140px;
    
                        span:nth-child(1) {
                            font-size: 20px;
                        }
                        span:nth-child(2) {
                            font-size: 9pt;
                            position: absolute;
                            right: 0;
                            bottom: 0px;     
                            display: flex;
                        }
                    }
                }
                .header__options {
                    button {
                        background-color: transparent;
                        border: none;
                        color: $white;
                        outline: none;
                        cursor: pointer;
                        font-size: 20px;
                        margin-top: 8px;
                        transition: all 0.3s;
                    }
                    button.bottom__msgbox img {
                        height: 22px !important;
                        width: 22px !important;
                        margin-bottom: 2px;
                    }
                    button.close__msgbox img {
                        height: 26px !important;
                        width: 26px !important;
                    }
                }
            }
        }

        .msgdel__right {
            float: right !important;
        }
        .msgdel__left {
            float: left !important;
        }

        .msg__body {
            background-color: $white;
            padding: 10px 15px;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            height: 320px;

            .body__wrapper {

                // messages wrapper
                .all__msg__wrapper {
                    .deleted_msg {
                        background-color: $secondry !important;
                        color: white !important;
                        padding: 3px 4px;
                        font-size: 13px;
                        border-radius: 5px;
                        margin-bottom: 5px;
                        width: 175px;

                        img {
                            height: 12px;
                        }
                    }
                    div.one_msg_wrapper {
                        width: 100%;
                        height: auto;
                        position: relative;

                        ul.msg-menu-bar {
                            position: absolute;
                            top: -13px;
                            padding: 5px;
                            background-color: rgb(0,0,0);
                            // border-radius: 12px;
                            z-index: 5;
                            list-style: none;
                            color: $secondry;
                            width: 100px;
                            font-size: 12px;
                            
                            li {
                                cursor: pointer;
                                padding: 3px 5px;

                                img {
                                    height: 13px;
                                    margin-bottom: -4px;
                                }

                                &:hover {
                                    color: white;
                                }
                            }
                        }
                        ul.msg-menu-bar--right {
                            right: 0 !important;
                            left: unset !important;
                        }
                        ul.msg-menu-bar--left {
                            left: 0 !important;
                            right: unset !important;
                        }

                        &:hover .reply_one_msg {
                            opacity: 1;
                        }

                        .msg { 
                            padding: 7px 10px;
                            margin-bottom: 5px;
                            max-width: 240px;
                            min-width: 100px;
                            text-align: right;
                            color: $white;
                            position: relative;
                            transition: background-color 0.3s linear;
                            z-index: 2;

                            p {
                                margin: 0px !important;
                                word-break: break-word;
                            }
                            p.msg__replied {
                                padding: 3px 5px;
                                border-right: 2px solid $white;
                                margin-bottom: 7px !important;
                                border-radius: 4px 0 0 4px;
                                display: flex;
                                flex-direction: column;
                                cursor: pointer;
        
                                span {
                                    font-size: 9pt;
                                }
                                &--right {
                                    background-color: #39a2f9;
                                }
                                &--left {
                                    background-color: #c5c5c5;
                                }
                            }
                            div.msg__info {
                                margin-top: 5px;
                                margin-bottom: -5px;
                                display: flex;
                                flex-direction: row;
                                justify-content: flex-start;
        
                                &__clock {
                                    font-size: 9pt;
                                }
                                &__edited {
                                    font-size: 9pt;
                                    padding: 0 7px;
                                    margin-top: -3px;
                                }
                                &__status {
                                    img {
                                        height: 14px;
                                        width: 16px;
                                        margin-left: 5px;
                                    }
                                }
                            }
                        }
                        .msg__left { 
                            float: left;
                            border-radius: 12px;
                            background-color: $secondry;

                            &::after {
                                content: '';
                                position: absolute;
                                bottom: 9px;
                                left: -8px;
                                width: 0;
                                height: 0;
                                border-top: 8px solid transparent;
                                border-bottom: 0px solid transparent;
                                border-right: 8px solid $secondry;
                            }
                            div.msg__info__clock {
                                padding-bottom: 4px !important;
                            }
                        }
                        .msg__right { 
                            float: right;
                            border-radius: 12px;
                            background-color: $primary;
    
                            &::after {
                                content: '';
                                position: absolute;
                                bottom: 9px;
                                right: -8px;
                                width: 0;
                                height: 0;
                                border-top: 8px solid transparent;
                                border-bottom: 0px solid transparent;
                                border-left: 8px solid $primary;
                            }
                        }
                        .reply_one_msg {
                            color: $secondry;
                            font-size: 10pt;
                            opacity: 0;
                            line-height: 11px;
                            z-index: 1;

                            &--right {
                                transform: translate(-5px, 7px);
                            }
                            &--left {
                                text-align: left;
                                transform: translate(5px, 7px);
                            }

                            span {
                                cursor: pointer;
                                transition: all 0.2s;
                                margin: 0 !important;
                                padding: 4px 0;

                                &:hover {
                                    color: darken($secondry, 20);
                                }
                            }
                        }
                    }
                    .clearfix {clear: both;}
                }

                // start tictoctoe game source code
                .tictoctoe__game {

                    #restart__game {
                        border: none;
                        outline: none;
                        font-family: vazir;
                        padding: 5px 15px;
                        border-radius: 5px;
                        cursor: pointer;
                        background-color: #ececec;
                        margin-bottom: 15px;
                
                        &:active {
                            transform: translateY(-1px);
                        }
                    }
                
                    #score__game {
                        display: flex;
                        justify-content: center;
                        margin-bottom: 20px;
                
                        div {
                            margin: 0 15px;
                            display: flex;
                
                            span:nth-child(1) {
                                color: $secondry;
                                padding-left: 3px;
                            }
                        }
                    }
                
                    .btns__wrapper {
                        width: 208px;
                        margin: auto;
                        position: relative;
                
                        #bg__glass {
                            background-color: transparent;
                            position: absolute;
                            inset: 0;
                            cursor: not-allowed !important; 
                        }
                
                        &__btn {
                            display: flex;
                            background-color: $primary;
                
                            .btn_game {
                                padding: 0px;
                                height: 65px;
                                width: 68px;
                                border: none;
                                outline: none;
                                background-color: $white;
                                display: flex;
                                justify-content: center;
                                align-items: center;
                
                                img {
                                    height: 50%;
                                    height: 50%;    
                                }
                            }
                            .m2px_l { margin-left: 2px; }
                            .m2px_b { margin-bottom: 2px; }
                            .disable_btn { 
                                cursor: not-allowed !important; 
                                pointer-events: none; 
                            }
                        }
                    }
                    #game_alert_msg {
                        color: white;
                        padding: 8px 7px;
                        border-radius: 7px;
                        max-width: 1100px;
                        margin: 20px auto;
                        background-color: $primary;
                        font-size: 11pt;
                        text-align: center;
                    }
                    .game_alert_msg_win { background-color: $secondry !important; }
                    .game_alert_msg_lose { background-color: $primary !important; }
                }

                // chat app login form
                .chatapp__form {
                    width: 250px;
                    margin: 20px auto;
                    border-radius: 8px;
                    box-shadow: $boxshadow;

                    .chatform__header {
                        border-radius: 8px 8px 0px 0px;
                        background-color: $primary;
                        padding: 8px;
                        color: $white;
                        font-size: 9pt;
                        text-align: start;
                        margin-bottom: 10px;
                    }
                    form {
                        padding: 1rem; 

                        div.chatapp_formcontrol {
                            position: relative;
                            margin-bottom: 23px;

                            input {
                                font-family: vazir;
                                width: 92%;
                                padding: 7px;
                                font-size: 13pt;
                                color: $primary;
                                border: 1px solid $secondry;
                                border-radius: 5px;
                                outline: none;
                                background: $white !important;
                                transition: all 0.3s linear;

                                &:focus {
                                    border-color: darken($secondry, 30%);
                                }
                                &:focus ~ label {
                                    color: darken($secondry, 30%);
                                }
                            }
                            label {
                                position: absolute;
                                pointer-events: none;
                                top: -15px;
                                right: 10px;
                                color: $secondry;
                                font-size: 13px;
                                padding: 0 7px;
                                background-color: white;
                                transition: all 0.3s linear;
                            }
                            p.form_error {
                                color: red;
                                font-size: 12px;
                                margin: 0px;
                                margin-top: 5px;
                            }
                        }
                        .mbnone__chatapp {margin-bottom: unset !important;}
                        .chatapp_button {
                            width: 100%;
                            display: flex;
                            justify-content: end;
                            margin-top: 13px;

                            button {
                                font-family: vazir;
                                border: none;
                                outline: none;
                                padding: 5px 25px;
                                cursor: pointer;
                                border-radius: 5px;
                            }
                        }
                    }
                }

                .btn_last_msg {
                    position: absolute;
                    left: 20px;
                    bottom: 60px;
                    z-index: 9999;
                    
                    button {
                        cursor: pointer;
                        outline: none;
                        border: none;
                        border-radius: 50%;
                        background-color: rgba(0,0,0, 0.3);
                        position: relative;

                        img {
                            height: 35px;
                            width: 35px;
                            padding: 5px 3px;
                            padding-top: 8px;
                        }
                        div.unreadmsg_counter {
                            position: absolute;
                            right: -2px;
                            top: -2px;
                            padding: 3px 7px;
                            background-color: $primary;
                            border-radius: 50%;
                            font-size: 10pt;
                            color: $white;
                        }
                    }

                }
            }
        }
        .body__inputs {
            padding: 0px 10px;
            padding-top: 4px !important;
            background-color: white;
            border-radius: 0 0 10px 10px;

            form {
                div.forminput_wrapper {
                    background-color: #ececec;
                    border-radius: 25px;
                    display: flex;
                    position: relative;

                    input {
                        flex: auto;
                        font-family: vazir !important;
                        outline: none;
                        border: none;
                        background-color: #ececec;
                        padding: 10px 15px;
                        border-radius: 25px;
                    }

                    .reply_msg_wrapper {
                        position: absolute;
                        bottom: 44px;
                        border-radius: 7px;
                        right: 0px;
                        background-color: #ececec;
                        padding: 5px 10px;
                        z-index: 9999;
                        width: 70%;
                        display: flex;
                        justify-content: space-between;
                        
                        div {
                            order: 1;
                            display: flex;
                            flex-direction: column;
                            
                            p {
                                margin: 0;
                                color: rgb(94, 94, 94);
                                font-size: 9pt;
                                padding: 0 5px;
                                border-right: 2px solid $white;
                                height: 20px;
                                overflow: hidden;
                            }
                        }
                        button.close_replybar {
                            order: 2;
                            background-color: transparent !important;
                            color: rgb(94, 94, 94);
                            border: none;
                            outline: none;
                            font-size: 20px;
                            cursor: pointer;
                            padding: 0 10px 10px 0;
                            height: 100%;

                            &:hover {
                                color: black;
                            }
                        }
                    }

                    .emoji_wrapper {
                        position: absolute;
                        bottom: 44px;
                        border-radius: 7px;
                        right: 0px;
                        background-color: #ececec;
                        padding: 5px 10px;
                        z-index: 9999;
                        width: 70%;
                        height: 100px;
                        overflow-y: scroll;
                        display: flex;
                        justify-content: space-between;
                        
                        div.emoji_box {
                            order: 1;
                            display: flex;
                            flex-direction: row;
                            flex-wrap: wrap;
                            
                            div.emoji_item {
                                flex: 1;
                                cursor: pointer;
                                font-size: 18px;
                                padding: 4px;
                                max-width: 25px;
                            }
                        }
                    }

                    button.show_game {
                        outline: none;
                        background-color: transparent;
                        border: none;
                        margin-right: 3px;
                        padding: 6px 10px;
                        cursor: pointer;

                        img {
                            height: 26px;
                            width: 28px;
                        }
                    }
                    button.show_emoji {
                        outline: none;
                        background-color: transparent;
                        border: none;
                        margin-right: 3px;
                        padding: 6px 2px;
                        cursor: pointer;

                        img {
                            height: 26px;
                            width: 28px;
                            margin-bottom: -4px;
                        }
                    }
                    
                    button[type="submit"] {
                        outline: none;
                        background-color: $primary;
                        border: none;
                        margin-right: 3px;
                        border-radius: 25px;
                        padding: 6px 20px;
                        cursor: pointer;

                        img {
                            height: 20px;
                            width: 21px;
                        }
                    }
                }
            }
            .goback_chat_btn {
                text-align: center;
                padding: 4px;
                cursor: pointer;
                transition: all 0.3s;

                &:hover {
                    color: $primary;
                }

                .new_msg_shower {

                    background-color: $primary;
                    color: white;
                    width: 56px;
                    font-size: 12px;
                    border-radius: 5px;
                    padding: 4px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    float: left;
                    margin-bottom: 10px;

                    img {
                        height: 20px;
                        margin-bottom: -5px;
                    }
                    div {
                        flex: 1;
                    }
                }
            }
        }
    }
}

section.chatapp__ltr {
    direction: ltr !important;

    .chatapp__btn {
        left: 14px;
        right: unset !important;
    }
    .chatapp__msg {
        left: 14px;
        right: unset !important;
        border-radius: 10px;
        bottom: 87px;
        box-shadow: $boxshadow;

        &::after {
            right: unset !important;
            left: 22px;
        }
    }
    .msg__info__status img {
        margin-right: 5px;
        margin-left: unset !important;
    }
    .msg__header .msg__wrapper .header__info div span:nth-child(2) {
        right: unset !important;
        left: 0;
    }
    .chatapp__msg .body__inputs form div button {
        margin-right: unset !important;
        margin-left: 3px;
    }
    .chatapp__msg .msg__body .body__wrapper .chatapp__form form div.chatapp_formcontrol label {
        right: unset !important;
        left: 10px;
    }
    .m2px_l { 
        margin-left: unset !important; 
        margin-right: 2px; 
    }
    .msg__body .body__wrapper .msg {
        text-align: left !important;

        p.msg__replied {
            border-right: unset !important;
            border-left: 2px solid $white;
            border-radius: 0 4px 4px 0 !important;
        }
    }
    .chatapp__msg .msg__header .msg__wrapper {
        background: linear-gradient(258deg, rgba(84, 141, 177, 0) 0%, rgba(0, 0, 0, 0.3) 100%) transparent !important;
    }
    .body__inputs .btn_last_msg {
        left: unset !important;
        right: 15px;
    }
    .body__inputs form div.forminput_wrapper .reply_msg_wrapper {
        left: 0px;
        right: unset !important;

        div {
            p {
                border-left: 2px solid $white !important;
                border-right: unset !important;
            }
        }
    }
    .body__inputs form div.forminput_wrapper .emoji_wrapper {
        left: 0px;
        right: unset !important;
    }
    .reply_one_msg--right {
        float: right !important;
    }
    .body__wrapper .msg div.msg__info__edited {
        margin-top: unset !important;
    }
}

/* *** ANIMATIONS *** */
@keyframes blink {
    from {opacity: 0;}
    to {opacity: 1;}
}

@keyframes spinner {
    0% { 
        transform: rotate(0deg)
    }
    100% { 
        transform: rotate(360deg)
    }
}

/* *** Media queries *** */
@media screen and (min-width: 1001px) {
    .chatapp__msg .msg__header .msg__wrapper {
        width: 375px !important;
    }
}
@media screen and (max-width: 1000px) {
    .chatapp__msg .msg__header .msg__wrapper .header__info div span:nth-child(1) {
        font-size: 12pt !important;
    }
    .chatapp__msg .msg__header .msg__wrapper .header__info div span:nth-child(2) {
        font-size: 9pt !important;
    }
}