@use '../function' as *;
@use '../mixin';

@mixin roolith-table {
    .table {
        font-size: rem(14);
        line-height: rem(18);

        th {
            text-align: left;
            font-weight: var(--r-table-header-font-weight);
        }

        th,
        td {
            padding: var(--r-table-spacing);
            position: relative;
            min-width: rem(30);

            &:first-child {
                padding-left: 0;
            }

            .form-check-input {
                margin: rem(7) rem(12);
            }
        }

        thead {
            tr {
                border-bottom: rem(1) solid var(--r-table-header-border-color);
            }
        }

        tbody tr {
            border-bottom: rem(1) solid var(--r-table-border-color);
        }

        .is-checked {
            background-color: var(--r-table-row-hover-color);
        }

        .is-highlight {
            background-color: var(--r-table-row-highlight-color);
        }

        .table-thead-label {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: rem(10);
            background: none;
            border: none;
            padding: 0;
            cursor: pointer;
            font-size: inherit;
            line-height: inherit;
            font-weight: inherit;
            color: inherit;
            width: 100%;
            font-family: var(--r-global-base-font);
        }
    }

    .table-primary {
        th {
            background-color: var(--r-table-primary-header-color);
        }

        th,
        td {
            &:first-child {
                padding-left: var(--r-table-spacing);
            }
        }

        tbody tr {
            @include mixin.transition('background');

            &:hover {
                background-color: var(--r-table-row-hover-color);
            }
        }
    }

    .table-striped {
        @extend .table-primary;

        tbody tr {
            &:nth-child(even) {
                background-color: var(--r-table-row-striped-color);
            }

            &:hover {
                background-color: var(--r-table-row-striped-hover-color);
            }
        }
    }

    .table-bordered {
        border-top: rem(1) solid var(--r-table-border-color);
        border-left: rem(1) solid var(--r-table-border-color);

        th,
        td {
            border-bottom: rem(1) solid var(--r-table-border-color);
            border-right: rem(1) solid var(--r-table-border-color);

            &:first-child {
                padding-left: var(--r-table-spacing);
            }
        }

        thead tr {
            border-bottom: none;
        }

        tbody tr {
            @include mixin.transition('background');

            &:hover {
                background-color: var(--r-table-row-hover-color);
            }
        }
    }

    .table-responsive {
        max-width: 100%;
        overflow-x: auto;
        @include mixin.nice-scroll();
    }
}
