
// The goal of this file is to contain CSS hacks related to allowing
// section and note on sale order and invoice.

table.o_section_and_note_list_view {
    --o-SectionAndNote-border-color: #{$gray-500};

    tr {
        &.o_is_line_note {
            font-style: italic;
        }

        &.o_is_line_section, &.o_is_line_subsection {
            --table-striped-bg: var(--table-bg-type);

            .o_list_section_options {
                width: 1px;  // to prevent the column to expand
            }

            .o_field_product_label_section_and_note_cell .o_input {
                text-overflow: ellipsis;
            }
        }

        &.o_is_line_section {
            --table-hover-bg: #{rgba($body-emphasis-color, .1)};
            --table-bg-type: #{rgba($body-emphasis-color, .08)};
            --ListRenderer-data-row-focused-striped-bg: var(--table-bg-type);

            font-weight: $font-weight-bolder;

            &:where(:not(:empty)) {
                // When dragging, an empty tr is created we don't want
                // a border here.
                border-top-color: var(--o-SectionAndNote-border-color);
            }

            &.o_dragged {
                border-width: $border-width 0;
            }
        }

        &.o_is_line_subsection {
            --table-hover-bg: #{rgba($body-emphasis-color, .05)};
            --table-bg-type: #{rgba($body-emphasis-color, .03)};

            font-weight: $font-weight-bold;
        }

        // Check if next sibling is a section to apply a border-color.
        &:where(:not(.o_dragged):has(+ .o_is_line_section:not(.o_dragged, .d-table-row))) {
            border-color: var(--o-SectionAndNote-border-color);
        }
    }

    // Check if first tr in the table is a section to apply a border-color on
    // the <th> els.
    &:where(:has(tbody > tr:first-child.o_is_line_section:not(.o_dragged, .d-table-row))) th {
        border-color: var(--o-SectionAndNote-border-color);
    }
}

.o_field_section_and_note_text {
    > span {
        white-space: pre-wrap !important;
    }
}
