@use '../../styles/bootstrap/variables' as bootstrap-variables;
@use '../../styles/mixins/utilities';
@use '../../styles/variables';
@use '../../styles/mixins/tables';

.thy-native-table {
    width: 100%;
    max-width: 100%;
    color: variables.$table-color;
    background-color: variables.$table-bg;
    table {
        border-collapse: separate;
        border-spacing: 0;
    }

    th,
    td {
        padding: variables.$table-default-header-cell-padding;
        vertical-align: middle;
        border-bottom: variables.$table-border-width solid variables.$table-border-color;
    }

    tbody tr {
        &.clear-hover {
            cursor: default !important;
            box-shadow: initial !important;
            background-color: transparent !important;

            td {
                border-bottom: 0;
            }
        }
    }

    @include tables.table-size(
        variables.$table-cell-height,
        variables.$table-cell-height,
        variables.$table-header-padding,
        variables.$table-cell-padding
    );
    .thy-native-table-content {
        table {
            width: 100%;
        }
    }
    .thy-table-pagination {
        padding: 0 20px;
        margin-top: 1.25rem;
    }
    &.table-fixed {
        table-layout: fixed;
    }
    .thy-table-cell-fix-left,
    .thy-table-cell-fix-right {
        background-color: variables.$bg-default;
        position: sticky !important;
        z-index: variables.$z-index-5;
    }

    .thy-table-cell-fix-left-last::after,
    .thy-table-cell-fix-right-first::before {
        position: absolute;
        top: 0;
        bottom: -1px;
        width: 30px;
        transform: translate(100%);
        transition: box-shadow 0.2s;
        content: '';
        pointer-events: none;
    }
    .thy-table-cell-fix-left-last::after {
        right: 30px;
        width: 31px;
    }
    .thy-table-cell-fix-right-first::before {
        left: -30px;
    }
    .thy-native-table-scroll-left {
        .thy-table-cell-fix-left-last::after {
            box-shadow: variables.$table-fixed-column-left-box-shadow;
        }
    }
    .thy-native-table-scroll-right {
        .thy-table-cell-fix-right-first::before {
            box-shadow: variables.$table-fixed-column-right-box-shadow;
        }
    }
}

.native-table-default {
    @include tables.table-set-header(
        left,
        bottom,
        400,
        variables.$table-border-width,
        transparent,
        variables.$table-border-color,
        variables.$table-default-header-color,
        variables.$table-default-header-padding
    );
}

.native-table-bordered {
    .thy-native-table-thead {
        .thy-table-cell-fix-left,
        .thy-table-cell-fix-right {
            background-color: variables.$table-bordered-bg;
        }
    }
    .thy-native-table-wrapper {
        border: variables.$table-border-width solid variables.$table-border-color;
        th,
        td {
            border-right: variables.$table-border-width solid variables.$table-border-color;
        }
    }
    @include tables.table-set-header(
        center,
        middle,
        400,
        variables.$table-border-width,
        variables.$table-bordered-bg,
        variables.$table-border-color,
        variables.$table-bordered-header-color,
        0
    );
}

.native-table-boxed {
    .thy-native-table-thead {
        .thy-table-cell-fix-left,
        .thy-table-cell-fix-right {
            background-color: variables.$table-bordered-bg;
        }
    }
    .thy-native-table-wrapper {
        border: variables.$table-border-width solid variables.$table-border-color;
        border-radius: variables.$table-boxed-border-radius;
    }

    tbody {
        tr:last-child {
            td {
                border-bottom: 0px;
            }
        }
    }

    @include tables.table-set-header(
        left,
        middle,
        400,
        variables.$table-border-width,
        variables.$table-bordered-bg,
        variables.$table-border-color,
        variables.$table-bordered-header-color,
        0
    );
}

.native-table-xlg {
    @include tables.table-size(
        variables.$table-cell-height-xlg,
        variables.$table-cell-height-xlg,
        variables.$table-header-padding-xlg,
        variables.$table-cell-padding-xlg
    );
}

.native-table-lg {
    @include tables.table-size(
        variables.$table-cell-height-lg,
        variables.$table-cell-height-lg,
        variables.$table-header-padding-lg,
        variables.$table-cell-padding-lg
    );
}

.native-table-md {
    @include tables.table-size(
        variables.$table-cell-height,
        variables.$table-cell-height,
        variables.$table-header-padding,
        variables.$table-cell-padding
    );
}

.native-table-sm {
    @include tables.table-size(
        variables.$table-cell-height-sm,
        variables.$table-cell-height-sm,
        variables.$table-header-padding-sm,
        variables.$table-cell-padding-sm
    );
}

.native-table-xs {
    @include tables.table-size(
        variables.$table-cell-height-xs,
        variables.$table-cell-height-xs,
        variables.$table-header-padding-xs,
        variables.$table-cell-padding-xs
    );
}
