/* Copyright 2019 Alexandre Díaz
   License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). */
// FIXME: More of these classes are cloned from other scss files.
.o_mail_failed_message {
    &.o_field_widget {
        display: block;
    }

    .o_thread_date_separator.o_border_dashed {
        border-bottom-style: dashed;

        &[data-toggle="collapse"] {
            cursor: pointer;

            .o_chatter_failed_message_summary {
                display: none;
            }

            &.collapsed {
                margin-bottom: 0;
                transition: margin 0.8s ease 0s;

                .o_chatter_failed_message_summary {
                    display: inline-block;

                    span {
                        padding: 0 5px;
                        border-radius: 100%;
                        font-size: 11px;
                    }
                }

                i.fa-caret-down:before {
                    content: "\f0da";
                }
            }
        }
    }

    .o_thread_show_more {
        text-align: center;
    }

    .o_mail_thread_content {
        display: flex;
        flex-direction: column;
        min-height: 100%;
    }

    .o_thread_bottom_free_space {
        height: 15px;
    }

    .o_thread_typing_notification_free_space {
        flex-grow: 1;
    }

    .o_thread_typing_notification_bar {
        flex: 0, 0, 20px;
        background-color: rgba($white, 0.75);
        padding: 5px;
        text-align: center;
        color: gray("600");

        &.o_thread_order_asc {
            @include o-position-sticky($bottom: 0px);
        }

        &.o_thread_order_desc {
            @include o-position-sticky($top: 0px);
        }
    }

    .o_thread_tooltip_container {
        display: inline;
        position: relative;
    }

    .o_thread_date_separator {
        margin-top: 15px;
        margin-bottom: 30px;
        @include media-breakpoint-down(sm) {
            margin-top: 0px;
            margin-bottom: 15px;
        }
        border-bottom: 1px solid gray("400");
        text-align: center;

        .o_thread_date {
            position: relative;
            top: 10px;
            margin: 0 auto;
            padding: 0 10px;
            font-weight: bold;
            background: white;
        }
    }

    .o_thread_new_messages_separator {
        margin-bottom: 15px;
        border-bottom: solid lighten($o-brand-odoo, 15%) 1px;
        text-align: right;
        .o_thread_separator_label {
            position: relative;
            top: 8px;
            padding: 0 10px;
            background: white;
            color: lighten($o-brand-odoo, 15%);
            font-size: smaller;
        }
    }

    .o_thread_message {
        display: flex;
        padding: 4px $o-horizontal-padding;
        margin-bottom: 0px;

        &.o_mail_not_discussion {
            background-color: rgba(gray("300"), 0.5);
            border-bottom: 1px solid gray("400");
        }

        .o_thread_message_sidebar {
            flex: 0 0 $o-mail-thread-avatar-size;
            margin-right: 10px;
            margin-top: 2px;
            text-align: center;
            font-size: smaller;

            @include media-breakpoint-down(sm) {
                margin-top: 4px;
                font-size: x-small;
            }

            .o_thread_message_avatar {
                max-width: $o-mail-thread-avatar-size;
            }
            .o_thread_message_side_date {
                margin-left: -5px;
            }
            .o_thread_message_star {
                margin-right: -5px;
            }

            .o_thread_message_side_date {
                opacity: 0;
            }
        }
        .o_thread_icon {
            cursor: pointer;
            opacity: 0;
            &.fa-star {
                opacity: $o-mail-thread-icon-opacity;
                color: gold;
            }
        }

        &:hover,
        &.o_thread_selected_message {
            .o_thread_message_side_date {
                opacity: $o-mail-thread-side-date-opacity;
            }
            .o_thread_icon {
                opacity: $o-mail-thread-icon-opacity;
                &:hover {
                    opacity: 1;
                }
            }
        }

        .o_mail_redirect {
            cursor: pointer;
        }

        .o_thread_message_core {
            flex: 1 1 auto;
            min-width: 0;
            max-width: 100%;
            word-wrap: break-word;
            > pre {
                white-space: pre-wrap;
                word-break: break-word;
                text-align: justify;
            }

            .o_mail_subject {
                font-style: italic;
            }

            .o_mail_notification {
                font-style: italic;
                color: gray;
            }

            [summary~="o_mail_notification"] {
                // name conflicts with channel notifications, but is odoo notification buttons to hide in chatter if present
                display: none;
            }

            p {
                margin: 0 0 9px; // Required by the old design to override a general rule on p's
                &:last-child {
                    margin-bottom: 0;
                }
            }
            a {
                display: inline-block;
                word-break: break-all;
            }
            :not(.o_image_box) > img {
                max-width: 100%;
                height: auto;
            }

            .o_mail_body_long {
                display: none;
            }

            .o_mail_info {
                margin-bottom: 2px;

                strong {
                    color: $headings-color;
                }
            }

            .o_thread_message_star,
            .o_thread_message_needaction,
            .o_thread_message_reply,
            .o_thread_message_email {
                padding: 4px;
            }

            i.o_thread_message_email {
                &.o_thread_message_email_ready {
                    color: grey;
                }
                &.o_thread_message_email_exception,
                &.o_thread_message_email_bounce {
                    color: red;
                    opacity: 1;
                    cursor: pointer;
                }
            }

            .o_attachments_list,
            .o_attachments_previews {
                &:last-child {
                    margin-bottom: $grid-gutter-width;
                }
            }

            .o_thread_tooltip_container {
                display: inline;
                position: relative;
            }
        }
    }
    .o_thread_title {
        margin-top: 20px;
        margin-bottom: 20px;
        font-weight: bold;
        font-size: 125%;
    }

    .o_mail_no_content {
        @include o-position-absolute(30%, 0, 0, 0);
        text-align: center;
        font-size: 115%;
    }

    .o_thread_message .o_thread_message_core .o_mail_read_more {
        display: block;
    }

    #o_chatter_failed_message {
        .o_thread_message {
            .o_thread_message_sidebar {
                .o_avatar_stack {
                    position: relative;
                    text-align: left;
                    margin-bottom: 8px;

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

                    .o_avatar_icon {
                        @include o-position-absolute($right: -5px, $bottom: -5px);
                        width: 25px;
                        height: 25px;
                        padding: 6px 5px;
                        text-align: center;
                        line-height: 1.2;
                        color: white;
                        border-radius: 100%;
                        border: 2px solid white;
                    }
                }
            }

            .o_mail_info {
                .o_activity_info {
                    vertical-align: baseline;
                    padding: 4px 6px;
                    background: theme-color("light");
                    border-radius: 2px 2px 0 0;
                    @include o-hover-opacity(1, 1);

                    &.collapsed {
                        @include o-hover-opacity(0.5, 1);
                        background: transparent;
                    }
                }
            }

            .o_thread_message_collapse .dl-horizontal.card {
                display: inline-block;
                margin-bottom: 0;

                dt {
                    max-width: 80px;
                }
                dd {
                    margin-left: 95px;
                }
            }

            .o_thread_message_note {
                margin: 2px 0 5px;
                padding: 0px;
            }
            .o_thread_message_warning {
                margin: 2px 0 5px;
            }

            .o_thread_message_tools {
                .o_failed_message_link {
                    padding: 0 $input-btn-padding-x;
                }
                .o_failed_message_retry {
                    padding-left: 0;
                }
            }
        }
    }
}
