.popover-region {
    float: right;
    position: relative;

    &.collapsed {
        .popover-region-toggle {
            &:before,
            &:after {
                display: none;
            }
        }

        .popover-region-container {
            height: 0;
            overflow: hidden;
            opacity: 0;
            visibility: hidden;
            transition: height 0.25s, opacity 101ms 0.25s, visibility 101ms 0.25s;
        }
    }
}

.popover-region-toggle {
    cursor: pointer;

    &::before {
        content: '';
        display: inline-block;
        border-left: 10px solid transparent;
        border-right: 10px solid transparent;
        border-bottom: 10px solid #ddd;
        position: absolute;
        bottom: 0;
        right: 7px;
    }
    &::after {
        content: '';
        display: inline-block;
        border-left: 9px solid transparent;
        border-right: 9px solid transparent;
        border-bottom: 9px solid #fff;
        position: absolute;
        bottom: -1px;
        right: 8px;
        z-index: 2;
    }
}

.count-container {
    padding: 2px;
    border-radius: 2px;
    background-color: red;
    color: white;
    font-size: 10px;
    line-height: 10px;
    position: absolute;
    top: 5px;
    right: 0;
}

.popover-region-container {
    position: absolute;
    right: 0;
    top: 0;
    height: 500px;
    width: 380px;
    border: 1px solid #ddd;
    transition: height 0.25s;
    opacity: 1;
    visibility: visible;
    background-color: @body-bg;
    z-index: 1;
}

.popover-region-header-container {
    height: 25px;
    line-height: 25px;
    padding-left: 5px;
    padding-right: 5px;
    border-bottom: 1px solid #ddd;
    box-sizing: border-box;
}

.popover-region-footer-container {
    height: 30px;
    text-align: center;
    border-top: 1px solid #ddd;
    background-color: @popover-bg;

    .popover-region-seeall-text {
        padding-top: 4px;
    }
}

.popover-region-header-text {
    float: left;
    margin: 0;
    font-size: 14px;
    line-height: 25px;
}

.popover-region-header-actions {
    float: right;

    > * {
        margin-left: 10px;
        min-width: 20px;
        display: inline-block;
    }
    .loading-icon {
        display: none;
        height: 12px;
        width: 12px;
    }
    .newmessage-link {
        margin-right: 10px;
    }
    label {
        display: inline-block;
        text-align: center;
        margin-bottom: 0;
    }
}

.popover-region-content-container {
    height: ~"calc(100% - 56px)";
    width: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    > .loading-icon {
        display: none;
        text-align: center;
        padding: 5px;
        box-sizing: border-box;
    }
    .empty-message {
        display: none;
        text-align: center;
        padding: 10px;
    }

    &.loading {
        > .loading-icon {
            display: block;
        }
        .empty-message {
            display: none;
        }
    }
}

.navbar {
    .popover-region {
        float: left;

        &.collapsed {
            .popover-region-container {
                height: 0;
                overflow: hidden;
                opacity: 0;
                visibility: hidden;
                transition: height 0.25s, opacity 101ms 0.25s, visibility 101ms 0.25s;
            }
        }
    }

    .popover-region-toggle {
        height: @navbar-height;
        line-height: @navbar-height;
        padding-left: 10px;
        padding-right: 10px;

        img {
            height: 16px;
            width: 16px;
        }
    }

    .count-container {
        padding: 2px;
        border-radius: 2px;
        background-color: red;
        color: white;
        font-size: 10px;
        line-height: 10px;
        position: absolute;
        top: 5px;
        right: 0;
    }

    .popover-region-container {
        top: @navbar-height;
    }
}

.content-item-container {
    width: 100%;
    border-bottom: 1px solid #ddd;
    box-sizing: border-box;
    padding: 5px;
    position: relative;
    margin: 0;
    display: block;
    color: inherit;
    text-decoration: none;

    &:hover {
        color: #fff;
        background-color: #79b5e6;

        .content-item-footer {
            .timestamp {
                color: #fff;
            }
        }
    }

    &.unread {
        margin: 0;
        background-color: #f4f4f4;

        &:hover {
            color: #fff;
            background-color: #79b5e6;
        }

        .content-item-body {
            .notification-message {
                font-weight: 600;
            }
        }
    }

    .context-link {
        color: inherit;
        text-decoration: none;
    }

    .content-item-body {
        box-sizing: border-box;
        margin-bottom: 5px;
    }

    .content-item-footer {
        text-align: left;
        box-sizing: border-box;

        .timestamp {
            font-size: 10px;
            line-height: 10px;
            margin: 0;
            color: #666;
            margin-left: 24px;
        }
    }

    .view-more {
        position: absolute;
        bottom: 5px;
        right: 5px;
        font-size: 12px;
        line-height: 12px;
    }

    &.notification {
        .content-item-body {
            .notification-image {
                display: inline-block;
                width: 24px;
                height: 24px;
                float: left;

                img {
                    height: 75%;
                }
            }

            .notification-message {
                display: inline-block;
                font-size: 12px;
                width: ~"calc(100% - 24px)";
            }
        }
    }

    &.selected {
        background-color: #4f94cd;
        color: #fff;
        border-color: #4f94cd;

        .content-item-footer {
            .timestamp {
                color: #fff;
            }
        }
    }
}

.popover-region-notifications {
    .popover-region-header-container {
        .mark-all-read-button {
            .normal-icon {
                display: inline-block;
            }

            &.loading {
                .normal-icon {
                    display: none;
                }
                .loading-icon {
                    display: inline-block;
                }
            }
        }
    }

    .all-notifications {
        opacity: 1;
        visibility: visible;
        height: auto;
        overflow: hidden;

        &:empty + .empty-message {
            display: block;
        }
    }

    .notification-image {
        display: inline-block;
        width: 8%;
        vertical-align: top;

        img {
            height: 75%;
        }
    }

    .notification-message {
        display: inline-block;
        font-size: 12px;
        width: 90%;
    }

    .popover-region-content-container {
        &.loading {
            .all-notifications {
                &:empty + .empty-message {
                    display: none;
                }
            }
        }
    }
}

.popover-region-messages {
    .mark-all-read-button {
        .normal-icon {
            display: inline-block;
        }

        &.loading {
            .normal-icon {
                display: none;
            }
            .loading-icon {
                display: inline-block;
            }
        }
    }

    .popover-region-content-container {
        &.loading {
            .popover-region-content {
                .messages {
                    &:empty + .empty-message {
                        display: none;
                    }
                }
            }
        }
    }

    .messages {
        &:empty + .empty-message {
            display: block;
        }
    }

    .content-item-container {
        &.unread {
            .content-item-body {
                font-weight: 600;
                width: ~"calc(90% - 30px)";
            }

            .unread-count-container {
                display: inline-block;
                width: 10%;
                text-align: center;
                float: right;
            }
        }
    }

    .content-item {
        height: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    .profile-image-container {
        width: 30px;
        display: inline-block;
        text-align: center;
        float: left;

        img {
            width: 100%;
            display: inline-block;
            vertical-align: middle;
            border-radius: 50%;
        }
    }

    .content-item-body {
        display: inline-block;
        box-sizing: border-box;
        width: ~"calc(100% - 30px)";
        font-size: 12px;
        padding-left: 10px;
        overflow: hidden;

        h3 {
            font-size: 12px;
            line-height: 12px;
            margin: 0;
            width: 100%;
        }

        p {
            margin: 0;
        }
    }

    .unread-count-container {
        display: none;
    }
}

.dir-rtl {
    .popover-region {
        .popover-region-container {
            left: 0;
            right: auto;
        }

        .popover-region-header-text {
            float: right;
        }

        .popover-region-header-actions {
            float: left;

            .newmessage-link {
                margin-left: 10px;
            }
        }
    }

    .navbar {
        .popover-region {
            float: left;
        }

        .popover-region-container {
            &::before {
                right: auto;
                left: 7px;
            }
            &::after {
                right: auto;
                left: 8px;
            }
        }

        .popover-region-header-text {
            float: right;
        }
        .popover-region-header-actions {
            float: left;
        }
    }

    .popover-region-messages {
        .profile-image-container {
            float: right;
        }

        .content-item-body {
            padding-left: 0;
            padding-right: 10px;
        }

        .unread-count-container {
            float: left;
        }
    }
}

@media (max-width: 767px) {
    .navbar {
        .popover-region {
            .popover-region-container {
                right: -70px;
            }
        }
    }
}

@media (max-width: 480px) {
    .navbar {
        .popover-region {
            .popover-region-container {
                position: fixed;
                top: 46px;
                right: 0;
                left: 0;
                bottom: 0;
                width: auto;
                height: auto;
            }
        }
    }
}
