/* ************************************************************
   DbqRightSidebarController
************************************************************ */

$right-sidebar-width-expanded: 320px;
$right-sidebar-width-collapsed: 80px;

$right-sidebar-inner-padding: 10px;

$multi-panel-layout-options-svg-size: 24px;

.dbqrs {
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
    height: 100%;

    .dbqrs-collapse-button {
        position: absolute;
        left: -15px;
        top: 15px;
        z-index: 1;
        @include list-collapse-button;
    }

    .dbqrs-top {
        flex: 0 0 auto;
        padding: 10px 15px 0 15px;

        // .dbqrs-multipanel-layout-options {
        //     display: flex;
        //     flex-wrap: wrap;
        //     gap: 8px;

        //     .dbqrs-layout-option {
        //         display: inline-flex;
        //         align-items: center;
        //         justify-content: center;
        //         background: none;
        //         border: none;
        //         outline: 0;

        //         svg {
        //             padding: 3px;
        //             fill: $text-color-default;
        //             width: $multi-panel-layout-options-svg-size;
        //             height: $multi-panel-layout-options-svg-size;
        //         }

        //         &:hover {
        //             svg {
        //                 fill: $color-primary;
        //             }
        //         }

        //         &.dbqrs-layout-option-active {
        //             svg {
        //                 fill: $color-primary;
        //             }
        //         }
        //     }   
        // }
    }

    .dbqrs-main {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;

        .dbqrs-view {
            display: flex;
            flex-direction: column;
            flex: 1 1 auto;
            min-height: 0;

            // Channels
            &.dbqrs-view-channels {
                padding: 0 15px;

                .dbqrs-channel-list {
                    display: flex;
                    flex-direction: column;
                    gap: 1px;

                    .dbqrs-channel-item-row {
                        display: flex;
                        align-items: center;
                        justify-content: space-between;
                        border-radius: $multi-panel-view-border-radius;
                        width: 100%;
                        gap: 8px;
                        padding: 3px 3px 3px 10px;

                        .dbqrs-channel-item {
                            color: $multi-panel-view-active-color;
                            background: none;
                            border: none;
                            outline: none;

                            .dbqrs-channel-label {
                                flex: 1 1 auto;
                                min-width: 0;
                                text-align: left;
                            }

                            .dbqrs-channel-badge {
                                margin-left: 5px;
                                @include alert-badge;
                            }
                        }

                        &:hover {
                            background: $sidebar-tile-background-hover;

                            .dbqrs-channel-item-inner {
                            }

                            .dbqrs-channel-prefix,
                            .dbqrs-channel-label {
                                color: $text-color-default;
                                font-weight: $font-weight-bold;
                            }
                        }
                    }
                }
            }

            //  Chats
            &.dbqrs-view-chat {
                .dbqrs-chat-header {
                    display: flex;
                    align-items: center;
                    gap: 8px;
                    margin-bottom: 12px;
                    padding: 0 $right-sidebar-inner-padding;

                    .dbqrs-chat-back-trigger {
                        display: inline-flex;
                        align-items: center;
                        background: none;
                        border: none;
                        border-radius: $multi-panel-view-border-radius;
                        outline: none;
                        cursor: pointer;
                        color: inherit;
                        gap: 8px;
                        min-width: 0;
                        width: 100%;
                        padding: 3px;

                        .dbqrs-chat-back-button {
                            display: inline-flex;
                            align-items: center;
                            justify-content: center;
                            flex: 0 0 auto;
                            opacity: 0.75;

                            svg {
                                fill: $text-color-default;
                                width: 18px;
                                height: 18px;
                            }
                        }

                        .dbqrs-chat-title {
                            width: 100%;
                            min-width: 0;
                            font-weight: 600;
                            text-align: left;
                            font-size: 12px;
                            font-weight: 600;
                            text-transform: uppercase;
                            letter-spacing: 0.06em;
                            opacity: 0.75;
                        }

                        &:hover {
                            background: $sidebar-tile-background-hover;

                            .dbqrs-channel-item-inner {
                            }

                            .dbqrs-channel-prefix,
                            .dbqrs-channel-label {
                                color: $text-color-default;
                                font-weight: $font-weight-bold;
                            }
                        }
                    }
                }

                .dbqrs-chat-body {
                    min-height: 0;
                    flex: 1 1 auto;

                    .dbqchat {
                        height: 100%;
                        min-height: 0;
                        border-radius: 0;

                        .dbqchat-window {
                            min-height: 0;
                            padding: $padding-default;
                            @include scrollbar;

                            // Chat items
                            .dbqchat-item-container {
                                .dbqchat-item-avatar {
                                    width: 36px;
                                    height: 36px;
                                }

                                .dbqchat-item-body {

                                }
                            }

                            // News feed items
                            .dbqrs-news-item-container {
                                width: 100%;

                                .dbqnf-container {
                                    height: auto;
                                    overflow: visible;
                                    padding: 0;
                                    margin: 0;
                                }

                                .dbqnf-item {
                                    width: 100%;
                                }

                                .dbqnf-title {
                                    color: $text-color-default;
                                }

                                .dbqnf-summary-text {
                                    color: $text-color-default;
                                }
                            }
                        }

                        .dbqchat-composer {
                            width: calc(100% - $margin-default - $margin-default);
                            margin: 0 $margin-default $margin-default $margin-default;
                        }
                    }
                }
            }
        }
    }

    .dbqrs-section {
        min-height: 0;
        margin-bottom: $right-sidebar-inner-padding;

        .dbqrs-section-title {
            margin-bottom: $right-sidebar-inner-padding;
            font-size: 12px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.06em;
            opacity: 0.75;
        }

        .dbqrs-section-title-secondary {
            margin-top: 16px;
        }
    }

    
    .dbqrs-collapsed-menu-item-container {
        display: none;
        position: relative;
    }

    .dbqrs-multipanel-layout-options {
        display: flex;
    }

    .dbqrs-multipanel-layout-options,
    .dbqrs-collapsed-menu-item-container {

        .dbqrs-collapsed-menu-item {
            width: 100%;
        }

        .dbqrs-layout-option,
        .dbqrs-collapsed-menu-item {
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 40px;
            padding: 8px;
            background: transparent;
            border: none;
            outline: none;
            cursor: pointer;
            color: $text-color-default;
            border-radius: $border-radius-default;
             
            &:hover {
                background: $sidebar-tile-background-hover;
            }

            .dbqrs-layout-option-icon {
                //padding: 2px;
            }

            .dbqrs-layout-option-icon,
            .dbqrs-collapsed-menu-item-icon {
                display: flex;
                align-items: center;
                justify-content: center;
                //width: 20px;
                //height: 20px;

                svg {
                    width: 24px;
                    height: 24px;
                    fill: currentColor;
                    
                    [class^="panel-"] {
                        fill-opacity: 0;
                    }

                    .panel-background {
                        fill-opacity: 1;
                        fill: currentColor;
                    }
                }
            }

            .dbqrs-collapsed-menu-item-badge {
                display: inline-flex;
                position: absolute;
                top: 0;
                right: -3px;
                margin-right: 5px;
                @include alert-badge;
            }
        }

        // Active styling
        .dbqrs-layout-option {
            &.dbqrs-layout-option-active {                   
                background: color(subtle);
                background: color(primary-tone, 90);

                .dbqrs-layout-option-icon {
                    svg {
                        fill: $dbqft-list-item-color;
                        fill: $color-primary;

                        .panel-background {
                            fill: $color-primary;
                        }
                    }
                }
            }
        }

        .dbqrs-popover-content {
            display: none;
        }
    }

    .dbqrs-collapsed-multipanels-popover-host,
    .dbqrs-collapsed-channels-popover-host {
        display: none;
    }

    // Collapsed menu
    &.dbqrs-collapsed {
        .dbqrs-top {
            .dbqrs-multipanel-layout-options {
                flex-direction: column;
                justify-content: center;
            }
        }

        .dbqrs-main {
            .dbqrs-view {
                &.dbqrs-view-channels {
                    .dbqrs-channel-list {
                        display: none;
                    }            
                }
            }
        }

        .dbqrs-section {
            margin-bottom: 0;
        }

        .dbqrs-section-title,
        .dbqrs-multipanel-view-items {
            display: none;
        }

        .dbqrs-collapsed-menu-item-container {
            display: block;
        }
    }

    // Expanded menu
    &.dbqrs-expanded {
        .dbqrs-collapsed-menu-item-container {
            display: none;
        }
    }
}

.dbqrs-multipanel-view-items {
    display: flex;
    flex-direction: column;
    gap: $multi-panel-view-inner-padding;
    max-height: $multi-panel-dropdown-view-items-max-height;
    overflow-x: hidden;
    overflow-y: auto;
    @include scrollbar;
}

.dbqrs-popover-content {
    position: absolute;
    z-index: 1000;
    margin: 0;
    border: none;
    padding: 6px 0;
    border-radius: 10px;
    background-color: $dropdown-background-color;
    list-style-type: none;
    min-width: 250px;
    @include shadow;

    .dbqrs-popover-title {
        padding: 6px 15px;
        font-weight: 500;
        font-family: $font-family-default;
        font-size: 14px;
    }

    .dbqrs-channel-list,
    .dbqrs-multipanel-view-items {
        display: flex;
        flex-direction: column;
        padding: 0 15px;
        gap: 0;
    }

    .dbqrs-multipanel-view-items {
        min-width: 160px;
    }

    .dbqrs-channel-item,
    .dbqmp-view-item {
        width: 100%;
        position: relative;
        overflow: unset;
        background-color: transparent;
        border: none;
        cursor: pointer;
    }

    .dbqrs-channel-item-row {
        border-radius: 10px;
        padding: 0 10px;

        .dbqrs-channel-item {
            display: block;
            outline: none;
            padding: 0;

            .dbqrs-channel-item-inner {
                display: flex;
                align-items: center;
                justify-content: space-between;
                background-color: transparent;
                color: $text-color-default;
                border-radius: 6px;
                width: 100%;
                overflow: hidden;
                padding: 2px 0;
                gap: 8px;
            }

            .dbqrs-channel-prefix-container {
                display: flex;
                align-items: center;
                justify-content: center;
                flex: 0 0 auto;
            }

            .dbqrs-channel-label {
                padding: 4px 6px;
                border-radius: 6px;
                font-family: $font-family-default;
                font-size: 14px;
                font-weight: 400;
                white-space: nowrap;
                text-overflow: ellipsis;
                width: 100%;
                max-width: 220px;
                overflow: hidden;
                color: $dropdown-text-color;
                display: inline-flex;
                flex-direction: column;
                text-align: left;

                &::after {
                    content: attr(data-name);
                    content: attr(data-name) / "";
                    height: 0;
                    visibility: hidden;
                    overflow: hidden;
                    user-select: none;
                    pointer-events: none;
                    font-weight: $font-weight-bold;

                    @media speech {
                        display: none;
                    }
                }
            }

            .dbqrs-channel-badge {
                margin-right: 5px;
                flex: 0 0 auto;
                @include alert-badge;
            }

            &.dbqrs-channel-item-active {
                .dbqrs-channel-item-inner {
                    background: color(subtle);
                }

                .dbqrs-channel-label {
                    color: $color-primary;
                    font-weight: 600;
                }
            }
        }
        
        &:hover {
            background: color(gray-7);

            .dbqrs-channel-item {
                .dbqrs-channel-label {
                    color: $text-color-default;
                    font-weight: 600;
                }
            }
        }
    }

    .dbqmp-view-item {
        &:hover {
            background: color(gray-7);
        }
    }
}

.dbqrs-channel-item-row {
    display: flex;
    align-items: center;
    cursor: pointer;

    .dbqrs-channel-item-open-in-panel-button {
        display: none;
        align-items: center;
        justify-content: center;
        @include button-rounded-with-icon;
    }

    &:hover {
        .dbqrs-channel-item-open-in-panel-button {
            display: flex;
        }
    }
}