@use "./_variables.scss" as *;
@use "../core/_index.scss" as *;
@use "../core/functions/index.import.scss" as *;
@use "@progress/kendo-theme-core/scss/components/button/_theme.scss" as *;

@mixin kendo-button--theme() {

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

    // Solid button
    @each $name, $color in $kendo-button-theme-colors {
        .k-button-solid-#{$name} {
            @include box-shadow( $kendo-button-shadow );

            // These 3 lines can be deleted once we
            // stop supporting the old color system.
            color: if( $name == "base", $kendo-button-text, if($kendo-enable-color-system, k-color( on-#{$name} ), k-contrast-color( $color )) );
            background-color: if( $name == "base", $kendo-button-bg, if($kendo-enable-color-system, k-color( $name ), $color) );
            border-color: if( $name == "base", $kendo-button-bg, if($kendo-enable-color-system, k-color( $name ), $color) );

            // Hover state
            &:hover,
            &.k-hover {
                @include box-shadow( $kendo-button-hover-shadow );
            }

            // Focus state
            &:focus,
            &.k-focus {
                background-color: if($kendo-enable-color-system, k-color( #{$name}-hover ), null);
                border-color: if($kendo-enable-color-system, k-color( #{$name}-hover ), null);
                @include box-shadow( $kendo-button-focus-shadow );
            }

            // Active state
            &:active,
            &.k-active {
                @include box-shadow( $kendo-button-active-shadow );
            }

            // Selected state
            &.k-selected {
                @include box-shadow( $kendo-button-selected-shadow );
            }

            // Disabled state
            &:disabled,
            &.k-disabled {
                @include box-shadow( $kendo-button-disabled-shadow );
            }
        }
    }


    // Outline button
    @each $name, $color in $kendo-button-theme-colors {
        .k-button-outline-#{$name} {

            // The "base" case can be deleted once we
            // stop supporting the old color system.
            @if $name == "base" {
                color: if($kendo-enable-color-system, k-color( base-on-surface ), $kendo-button-text)
            } @else {
                color: if($kendo-enable-color-system, k-color( #{$name}-on-surface ), $color)
            }

            &:hover,
            &.k-hover,
            &:focus,
            &.k-focus,
            &:active,
            &.k-active,
            &.k-selected {
                // The "base" case can be deleted once we
                // stop supporting the old color system.
                @if $name == "base" {
                    color: if($kendo-enable-color-system, k-color( base-on-surface ), $kendo-button-text)
                } @else {
                    color: if($kendo-enable-color-system, k-color( #{$name}-on-surface ), $color)
                }
            }

            // Disabled state
            &:disabled,
            &.k-disabled {
                color: $kendo-button-disabled-text;
            }
        }
    }


    // Link button
    @each $name, $color in $kendo-button-theme-colors {
        .k-button-link-#{$name} {

            // Disabled state
            &:disabled,
            &.k-disabled {
                color: $kendo-button-disabled-text;
            }
        }
    }


    // Menu button
    .k-menu-button {}


    // Button group
    .k-button-group {
        @include box-shadow( $kendo-button-shadow );

        .k-button {
            @include box-shadow( none );
        }

        // Disabled state
        &:disabled,
        &[disabled],
        &.k-disabled {
            @include box-shadow( none );
        }
    }


    // Variant button group
    .k-button-group-flat,
    .k-button-group-link,
    .k-button-group-outline {
        @include box-shadow( none );
    }

}
