@use "sass:math";

$eccgui-propertyvalue-size-column-breakpoint-small: 20rem !default;

.#{$eccgui}-propertyvalue__list {
    display: block;
}

.#{$eccgui}-propertyvalue__pair {
    clear: both;
    display: block;
    width: 100%;
    container-name: eccgui-propertyvalue-pair;
    container-type: inline-size;

    &.#{$eccgui}-propertyvalue__pair--hasdivider {
        &:not(:last-child) {
            border-bottom: solid 1px $pt-divider-black;
        }
    }
    &.#{$eccgui}-propertyvalue__pair--hasspacing {
        &:not(:last-child) {
            padding-bottom: $eccgui-size-block-whitespace * 0.5;
            margin-bottom: $eccgui-size-block-whitespace * 0.5;
        }
        .#{$eccgui}-propertyvalue__pair + & {
            margin-top: $eccgui-size-block-whitespace * 0.5;
        }
    }

    .#{$eccgui}-label {
        color: inherit;
    }
}

.#{$eccgui}-propertyvalue__property,
.#{$eccgui}-propertyvalue__value {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;

    :not(.#{$eccgui}-propertyvalue__pair--singlecolumn) > & {
        @container eccgui-propertyvalue-pair (width >= #{$eccgui-propertyvalue-size-column-breakpoint-small}) {
            min-height: $eccgui-size-textfield-height-regular;
        }

        @container eccgui-propertyvalue-pair (width < #{$eccgui-propertyvalue-size-column-breakpoint-small}) {
            &.#{$eccgui}-propertyvalue__value {
                margin-bottom: $eccgui-size-inline-whitespace * 0.5;
            }
        }
    }
}

.#{$eccgui}-propertyvalue__property {
    :not(.#{$eccgui}-propertyvalue__pair--singlecolumn) > & {
        @container eccgui-propertyvalue-pair (width >= #{$eccgui-propertyvalue-size-column-breakpoint-small}) {
            bottom: -1px;
            float: left;
            width: math.div(3, 16) * 100%;
            overflow: hidden;

            & > div {
                margin-right: $eccgui-size-block-whitespace;
            }

            .#{$eccgui}-label {
                line-height: normal;
            }
        }
    }

    .#{$eccgui}-label:has(.#{$eccgui}-typography__overflowtext) {
        display: inline-flex;
        align-items: baseline;
        max-width: 100%;

        span {
            flex-grow: 0;
            flex-shrink: 1;
            min-width: 0;
        }

        .#{$eccgui}-label__tooltip,
        .#{$eccgui}-label__other {
            position: relative;
            bottom: -1px;
        }
    }
}

.#{$eccgui}-propertyvalue__value {
    box-sizing: content-box;

    :not(.#{$eccgui}-propertyvalue__pair--singlecolumn) > & {
        @container eccgui-propertyvalue-pair (width >= #{$eccgui-propertyvalue-size-column-breakpoint-small}) {
            margin-left: math.div(3, 16) * 100%;
        }
    }

    &:not(:last-child) {
        .#{$eccgui}-propertyvalue__pair--hasdivider > & {
            border-bottom: solid 1px $pt-divider-black;
        }
        .#{$eccgui}-propertyvalue__pair--hasspacing > & {
            padding-bottom: $eccgui-size-block-whitespace * 0.5;
            margin-bottom: $eccgui-size-block-whitespace * 0.5;
        }
    }
}

.#{$eccgui}-propertyvalue__property--small {
    :not(.#{$eccgui}-propertyvalue__pair--singlecolumn) > & {
        @container eccgui-propertyvalue-pair (width >= #{$eccgui-propertyvalue-size-column-breakpoint-small}) {
            width: math.div(2, 16) * 100%;

            & + .#{$eccgui}-propertyvalue__value {
                margin-left: math.div(2, 16) * 100%;
            }
        }
    }
}

.#{$eccgui}-propertyvalue__property--large {
    :not(.#{$eccgui}-propertyvalue__pair--singlecolumn) > & {
        @container eccgui-propertyvalue-pair (width >= #{$eccgui-propertyvalue-size-column-breakpoint-small}) {
            width: math.div(5, 16) * 100%;

            & + .#{$eccgui}-propertyvalue__value {
                margin-left: math.div(5, 16) * 100%;
            }
        }
    }
}

.#{$eccgui}-propertyvalue__property--nowrap {
    overflow: visible;
    white-space: nowrap;
}

@media print {
    .#{$eccgui}-propertyvalue__pair,
    .#{$eccgui}-propertyvalue__property,
    .#{$eccgui}-propertyvalue__value {
        position: relative;
        float: none !important;
        display: block;
        width: auto;
        height: auto;
        min-height: 0 !important;
        padding: 0;
        margin: 0 !important;

        &:is(.#{$eccgui}-propertyvalue__property) {
            margin-bottom: 0.25 * $eccgui-size-block-whitespace !important;
        }
        &:is(.#{$eccgui}-propertyvalue__pair) {
            margin-bottom: 0.5 * $eccgui-size-block-whitespace !important;
        }
    }
}
