@use "./_variables.scss" as *;
@use "../core/_index.scss" as *;
@use "../list/_variables.scss" as *;
@use "@progress/kendo-theme-core/scss/components/grid/_theme.scss" as *;


@mixin kendo-grid--theme() {

    @include kendo-grid--theme-base();

    $kendo-grid-filter-button-focus: rgba( black, .12 ) !default;

    .k-grid {

        @if($kendo-enable-color-system) {
            .k-table {
                td:focus,
                td.k-focus,
                th:focus,
                th.k-focus {
                    &::after {
                        background-color: $kendo-grid-hover-bg;
                    }
                }
            }
        } @else {

            // Selected state
            .k-table-td.k-selected,
            .k-table-row.k-selected {
                color: $kendo-grid-selected-text;
                background-color: $kendo-grid-selected-bg;
            }

            .k-table-row.k-selected > td,
            .k-table-row.k-selected > .k-table-td {
                color: inherit;
                background-color: transparent;
            }

            // Hover, Focused state
            .k-table {
                > .k-table-row:not(.k-detail-row):hover,
                > .k-table-row:not(.k-detail-row).k-hover,
                td:focus,
                td.k-focus,
                .k-table-td:focus,
                .k-table-td.k-focus,
                .k-table-th:focus,
                .k-table-th.k-focus,
                .k-master-row > td:focus,
                .k-grouping-row > td:focus,
                .k-detail-row > td:focus,
                .k-group-footer > td:focus,
                .k-master-row > .k-table-td:focus,
                .k-grouping-row > .k-table-td:focus,
                .k-detail-row > .k-table-td:focus,
                .k-group-footer > .k-table-td:focus {
                    color: inherit;
                    background-color: $kendo-grid-hover-bg;
                }

                .k-table-row:hover,
                .k-table-row.k-hover {
                    .k-grid-header-sticky,
                    .k-grid-footer-sticky {
                        color: inherit;
                        background-color: $kendo-grid-sticky-hover-bg;
                    }
                }

                .k-table-th,
                td,
                .k-table-td,
                .k-master-row > td,
                .k-grouping-row > td,
                .k-detail-row > td,
                .k-group-footer > td,
                .k-master-row > .k-table-td,
                .k-grouping-row > .k-table-td,
                .k-detail-row > .k-table-td,
                .k-group-footer > .k-table-td {
                    &:focus,
                    &.k-focus {
                        &.k-grid-header-sticky,
                        &.k-grid-content-sticky,
                        &.k-grid-footer-sticky {
                            color: inherit;
                            background-color: $kendo-grid-sticky-hover-bg;
                        }
                    }
                }
            }

        }

        .k-grid-pager:focus,
        .k-grid-pager.k-focus {
            color: inherit;
        }

        .k-table-th,
        td,
        .k-table-td {
            border-inline-start-color: transparent;
        }

        .k-grid-header-locked,
        .k-grid-content-locked,
        .k-grid-header-locked .k-table-th,
        .k-grid-content-locked td,
        .k-grid-content-locked .k-table-td {
            border-top-color: $kendo-grid-header-border;
            border-bottom-color: $kendo-grid-header-border;

            .k-group-footer {
                &:hover td,
                &.k-hover td,
                &:hover .k-table-td,
                &.k-hover .k-table-td {
                    color: inherit;
                    @include fill( $bg: $kendo-grid-sticky-footer-hover-bg );
                }
            }
        }

        .k-master-row {
            .k-grid-content-sticky {
                border-color: $kendo-grid-sticky-border;
                border-bottom-color: $kendo-grid-header-border;
            }
            .k-grid-row-sticky {
                border-top-color: $kendo-grid-sticky-border;
                border-bottom-color: $kendo-grid-sticky-border;
            }
        }
    }

    .k-grid-header {
        .k-sorted,
        .k-link:hover {
            color: $kendo-grid-text;

            > .k-icon {
                color: inherit;
            }
        }

        .k-grid-filter,
        .k-table-th-column-menu,
        .k-grid-header-menu,
        .k-hierarchy-cell .k-icon {
            &:hover {
                color: $kendo-grid-text;
                background-color: transparent;
            }

            &:focus,
            &.k-focus {
                color: $kendo-grid-text;
                background-color: $kendo-grid-filter-button-focus;
                box-shadow: none;
            }

            &.k-active {
                color: $kendo-color-primary-contrast;
                background-color: $kendo-color-primary;
            }
        }

        .k-table-thead > .k-table-row:not(:only-child) > .k-table-th,
        .k-table-thead > .k-table-row:not(:only-child) > .k-table-td {
            border-inline-start-color: $kendo-grid-border;

            &.k-grid-header-sticky {
                border-inline-color: $kendo-grid-sticky-header-border;
            }
        }

        .k-grid-header-locked .k-table-thead .k-table-row .k-table-th {
            border-inline-color: $kendo-grid-sticky-header-border;
        }

    }

    .k-group-footer {
        td,
        .k-table-td,
        .k-grid-footer-sticky {
            background: $kendo-grid-sticky-footer-bg;
        }

        &:hover td,
        &.k-hover td,
        &:hover .k-table-td,
        &.k-hover .k-table-td {
            @include fill( $bg: $kendo-grid-sticky-footer-hover-bg );
        }
    }

    .k-grouping-dropclue,
    .k-reorder-cue {
        border-color: $kendo-color-primary;

        &::before {
            border-color: transparent;
        }

        &::after {
            border-color: transparent;
            background-color: transparent;
        }
    }

    .k-resize-handle:hover .k-resize-handle-inner {
        background-color: $kendo-color-primary;
    }

    .k-column-resizer:hover {
        color: $kendo-color-primary;
    }

    .k-reorder-cue {
        background-color: $kendo-color-primary;
    }

    .k-columnmenu-item {
        &.k-selected {
            @include fill(
                $kendo-list-item-selected-text,
                $kendo-list-item-selected-bg
            );
        }
    }
    .k-column-list-item:focus,
    .k-column-list-item.k-focus,
    .k-columnmenu-item:focus,
    .k-columnmenu-item.k-focus {
        background: $kendo-list-item-hover-bg;
    }

    .k-column-menu .k-menu:not(.k-context-menu) {

        .k-item {
            // Selected state
            &.k-selected {
                background: $kendo-list-item-hover-bg;
            }
        }
    }

}
