@import "~theme/globals.scss";

:host-context(.ios) {
    ion-footer .toolbar:last-child {
        padding-bottom: 4px;
        min-height: 0;
    }
}

ion-content {
    --content-background: var(--background-alternative);
    --background: var(--content-background);

    &::part(scroll) {
        padding-bottom: 0 !important;
    }
}

.addon-messages-discussion-container {
    display: flex;
    flex-direction: column;
    padding-bottom: 16px !important;
    background: var(--content-background);
}

.addon-messages-date {
    font-weight: normal;
    font-size: 0.9rem;
}

// Message item.
ion-item.addon-message {
    --message-background: var(--addon-messages-message-bg);
    --message-activated-background: var(--addon-messages-message-activated-bg);
    --message-alignment: flex-start;

    border: 0;
    border-radius: var(--medium-radius);
    padding: 0 8px 0 8px;
    margin: 8px;
    --background: var(--message-background);
    background: var(--message-background);
    align-self: var(--message-alignment);
    width: 90%;
    max-width: var(--list-item-max-width);
    --min-height: var(--a11y-min-target-size);
    position: relative;
    @include core-transition(width);
    // This is needed to display bubble tails.
    overflow: visible;

    &::part(native) {
        --inner-border-width: 0px;
        --inner-padding-end: 0px;
        padding: 0;
        margin: 0;
    }

    &:hover {
        -webkit-filter: drop-shadow(2px 2px 2px rgba(0,0,0,.3));
        filter: drop-shadow(2px 2px 2px rgba(0,0,0,.3));
    }

    core-format-text > p:only-child {
        display: inline;
    }

    .addon-message-user {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-bottom: .5rem;
        margin-top: 0;
        color: var(--ion-text-color);

        core-user-avatar {
            display: block;
            --core-avatar-size: var(--addon-messages-avatar-size);
            margin: 0;
        }

        div {
            font-weight: 500;
            flex-grow: 1;
            padding-left: .5rem;
            padding-right: .5rem;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
    }

    ion-note {
        color: var(--addon-messages-message-note-text);
        font-size: var(--addon-messages-message-note-font-size);
        margin: 0;
        padding: 8px 0;
        align-self: flex-start;
    }

    &[tappable]:active {
        --message-background: var(--message-activated-background);
    }

    ion-label {
        margin: 0;
        padding: 8px 0;
    }

    .addon-message-text {
        display: inline-flex;
        * {
            color: var(--ion-text-color);
        }
    }

    .tail {
        content: '';
        width: 0;
        height: 0;
        border: 0.5rem solid transparent;
        position: absolute;
        touch-action: none;
        bottom: 0;
        border-bottom-color: var(--message-background);
    }

    // Defines when an item-message is the user's.
    &.addon-message-mine {
        --message-background: var(--addon-messages-message-mine-bg);
        --message-activated-background: var(--addon-messages-message-mine-activated-bg);
        --message-alignment: flex-end;

        .spinner {
            @include float(end);
            @include margin(2px, -3px, -2px, 5px);

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

        .tail {
            @include position(null, -8px, null, null);
            @include margin-horizontal(null, -0.5rem);
        }
    }

    &.addon-message-not-mine .tail {
        @include position(null, null, null, -8px);
        @include margin-horizontal(-0.5rem, null);
    }

    .addon-messages-delete-button {
        min-height: initial;
        line-height: initial;
        margin-top: 0px;
        margin-bottom: 0px;
        height: var(--a11y-min-target-size) !important;
        align-self: flex-end;

        ion-icon {
            font-size: 1.4em;
            line-height: initial;
            color: var(--danger);
        }
    }

    &.addon-message-no-user {
        margin-top: 0px;
    }
}
