@use "../../wwwroot/scss/variables" as *;

.segmented {
    --bb-segmented-padding: #{$bb-segmented-padding};
    --bb-segmented-bg: #{$bb-segmented-bg};
    --bb-segmented-item-padding: #{$bb-segmented-item-padding};
    --bb-segmented-item-height: #{$bb-segmented-item-height};
    --bb-segmented-item-font-size: #{$bb-segmented-item-font-size};
    --bb-segmented-item-selected-bg: var(--bs-body-bg);
    --bb-segmented-item-hover-bg: #{$bb-segmented-item-hover-bg};
    --bb-segmented-item-active-bg: #{$bb-segmented-item-active-bg};
    --bb-segmented-item-border-radius: #{$bb-segmented-item-border-radius};
    --bb-segmented-item-lg-height: #{$bb-segmented-item-lg-height};
    --bb-segmented-item-lg-padding: #{$bb-segmented-item-lg-padding};
    --bb-segmented-item-lg-font-size: #{$bb-segmented-item-lg-font-size};
    --bb-segmented-item-lg-border-radius: #{$bb-segmented-item-lg-border-radius};
    --bb-segmented-item-sm-height: #{$bb-segmented-item-sm-height};
    --bb-segmented-item-sm-padding: #{$bb-segmented-item-sm-padding};
    --bb-segmented-item-sm-font-size: #{$bb-segmented-item-sm-font-size};
    --bb-segmented-item-sm-border-radius: #{$bb-segmented-item-sm-border-radius};
    --bb-segmented-text-margin-left: #{$bb-segmented-text-margin-left};
    padding: var(--bb-segmented-padding);
    background-color: var(--bb-segmented-bg);
    border-radius: var(--bs-border-radius);
    border: var(--bs-border-width) solid var(--bs-border-color);
    display: inline-flex;
    position: relative;

    &.segmented-lg {
        --bb-segmented-item-border-radius: var(--bb-segmented-item-lg-border-radius);
        --bb-segmented-item-height: var(--bb-segmented-item-lg-height);
        --bb-segmented-item-padding: var(--bb-segmented-item-lg-padding);
        --bb-segmented-item-font-size: var(--bb-segmented-item-lg-font-size);
    }

    &.segmented-sm {
        --bb-segmented-item-border-radius: var(--bb-segmented-item-sm-border-radius);
        --bb-segmented-item-height: var(--bb-segmented-item-sm-height);
        --bb-segmented-item-padding: var(--bb-segmented-item-sm-padding);
        --bb-segmented-item-font-size: var(--bb-segmented-item-sm-font-size);
    }

    &.block {
        display: flex;

        .segmented-item {
            flex: 1;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    }

    .segmented-item {
        padding: var(--bb-segmented-item-padding);
        cursor: pointer;
        border-radius: var(--bb-segmented-item-border-radius);
        line-height: var(--bb-segmented-item-height);
        font-size: var(--bb-segmented-item-font-size);
        position: relative;
        transition: color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
        white-space: nowrap;
        display: flex;
        align-items: center;
        justify-content: center;

        &.mask {
            background-color: var(--bb-segmented-item-selected-bg);
            box-shadow: 0 1px 2px 0 rgba(var(--bs-body-color-rgb),.03), 0 1px 6px -1px rgba(var(--bs-body-color-rgb),.02), 0 2px 4px 0 rgba(var(--bs-body-color-rgb),.02);
            pointer-events: none;
            position: absolute;
            left: 0;
            transition: transform .3s ease-in-out, width .3s ease-in-out;
            visibility: hidden;
        }

        &.selected {
            background-color: var(--bb-segmented-item-selected-bg);
            box-shadow: 0 1px 2px 0 rgba(var(--bs-body-color-rgb),.03), 0 1px 6px -1px rgba(var(--bs-body-color-rgb),.02), 0 2px 4px 0 rgba(var(--bs-body-color-rgb),.02);
        }

        &.disabled {
            color: rgba(var(--bs-body-color-rgb),.25);
            cursor: not-allowed;
        }

        &:hover:not(.selected):not(.disabled):not(.moving):after {
            background-color: var(--bb-segmented-item-hover-bg);
        }

        &:active:not(.selected):not(.disabled):not(.moving):after {
            background-color: var(--bb-segmented-item-active-bg);
        }

        &:after {
            content: "";
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            border-radius: inherit;
            transition: background-color 0.2s;
            pointer-events: none;
        }

        .segmented-item-icon + span {
            margin-left: var(--bb-segmented-text-margin-left);
        }

        .flex-column {
            --bb-segmented-text-margin-left: 0;
        }
    }
}

[data-bs-theme='dark'] .segmented {
    --bb-segmented-item-selected-bg: rgba(var(--bs-body-color-rgb),.12);
}
