/* ************************************************************
    DbqChatControl
************************************************************ */

$chat-max-width: 768px;

$chat-item-self-background-color: $color-subtle;
$chat-item-self-text-color: $text-color-default;
$chat-item-self-create-time-text-color: $color-primary;
$chat-item-other-background-color: $color-layer-3;
$chat-item-other-text-color: $text-color-default;

$chat-item-margin: $margin-default;
$chat-item-padding: $padding-default;
$chat-item-border-radius: $border-radius-default;

$chatbox-background-color: $background-item-color-default;

.dbqchat {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    clear: both;
    margin: 0;
    padding: 0;
    background-color: $classlist-background;
    // border-radius: $border-radius-default;
    box-shadow: none;

    &[data-is-loading="true"] {
        min-height: (100 + ($padding-default * 2));

        .dbqchat-loading {
            display: block;
        }
    }

    .dbqchat-loading {
        display: none;
        position: absolute;
        inset: 0;
    }

    .dbqchat-window {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-between;
        position: relative;
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        @include scrollbar;

        .dbqchat-items {
            width: 100%;
            max-width: $chat-max-width;
            flex-grow: 1;
            display: flex;
            flex-direction: column;
            gap: 0;
            padding: 0;
        }
    }

    .dbqchat-error {
        padding: $padding-default;
    }

    .dbqchat-processing {
        margin: 5px 0 $margin-default 0;
    }

    .dbqchat-processing-text {
        text-align: center;
        color: $text-color-default;
        width: 80%;
        margin: $margin-default auto 0;
    }

    .dbqchat-empty {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 30px;
        padding: $padding-default;
        color: $text-color-default;
        text-align: center;
    }

    .dbqchat-item-container {
        position: relative;
        display: flex;
        flex-direction: column;
        margin: $chat-item-margin 0;
        cursor: pointer;
    }

    .dbqchat-item {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        max-width: 90%;
        gap: 0;
    }

    .dbqchat-item-self {
        align-self: flex-end;
    }

    .dbqchat-item-other {
        align-self: flex-start;
    }

    .dbqchat-item-avatar,
    .dbqchat-item-initials {
        background: $chat-item-other-background-color;
        width: 64px;
        height: 64px;
        flex-shrink: 0;
        border-radius: 50%;
        overflow: hidden;
        z-index: 1;
    }

    .dbqchat-item-initials {
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        font-size: 24px;
    }

    .dbqchat-item-avatar img {
        width: 100%;
        height: 100%;
    }

    .dbqchat-item-body {
        min-width: 0;
        max-width: calc(100% - 64px - #{$chat-item-margin});
        padding: $chat-item-padding;
        border-radius: $chat-item-border-radius;
    }

    .dbqchat-item-self .dbqchat-item-body {
        background: $chat-item-self-background-color;
        color: $chat-item-self-text-color;
    }

    .dbqchat-item-other .dbqchat-item-body {
        background: $chat-item-other-background-color;
        color: $chat-item-other-text-color;
    }

    .dbqchat-item-self .dbqchat-item-avatar,
    .dbqchat-item-self .dbqchat-item-initials {
        margin-left: $chat-item-margin;
    }

    .dbqchat-item-other .dbqchat-item-avatar,
    .dbqchat-item-other .dbqchat-item-initials {
        margin-right: $chat-item-margin;
    }

    .dbqchat-item-text {
        word-break: break-word;

        p {
            font-size: $font-size-base;
            font-weight: normal;
            line-height: 1.5;

            &:last-of-type {
                margin-bottom: 0;
            }
        }

        ol,
        ul {
            li {
                font-size: $font-size-base;
                font-weight: normal;
                line-height: 1.5;
            }
        }
    }

    .dbqchat-item-meta {
        display: flex;
        gap: 10px;
        align-items: center;
        margin-bottom: 4px;
        font-size: 12px;
        opacity: 0.75;
    }

    .dbqchat-item-time {
        color: $color-gray-dark;
        font-size: 13px;
        font-weight: 500;
        margin-top: 2px;
    }

    .dbqchat-item-self .dbqchat-item-time {
        text-align: end;
        color: $chat-item-self-create-time-text-color;
    }
                    
    .dbqchat-item-actions {
        .dbqchat-item-action {
            @include button-link;
            margin-right: 8px;

            &:last-child {
                margin-right: 0;
            }
        }
    }

    .dbqchat-item-selected {
        .dbqchat-item-self .dbqchat-item-body {
            box-shadow: inset 0 0 0 2px $color-primary;
        }

        .dbqchat-item-other .dbqchat-item-body {
            box-shadow: inset 0 0 0 2px $color-layer-4;
        }
    }

    .dbqchat-item-container:hover {
        .dbqchat-item-self .dbqchat-item-body {
            background: darken($chat-item-self-background-color, 5);
        }

        .dbqchat-item-other .dbqchat-item-body {
            background: darken($chat-item-other-background-color, 5);
        }
    }

    .dbqchat-divider {
        position: relative;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        margin: 8px 0;

        .dbqchat-divider-title {
            background: $color-layer-3;
            border-radius: $border-radius-default;
            color: $text-color-default;
            padding: 5px 10px;
            z-index: 1;
            font-size: 12px;
            opacity: 1;
        }
    }

    .dbqchat-composer {
        display: flex;
        flex-shrink: 0;
        align-self: center;
        position: relative;
        width: 100%;
        max-width: $chat-max-width;
        background: $chatbox-background-color;
        border-radius: 28px;
    }

    .dbqchat-composer {
        .dbqmd-form-group {
            flex-grow: 1;
            box-shadow: none;

            .dbqmd-label {
                background: $chatbox-background-color !important;
                width: calc(100% - 56px);
                border-bottom: none;
                border-radius: 28px 0 0 28px;

                .dbqmd-textarea,
                .dbqchat-textarea {
                    background: $chatbox-background-color !important;
                    border-top-color: $chatbox-background-color !important;
                    border-bottom: none;
                    resize: none !important;
                }

                .dbqmd-ripple {
                    display: none;
                }
            }
        }
    }

    .dbqchat-send-button {
        @include button;
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        right: 10px;
        bottom: 10px;
        width: 36px;
        height: 36px;
        margin-top: 0;
        border-radius: 50%;
        outline: none;
        z-index: 2;

        svg {
            width: 24px;
            height: 24px;
            fill: $color-white;
        }
    }

    .dbqchat-scroll-bottom {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        top: -45px;
        z-index: 3;
    }

    .dbqchat-scroll-bottom-button {
        display: flex;
        align-items: center;
        justify-content: center;
        outline: none;
        border: none;
        width: 36px;
        height: 36px;
        background-color: $chatbox-background-color;
        border-radius: 50%;

        svg {
            width: 16px;
            height: 16px;
            fill: $text-color-default;
        }
    }

    &.dbqchat-in-multipanel {
        background-color: unset;

        .dbqchat-window {
            margin: 0 $margin-default $margin-default $margin-default;
            background-color: $classlist-background;
			border: 1px solid $global-border-color;
			@include border-radius($global-border-radius);
            @include scrollbar;

            .dbqchat-items {
                padding: 0 $padding-default;
            }
        }
    }
}
