@panel-heading-padding-top: extract(@panel-heading-padding, 1);
@panel-heading-padding-bottom: extract(@panel-heading-padding, 1);
@panel-footer-padding-top: extract(@panel-footer-padding, 1);
@panel-footer-padding-bottom: extract(@panel-footer-padding, 1);

.@{component-class-prefix}-grid{
    display: flex;
    flex-flow: row wrap;
    position: relative;

    & > * {
        flex: 1 100%;
    }

    &.details-open > div {
        flex: 1 auto;
        overflow-x: hidden;

        & + div.panel {
            flex: 9 0px;
            width: auto;
            display: block;
        }

        & > table {
            & > thead th:not( .primary-column ),
            & > tbody td:not( .primary-column ),
            & > tbody th:not( .primary-column ) {
                max-width: 0;
                overflow: hidden;
                padding-left: 0;
                padding-right: 0;
                font-size: 0;
            }
        }
    }

    &.hasDetails > div > table > tbody td {
        cursor: pointer;
    }

    & > div {
        overflow: auto;

        & > table {
            width: 100%;
            border-collapse: inherit;
            margin: 0;

            & > thead {
                th {
                    background-color: @table-bg;
                }

                /* if @table-bg is set to "transparent" */
                th when ( alpha( @table-bg ) = 0 ) {
                    background-color: @body-bg;
                }

                .sortable-column {
                    cursor: pointer;
                }

                .sl-icon-sortable:after {
                    content: @icon-grid-sortable;
                }

                .column-descending .sl-icon-sortable:after {
                    content: @icon-grid-sorted-desc;
                }

                .column-ascending .sl-icon-sortable:after {
                    content: @icon-grid-sorted-asc;
                }
            }

            tr.active > td, tr.active:hover td {
                background-color: @component-active-bg;
                color: @component-active-color;
            }

            /* the fake header */
            & > tbody tr:first-child {
                display: none;
            }

            &.fixed-header {
                &> tbody > tr:first-child {
                    display: table-row;
                }

                &> thead {
                    position: absolute;
                    z-index: 2;
                }
            }
        }
    }

    & > div.sl-loading {
        overflow: hidden;
    }

    &> div + div.panel {
        display: none;
        box-sizing: border-box;
        overflow: visible;
        position: relative;
        margin-bottom: 0;
        min-height: 15em;

        &> * {
            position: absolute;
            left: 0;
            right: 0;
        }

        &> div {
            overflow: auto;
            top: 0;
            bottom: 0;
        }

        &> footer {
            bottom: 0;
        }

        &> header button.close {
            font-size: 1.4em;

            .sl-icon-close::before {
                content: @icon-grid-details-close;
            }
        }

        &> header + div {
            top: calc( 1.5em ~"+" @panel-heading-padding-top ~"+" @panel-heading-padding-bottom );

            &:nth-last-child(2) {
                bottom: calc( 1.5em ~"+" @panel-footer-padding-top ~"+" @panel-footer-padding-bottom );
            }
        }
    }

    &> footer {
        clear: left;
        margin-top: @line-height-computed;
    }
}

.panel .grid.sl-ember-components > div > table > thead th {
    background-color: @panel-bg;
}

.sl-icon-sortable {
    &:extend( .sl-ember-components-icons all );
}
