@import '../dynamic.scss';

.form-control-radio-switch {
    background-color: $white;
    white-space: nowrap;
    line-height: calc(#{$input-height} - #{$border-width * 2});
    border: solid 1px $gray-400;
    border-radius: $input-height / 2;
    height: $input-height;
    justify-content: space-evenly;
    display: flex;
    position: relative;
    font-weight: 500;

    .form-check-inline {
        display: inline-flex;
        align-items: center;
        line-height: inherit;
        padding-left: 0;
        margin: $input-border-width * -1;
        width: 100%;
        text-align: center;
        overflow: hidden;
        flex-shrink: 10;
        &.form-check-inline-noclip {
            overflow: visible;
        }
        &.form-check-inline-sm {
            flex-shrink: 11;
        }
        &.form-check-inline-lg {
            flex-shrink: 8;
        }
        &.form-check-inline-xl {
            flex-shrink: 6;
        }
    }

    .form-check-label {
        white-space: nowrap;
        text-overflow: ellipsis;
        padding: 0 0.5rem;
        margin: auto;
        border: 1px solid transparent;
        border-radius: $input-height / 2;
        overflow: hidden;
        width: 100%;
        height: $input-height;
        cursor: pointer;
        display: inline-block;
    }

    .form-check-input {
        width: 0;
        height: 0;
        position: absolute;
        appearance: none;
        &:before {
            content: none !important;
            display: none !important;
        }
        &:checked + .form-check-label {
            background-color: $gray-800;
            color: $white;
            border-color: $gray-800;
        }
    }

    &:focus-within {
        border-color: $gray-500;
        box-shadow: 0 0 1px $gray-500 inset;
        .form-check-input:checked + .form-check-label {
            background-color: $gray-700;
            border-color: $gray-800;
        }
    }

    &.disabled,
    &:disabled {
        opacity: $btn-disabled-opacity;
        .form-check-label {
            cursor: default;
        }
    }

    &.radio-switch-branded {
        .form-check-input:checked + .form-check-label {
            background-color: $branded;
            color: $gray-800;
            border-color: $branded;
        }
        &:focus-within {
            .form-check-input:checked + .form-check-label {
                background-color: map-get($highlighted-colors, branded);
                border-color: map-get($active-colors, branded);
            }
        }
    }
}

.form-control-radio-switch-lg {
    font-size: $font-size-lg;
    line-height: $input-height-lg;
    height: $input-height-lg;
    border-radius: $input-height-lg / 2;
    .form-check-label {
        border-radius: $input-height-lg / 2;
        height: $input-height-lg;
    }
}

.form-control-radio-switch-sm {
    line-height: $input-height-sm;
    border-radius: $input-height-sm / 2;
    height: $input-height-sm;
    .form-check-label {
        border-radius: $input-height-sm / 2;
        height: $input-height-sm;
    }
}

.form-control-radio-switch-narrow {
    display: inline-flex;
    .form-check-inline {
        overflow: visible;
    }
    .form-check-label {
        min-width: $input-height;
        & > * {
            height: 100%;
        }
    }
}
