/**
* DevExtreme (widgets/material/switch.material.less)
* Version: 19.2.7 (build 20134-0312)
* Build date: Wed May 13 2020
*
* Copyright (c) 2012 - 2020 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
@import (once) "./validation.material.less";

.dx-size-default() {
    @MATERIAL_SWITCH_WIDTH: 36px;
    @MATERIAL_SWITCH_HANDLE_WIDTH: 14px;
    @MATERIAL_SWITCH_HANDLE_OFFSET: 2px;
    @MATERIAL_SWITCH_HANDLE_SHADOW: 0 1px 4px 0 rgba(0, 0, 0, 0.2);
    @MATERIAL_SWITCH_CONTAINER_ADJUSTMENT: 6px;
    @MATERIAL_SWITCH_ON_OFF_ADDING_PADDING: 2px;
    @MATERIAL_SWITCH_CONTAINER_MARGIN: 3px;
}

.dx-size-compact() {
    @MATERIAL_SWITCH_WIDTH: 32px;
    @MATERIAL_SWITCH_HANDLE_WIDTH: 12px;
    @MATERIAL_SWITCH_HANDLE_OFFSET: 2px;
    @MATERIAL_SWITCH_HANDLE_SHADOW: 0 1px 4px 0 rgba(0, 0, 0, 0.2);
    @MATERIAL_SWITCH_CONTAINER_ADJUSTMENT: 6px;
    @MATERIAL_SWITCH_ON_OFF_ADDING_PADDING: 2px;
    @MATERIAL_SWITCH_CONTAINER_MARGIN: 2px;
}

@MATERIAL_SWITCH_SHADOW_BLUR_RADIUS: 10px;
@MATERIAL_SWITCH_TRANSITION: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
@MATERIAL_ON_VALUE_SWITCH_SHADOW: 0 0 0 @MATERIAL_SWITCH_SHADOW_BLUR_RADIUS fade(@switch-handle-on-bg, 10%);
@MATERIAL_SWITCH_SHADOW: 0 0 0 @MATERIAL_SWITCH_SHADOW_BLUR_RADIUS fade(@base-text-color, 10%);
@MATERIAL_INVALID_SWITCH_SHADOW: 0 0 0 @MATERIAL_SWITCH_SHADOW_BLUR_RADIUS fade(@switch-invalid-handle-bg, 10%);

.dx-switch-wrapper {
    position: relative;
    padding: @MATERIAL_SWITCH_SHADOW_BLUR_RADIUS;
    box-sizing: content-box;
    left: -@MATERIAL_SWITCH_SHADOW_BLUR_RADIUS;
    top: -@MATERIAL_SWITCH_SHADOW_BLUR_RADIUS;
    overflow: hidden;
    vertical-align: middle;
}

.dx-switch {
    width: @MATERIAL_SWITCH_WIDTH;
    height: @MATERIAL_SWITCH_HEIGHT;

    &.dx-state-readonly,
    &.dx-state-disabled {
        .dx-switch-handle:before {
            background-color: @switch-handle-disabled-bg;
        }

        .dx-switch-container:before {
            background-color: fade(@base-text-color, 12%);
        }
    }

    &.dx-state-active,
    &.dx-state-focused {
        .dx-switch-handle:before {
            box-shadow: @MATERIAL_SWITCH_SHADOW;
            border-radius: 50%;
        }
    }
}

.dx-switch-on-value,
.dx-switch {
    &.dx-state-readonly.dx-state-focused {
        .dx-switch-handle:before {
            box-shadow: @MATERIAL_SWITCH_SHADOW;
            border-radius: 50%;
        }
    }
}

.dx-switch-container {
    height: @MATERIAL_SWITCH_HEIGHT;
    overflow: visible;
    position: relative;

    &:before {
        position: absolute;
        content: '';
        width: 100%;
        height: 14px;
        border-radius: 500px;
        background-color: @switch-bg;
        margin: @MATERIAL_SWITCH_CONTAINER_MARGIN 0;
    }
}

.dx-switch-inner {
    width: 200%;
    height: 100%;
}

.dx-switch-on,
.dx-switch-off {
    flex-shrink: 0;
    float: left;
    padding: 4px 0;
    width: 50%;
    height: @MATERIAL_SWITCH_HEIGHT;
    color: transparent;
    text-align: center;
    line-height: 100%;
}

.dx-switch-on {
    background: transparent;
}

.dx-switch-off {
    display: none;
    padding-bottom: 10px;
    background-color: transparent;
}

.dx-switch-handle {
    flex-basis: @MATERIAL_SWITCH_HEIGHT;
    flex-shrink: 0;
    position: relative;
    float: left;
    width: @MATERIAL_SWITCH_HEIGHT;
    height: @MATERIAL_SWITCH_HEIGHT;
    background-color: @switch-handle-off-bg;
    box-shadow: @MATERIAL_SWITCH_HANDLE_SHADOW;
    border-radius: @switch-handle-border-radius;

    &:before {
        display: block;
        content: ' ';
        width: 100%;
        height: 100%;
        background-color: @switch-handle-off-bg;
        border-radius: @switch-handle-border-radius;
        transition: @MATERIAL_SWITCH_TRANSITION;
    }
}

.dx-switch-on-value {
    .dx-switch-container:before {
        background-color: @switch-on-bg;
    }

    .dx-switch-handle:before {
        background-color: @switch-handle-on-bg;
    }

    &.dx-state-active,
    &.dx-state-focused {
        .dx-switch-handle:before {
            box-shadow: @MATERIAL_ON_VALUE_SWITCH_SHADOW;
            border-radius: 50%;
        }
    }
}

.dx-rtl .dx-switch,
.dx-switch.dx-rtl {
    .dx-switch-on,
    .dx-switch-off {
        float: right;
        padding-left: @MATERIAL_SWITCH_HANDLE_WIDTH + @MATERIAL_SWITCH_ON_OFF_ADDING_PADDING;
        padding-right: @MATERIAL_SWITCH_HANDLE_OFFSET;
    }

    .dx-switch-off {
        margin-left: 0;
    }

    .dx-switch-handle {
        float: right;
        margin-left: 0;
        margin-right: -@MATERIAL_SWITCH_HEIGHT;
    }

    .dx-switch-wrapper {
        left: @MATERIAL_SWITCH_SHADOW_BLUR_RADIUS;
    }

    .dx-switch-container {
        margin: 0 0 0 -@MATERIAL_SWITCH_CONTAINER_ADJUSTMENT;
    }
}

.dx-invalid {
    .dx-switch-container {
        .dx-switch&:before {
            background-color: @switch-invalid-container-bg;
        }

        .dx-switch-handle:before {
            .dx-switch-on-value:not(.dx-state-readonly):not(.dx-state-disabled)& {
                background-color: @switch-invalid-handle-bg;

                .dx-state-active&,
                .dx-state-focused& {
                    box-shadow: @MATERIAL_INVALID_SWITCH_SHADOW;
                }
            }
        }
    }
}
