@import "../00_Abstracts/index";

// Prevent double borders
table {
    border-collapse: collapse;
}

caption {
    text-align: left;
    caption-side: bottom;
}

// Matches default `<td>` alignment by inheriting from the `<body>`, or the
// closest parent with a set `text-align`.
th {
    text-align: inherit;
}

.table {
    border-collapse: separate;
    border-spacing: 0;
    @include b();
    @include b-b($size: none);
    @include b-r($size: none);

    &.striped {
        tbody {
            tr:nth-child(odd) {
                @include bg-color(light, lighter);
            }
        }
    }

    &.hover {
        tbody {
            tr {
                &:hover {
                    @include bg-color(light, light);
                }
            }
        }
    }

    thead {
        font-weight: bold;
        @include b-b($size: xxs);
    }

    tr {
        background-color: white;
    }

    th,
    td {
        vertical-align: bottom;
        background-color: inherit;
        @include p(sm);
        @include b-r();
        @include b-b();
    }

    &.fixed-heading {
        thead tr th {
            position: sticky;
            top: 0;
            @include z-index(xxs);
        }

        thead tr> :first-child {
            top: 0;
            @include z-index(xs);
        }
    }

    &.fixed-column {
        thead tr> :first-child {
            position: sticky;
            left: 0;
            @include z-index(xs);
        }

        tbody tr> :first-child {
            position: sticky;
            left: 0;
            @include z-index(xxs);
        }
    }

}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    @include b-x();

    .table {
        @include mx(-xxxs);

        tr> :last-child {
            @include b-r($size:none);
        }
    }
}
