// Separator for navigation items
@mixin nav-item-separator() {
    border-bottom: 1px solid $border-grey;
}

#navigation-topheader {
    background-color: #424242;
    padding: 0 $main-padding 0 (2*$main-padding);
    min-height: 68px;
    display: flex;
    flex-direction: row;
    color: white;
    box-shadow: -2px 2px 4px -2px rgba(0,0,0,0.8);
    z-index: 21;
    align-items: center;
    justify-content: center;

    .my-identity {
        width: 85%;
        flex-grow: 1;
        span {
            max-width: 100%;
            display: inline-block;
            text-shadow: 0.5px 0.5px 1px rgba(0,0,0,0.25);
            font-size: 16pt;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            word-wrap: break-word;
            word-break: break-all;
            @include mouse-hand;
        }
    }
}

#navigation-header {
    background-color: #f5f5f5;
    box-shadow: -2px 2px 4px -2px rgba(0,0,0,0.4);
    z-index: 18;
    .main {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;

        .md-nav-item{
            :first-of-type {
                margin-left: 0px;
            }
        }

        .md-button {
            min-width: 42px;
        }
    }

    .search {
        input[type="text"] {
            border: 1px solid #ddd;
            border-radius: $material-radius;
            padding: $main-padding;
            box-sizing: border-box;
            width: 100%;
            margin: 0;
            background-color: white;
            .md-errors-spacer {
                display: none;
            }
        }

        $duration-opacity: 0.1s;
        $duration-height: 0.2s;
        max-height: 0;
        opacity: 0;
        visibility: hidden;

        // Animation when disappearing
        transition: opacity $duration-opacity linear,
        max-height $duration-height ease-out $duration-opacity,
        visibility 0s linear $duration-height;

        &.visible {
            padding: $main-padding;
            max-height: 50px;
            opacity: 1;
            visibility: visible;

            // Animation when appearing
            transition: visibility 0s,
            max-height $duration-height ease-in,
            opacity $duration-opacity linear $duration-height;
        }
    }
}

#navigation-conversations,
#navigation-contacts {
    .empty {
        color: $material-grey;
        margin-top: 1em;
        margin-left: 4px;
        font-size: 1.2em;
        font-weight: 300;
    }

}

#navigation-conversations {
    $border-width: 4px;
    $border-count: 2;
    overflow-y: auto;
    background-color: white;
    flex: 1;
    .loading-element {
        margin-top: 50px;
    }

    .conversation-wrapper {
        display: block;
        @include nav-item-separator;

        .conversation {
            display: flex;
            flex-direction: row;
            align-items: center;
            padding: (1.5 * $main-padding) $main-padding - ($border-width * ($border-count - 1));
            border-left: $border-width * $border-count solid white;

            &.active, &:hover {
                background-color: $dark-background-color;
                border-color: $dark-background-color;
            }
            &:hover:not(.active) {
                @include mouse-hand;
            }

            // Only unread
            &.unread {
                border-image: linear-gradient(to right, $status-error, $status-error 50%, white 50%, white 100%) 1 100%;
                &.active {
                    border-image: linear-gradient(to right, $status-error, $status-error 50%, $dark-background-color 50%, $dark-background-color 100%) 1 100%;
                }
            }

            // Only starred
            &.starred {
                border-image: linear-gradient(to right, $status-starred, $status-starred 50%, white 50%, white 100%) 1 100%;
                &.active {
                    border-image: linear-gradient(to right, $status-starred, $status-starred 50%, $dark-background-color 50%, $dark-background-color 100%) 1 100%;
                }
            }

            // Both starred and unread
            &.starred.unread {
                border-image: linear-gradient(to right, $status-error, $status-error 50%, $status-starred 50%, $status-starred 100%) 1 100%;
            }

            .avatar-box {
                margin-right: 8px;
                position: relative;
                .loading {
                    position: absolute;
                }
            }

            .conversation-box {
                flex-grow: 1;
                display: flex;
                flex-direction: column;
                overflow: hidden;

                .receiver-box,
                .message-box {
                    flex-wrap: nowrap;
                    line-height: 1.4em;

                }

                .receiver-box {
                    flex-grow: 1;
                    display: flex;
                    flex-direction: row;
                    justify-content: space-between;
                    font-weight: bold;
                    color: black;
                    .title {
                        flex: 1;
                        white-space: nowrap;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        margin-right: $main-padding;
                    }
                    .disabled {
                        text-decoration: line-through;
                    }
                    .muted {
                        margin: 1px 0 0 4px;
                        padding: 0;
                        height: 20px;
                        i {
                            color: $material-grey;
                            font-size: 20px;
                            margin: 0;
                            padding: 0;
                        }
                    }
                }

                .message-box {
                    flex-grow: 1;

                    .latest-message {
                        display: flex;
                        flex-direction: row;
                        justify-content: space-between;
                        align-items: center;
                        color: rgba(0, 0, 0, 0.54); // TODO: Extract color

                        .left {
                            white-space: nowrap;
                            overflow: hidden;
                            text-overflow: ellipsis;
                            display: flex;

                        }

                        .right {
                            flex-shrink: 0;
                            text-align: right;
                            margin-left: 24px;

                            .draft {
                                color: #C62828;
                            }
                        }

                        .message-name, .message-text {
                            line-height: 1.7em;
                        }

                        .message-name:after {
                            content: ':';
                            margin-right: 4px;
                        }

                        .message-text {
                            white-space: nowrap;
                            overflow: hidden;
                            text-overflow: ellipsis;
                        }

                        &.is-hidden {
                            .no-hidden {
                                display: none;
                            }
                        }

                        &.is-typing {
                            .no-typing {
                                display: none;
                            }
                        }

                        &.show-draft {
                            .no-draft {
                                display: none;
                            }
                        }

                        &:not(.is-typing) {
                            .typing {
                                display: none;
                            }
                        }
                        &:not(.show-draft) {
                            .draft {
                                display: none;
                            }
                        }

                        &:not(.is-hidden) {
                            .hidden {
                                display: none;
                            }
                        }
                    }
                }
            }

            .badge.unread-count {
                background-color: $status-error;
                border-radius: 5px;
                color: white;
                font-size: 0.9em;
                padding: 0 5px;
                margin-left: 4px;
            }
        }
    }
}

#navigation-contacts {
    overflow-y: scroll;
    flex: 1;

    .contact {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        padding: 12px 8px;
        border-left: 4px solid white;

        @include nav-item-separator;

        .avatar-box {
            padding-right: 8px;
        }

        .left {
            flex-grow: 1;
            display: flex;
            flex-direction: column;
        }

        .right {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
        }

        .name {
            font-weight: bold;
        }

        .nickname {
            font-size: 0.8em;
        }
    }

    .contact:hover {
        @include mouse-hand;
        background-color: #f5f5f5;
    }

    .contact.inactive {
        opacity: 0.5;
    }
}

#navigation-fab {
    position: relative;

    md-icon {
        color: white;
    }

    .fab-button-add-contact {
        background-color: #D32F2F;
    }
    .fab-button-add-group {
        background-color: #FF9800;
    }
    .fab-button-add-distribution-list {
        background-color: #3F51B5;
    }
}
