@mixin adf-datatable-theme($theme) {
    $foreground: map-get($theme, foreground);
    $background: map-get($theme, background);
    $primary: map-get($theme, primary);

    $data-table-font-size: 14px !default;
    $data-table-header-font-size: 12px !default;
    $data-table-header-sort-icon-size: 16px !default;
    $data-table-header-color: mat-color($foreground, text) !default;
    $data-table-header-sorted-color: mat-color($foreground, text) !default;
    $data-table-header-sorted-icon-hover-color: mat-color($foreground, disabled-text) !default;
    $data-table-divider-color: mat-color($foreground, text, .07) !default;
    $data-table-hover-color: mat-color($background, 'hover') !default;
    $data-table-selection-color: mat-color($background, 'selected-button') !default;
    $data-table-dividers: 1px solid $data-table-divider-color !default;
    $data-table-row-height: 56px !default;
    // $data-table-last-row-height: 56px !default;
    // $data-table-header-height: 56px !default;
    $data-table-column-spacing: 36px !default;
    $data-table-column-padding: $data-table-column-spacing / 2;
    // $data-table-card-header-height: 64px !default;
    // $data-table-card-title-top: 20px !default;
    $data-table-card-padding: 24px !default;
    // $data-table-button-padding-right: 16px !default;
    $data-table-cell-top: $data-table-card-padding / 2;
    $data-table-drag-border: 1px dashed rgb(68, 138, 255);

    .adf-data-table-card {

        border: 1px solid mat-color($foreground, divider);

        .adf-datatable-body {
            flex-flow: row wrap;
            display: flex;

            width: 100%;
            flex-direction: row;
            justify-content: space-between;

            &:after {
                content: "";
                flex: auto;
            }

            .adf-datatable-row {
                transition: all 0.3s ease;
                position: relative;
                display: flex;
                flex-direction: column;
                flex: 0 1 24%;

                width: 288px !important;
                max-width: 288px !important;
                min-width: 288px !important;

                height: 200px !important;

                overflow: hidden !important;
                margin: 6px;
                padding: 15px;

                @include mat-elevation-transition;
                @include mat-overridable-elevation(2);
            }

            .is-selected {
                background: mat-color($primary, 100);
                padding-bottom: 31px;
            }

            .adf-data-table-card-permission {
                width: 100%;
                min-height: 250px;

                .adf-datatable-table-cell {
                    height: 240px !important;
                }
            }

            .adf-data-table-card-loading {
                width: 100%;
                min-height: 250px;

                .adf-datatable-table-cell {
                    height: 240px !important;
                }
            }

            .adf-data-table-card-empty {
                width: 100%;
                min-height: 380px;

                .adf-datatable-table-cell {
                    height: 370px !important;
                }
            }

            .adf-datatable-table-cell {
                text-align: left;
                flex: 0 1 24%;
                height: 136px !important;
                white-space: nowrap;
                text-overflow: ellipsis;
                overflow: hidden;
                outline: none;

                &:before {
                    margin-left: 10px;
                    text-align: left;
                    content: attr(title);
                    color: mat-color($foreground, text, 0.4);
                    float: left;
                    width: 140px;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                    overflow: hidden;
                }

            }
            .alfresco-datatable__actions-cell {
                position: absolute;
                height: 42px !important;
                width: 42px !important;
                right: 0px;
                text-align: right;
            }

            .image-table-cell {
                margin: 8px;
                padding: 4px;
                overflow: visible;
                border-bottom-color: mat-color($foreground, divider);
                border-bottom-width: 1px;
                border-bottom-style: solid;

                .cell-container {
                    float: left;
                    width: 42px;
                }

                &:after {
                    margin: 2px;
                    content: attr(filename);
                    float: left;
                    width: 140px;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                    overflow: hidden;
                }
            }

            .adf-datatable-table-checkbox {
                margin: 8px;
            }

        }

        .adf-datatable-header {
            margin-right: 18px;
            float: right;
        }

    }

    .adf-data-table {
        display: table;
        width: 100%;
        position: relative;
        border: $data-table-dividers;
        border-collapse: collapse;
        white-space: nowrap;
        font-size: $data-table-font-size;

        /* Firefox fixes */
        border-collapse: unset;
        border-spacing: 0;

        .adf-datatable-row {
            display: table-row;
            vertical-align: inherit;
            border-color: inherit;
        }

        .adf-datatable-body {
            display: table-row-group;
            vertical-align: middle;
            border-color: inherit;
        }

        .adf-datatable-table-cell {
            display: table-cell;
        }

        .adf-datatable-table-cell-header {
            display: table-cell;
        }

        .adf-datatable-header {
            padding-bottom: 3px;
            display: table-header-group;
            vertical-align: middle;
            border-color: inherit;
        }

        .adf-datatable-body {

            .adf-datatable-row {
                cursor: pointer;
                position: relative;
                height: $data-table-row-height;
                @include material-animation-default(0.28s);
                transition-property: background-color;

                &:hover {
                    background-color: $data-table-hover-color;
                }

                &.is-selected, &.is-selected:hover {
                    background-color: $data-table-selection-color;
                }

                &:focus {
                    outline-offset: -1px;
                    outline-width: 1px;
                    outline-color: rgb(68, 138, 255);
                    outline-style: solid;
                }

                &:last-child {
                    & > td {
                        border-bottom: $data-table-dividers;
                    }
                }
            }
        }

        .adf-datatable-table-cell, .adf-datatable-table-cell-header {
            padding: 0 $data-table-column-padding 12px $data-table-column-padding;
            text-align: left;

            &:first-of-type {
                padding-left: 24px;
            }

            &:last-of-type {
                padding-right: 24px;
            }

            &:focus {
                outline-offset: -1px;
                outline-width: 1px;
                outline-color: rgb(68, 138, 255);
                outline-style: solid;
            }
        }

        .adf-datatable-table-cell {
            color: mat-color($foreground, text);
            position: relative;
            vertical-align: middle;
            height: $data-table-row-height;
            border-top: $data-table-dividers;
            padding-top: $data-table-cell-top;
            box-sizing: border-box;

            @include no-select;
        }

        .adf-datatable-table-cell-header {
            @include no-select;
            cursor: pointer;
            position: relative;
            vertical-align: bottom;
            text-overflow: ellipsis;
            font-size: 14px;
            font-weight: bold;
            line-height: 24px;
            letter-spacing: 0;
            height: $data-table-row-height;
            font-size: $data-table-header-font-size;
            color: $data-table-header-color;
            padding-bottom: 8px;
            box-sizing: border-box;
            white-space: nowrap;

            &.sortable {
                @include no-select;
                &:hover {
                    cursor: pointer;
                }
            }

            &.adf-data-table__header--sorted-asc,
            &.adf-data-table__header--sorted-desc {
                color: $data-table-header-sorted-color;
                &:before {
                    @include typo-icon;
                    font-size: $data-table-header-sort-icon-size;
                    content: "\e5d8";
                    margin-right: 5px;
                    vertical-align: sub;
                }
            }
            &.adf-data-table__header--sorted-desc:before {
                content: "\e5db";
            }
        }

        .adf-data-table-cell {
            text-align: left;
            height: 100%;

            &--text {
                text-align: left;
            }

            &--date {
                text-align: left;
            }

            &--number {
                text-align: right;
            }

            &--image {
                padding-left: 24px;
                padding-right: 24px;
                width: 10px;
                text-align: left;

                .cell-value {
                    height: 24px;
                }

                img {
                    height: 100%;
                }
            }

            .cell-container {
                display: flex;
                align-items: center;
            }
        }

        .adf-location-cell {
            a {
                text-decoration: none;
                color: mat-color($foreground, text);

                &:hover {
                    color: #2196F3;
                    text-decoration: underline;
                }
            }
        }

        .full-width {
            width: 100%;
        }

        /* Empty folder */
        .adf-no-content-container {
            padding: 0 !important;
            border: none !important;
            width: 100%;

            & > img {
                width: 100%;
            }
        }

        /* Loading folder */
        .adf-loading-content-container {
            padding: 0 !important;
            width: 100%;

            & > img {
                width: 100%;
            }
        }

        .adf-no-permission {
            &__row:hover {
                cursor: default;
                background-color: inherit;
            }

            &__cell {
                padding: 0 !important;
            }
        }

        .ellipsis-cell {
            .cell-container {
                height: 100%;
            }

            .cell-container > * {
                display: block;
                position: absolute;
                max-width: calc(100% - 2em);
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                line-height: 1.12em;
            }

            /* visible content */
            .cell-value {
                display: block;
                position: relative;
                max-width: calc(100% - 2em);
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                line-height: 1.12em;
            }

            /* cell stretching content */
            & > div:after {
                content: attr(title);
                overflow: hidden;
                height: 0;
                display: block;
            }
        }

        /* [Accessibility] For screen reader only */
        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            border: 0;
        }

        /* Utils */
        .hidden {
            display: none;
        }

        /* mobile phone */
        @media all and (max-width: 768px) {
            .desktop-only {
                display: none;
            }
        }

        @media (max-device-width: 768px) {
            .desktop-only {
                display: none;
            }
        }
    }

    .adf-upload__dragging {
        & > td {
            border-top: $data-table-drag-border;
            border-bottom: $data-table-drag-border;

            &:first-child {
                border-left: $data-table-drag-border;
            }

            &:last-child {
                border-right: $data-table-drag-border;
            }
        }
    }
}
