@import (reference) '@sb1/ffe-core/less/typography';

.ffe-toggle-switch {
    &__input {
        position: absolute;
        opacity: 0;
        cursor: pointer;
    }

    &__label {
        display: flex;
        align-items: center;
        position: relative;
        cursor: pointer;
        color: var(--ffe-color-foreground-default);
        font-family: var(--ffe-g-font);
        font-variant-numeric: tabular-nums;
        min-height: 44px;
        transition: color var(--ffe-transition-duration) var(--ffe-ease);
        font-size: var(--ffe-fontsize-h6);
    }

    &__label-text {
        margin-right: auto;
        padding-right: var(--ffe-spacing-sm);
    }

    &__label-on,
    &__label-off {
        .ffe-small-text();
    }

    &__label-description {
        display: block;
        margin-top: var(--ffe-spacing-2xs);
        .ffe-small-text();
    }

    &__switch {
        position: relative;
        margin: 0 var(--ffe-spacing-sm);
        display: flex;
        align-items: center;

        .ffe-toggle-switch--hide-on-off & {
            margin: 0;
        }

        &::before {
            display: inline-block;
            content: '';
            width: 56px;
            height: 30px;
            background: var(
                --ffe-color-component-form-toggleswitch-fill-default
            );
            border-radius: 52px;
            left: auto;
            right: 0;
            transition:
                background 0.4s var(--ffe-ease),
                box-shadow var(--ffe-transition-duration) var(--ffe-ease);
        }

        &::after {
            display: inline-block;
            content: '';
            width: 24px;
            height: 24px;
            background: var(
                --ffe-color-component-form-toggleswitch-handle-default
            );
            border-radius: 50%;
            position: absolute;
            left: 4px;
            transition: transform var(--ffe-transition-duration) var(--ffe-ease);
        }

        @media (hover: hover) and (pointer: fine) {
            .ffe-toggle-switch__label:hover &::before {
                background: var(
                    --ffe-color-component-form-toggleswitch-fill-default-hover
                );
            }
        }
    }

    &__input:checked + &__label &__switch::after {
        transform: translateX(24px);
    }

    &__input:checked + &__label &__switch::before {
        background: var(--ffe-color-component-form-toggleswitch-fill-selected);
    }

    @media (hover: hover) and (pointer: fine) {
        &__input:checked + &__label:hover &__switch::before {
            background: var(
                --ffe-color-component-form-toggleswitch-fill-selected-hover
            );
        }
    }

    &__input:focus:not(:focus-visible) + &__label &__switch::before {
        box-shadow: none;
    }

    &__input:focus + &__label &__switch::before {
        box-shadow:
            0 0 0 3px var(--ffe-color-surface-primary-default),
            0 0 0 5px var(--ffe-color-border-interactive-focus);
    }

    :active + &__label &__switch::before {
        background: var(
            --ffe-color-component-form-toggleswitch-fill-default-pressed
        );
    }

    &__input:checked:active + &__label &__switch::before {
        background: var(
            --ffe-color-component-form-toggleswitch-fill-selected-pressed
        );
    }
}
