@import '../default/var';

.#{$prefix}-table {
    position: relative;
    &.is-border {
        .#{$prefix}-table__body {
            border-top: solid 1px $table-color-border;
            border-left: solid 1px $table-color-border;
            td,
            th {
                border-right: solid 1px $table-color-border;
                border-bottom: solid 1px $table-color-border;
            }
        }
    }
    &__loading {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(#fff, .7);
        z-index: 10;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    &__header {
        background: $table-color-header;
        color: $table-color-header-fore;
        table-layout: fixed;
        &__container {
            overflow: hidden;
        }
        td,
        th {
            &:last-of-type {
                .#{$prefix}-table__cell {
                    padding-left: 30px;
                    padding-right: 30px;
                }
            }
        }
        td {
            border-bottom: solid 1px $table-color-border;
        }
    }
    &__body {
        table-layout: fixed;
        &__container {
            position: relative;
            overflow-x: auto;
        }
        tr {
            &:not(.empty) {
                &.is-hover {
                    background: $table-color-hover;
                }
            }
            &.empty {
                td {
                    .#{$prefix}-table__cell {
                        text-align: center;
                        padding: 80px;
                    }
                }
            }
        }
        td {
            border-bottom: solid 1px $table-color-border;
        }
    }
    &__cell {
        line-height: 1.5;
        overflow: hidden;
        text-overflow: ellipsis;
        word-break: break-all;
        &--left {
            text-align: left;
            padding-left: 30px;
        }
        &--center {
            text-align: center;
            padding: 0 30px;
        }
        &--right {
            text-align: right;
            padding-right: 30px;
        }
    }
    &__fixed {
        &--left,
        &--right {
            position: absolute;
            top: 0;
            .#{$prefix}-table__body__container {
                overflow: hidden;
                background: #fff;
            }
            &.scroll-middle,
            &.scroll-left,
            &.scroll-right {
                &:before {
                    content: "";
                    height: 100%;
                    display: block;
                    width: 15px;
                    position: absolute;
                }
            }
        }
        &--left {
            &.scroll-middle,
            &.scroll-right {
                &:before {
                    right: -15px;
                    background-image: linear-gradient(-90deg, rgba(239, 240, 245, 0.00) 0%, #EFF0F5 98%);
                }
            }
        }
        &--right {
            right: 0;
            &.scroll-middle,
            &.scroll-left {
                &:before {
                    left: -15px;
                    background-image: linear-gradient(90deg, rgba(239, 240, 245, 0.00) 0%, #EFF0F5 98%);
                }
            }
        }
    }
    @each $size in large,
    medium,
    small,
    mini {
        &--#{$size} {
            $s: map-get($table-sizes, $size);
            $fs: map-get($table-font-sizes, $size);
            .#{$prefix}-table__header {
                .#{$prefix}-table__cell {
                    padding-top: 0;
                    padding-bottom: 0;
                    line-height: $s;
                }
            }
            .#{$prefix}-table__cell {
                padding-top: $s / 2;
                padding-bottom: $s / 2;
                font-size: $fs;
            }
            .before {
                position: absolute;
                display: block;
                height: $s;
                right: 0;
                top: 0;
                background: $table-color-header;
            }
        }
    }
}