@use "../../assets/mixins.scss" as *;

.pl-btn-group {
  --pl-btn-group-height: 40px;
  box-sizing: border-box;
  position: relative;
  font-family: var(--control-font-family);

  label {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    font-size: var(--font-size-base);
    line-height: 20px;
  }

  &__helper {
    @include field-helper();
  }

  &__error {
    @include field-error();
  }

  .inner-border {
    height: var(--pl-btn-group-height);
    min-height: var(--pl-btn-group-height);

    &::after {
      border: 1px solid var(--color-border-default);
      border-radius: 6px;
    }
  }

  &__container {
    flex: 1;
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: content-box;
    border-radius: 6px;
    font-weight: 500;
    font-size: 10px;
    text-align: center;
    user-select: none;
  }

  &__option {
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 0 12px;
    align-self: stretch;
    cursor: pointer;
    outline: none;
    text-transform: capitalize;
    color: var(--btn-switcher-option-color);
    white-space: nowrap;

    &:hover:not(.active) {
      background-color: var(--btn-sec-hover-grey);
    }

    &:first-child {
      border-top-left-radius: 6px;
      border-bottom-left-radius: 6px;
    }

    &:last-child {
      border-top-right-radius: 6px;
      border-bottom-right-radius: 6px;
    }

    &:focus-visible {
      @include border-fix {
        border: 2px solid var(--border-color-focus);
        border-radius: inherit;
        z-index: 1;
      }
    }

    &:not(.active) + .pl-btn-group__option:not(.active) {
      &::before {
        content: "";
        position: absolute;
        width: 1px;
        height: 24px;
        left: -1px;
        top: 50%;
        transform: translateY(-50%);
        background-color: var(--color-border-default);
      }
    }

    &.active {
      background: var(--btn-switcher-bg);
      border: var(--btn-switcher-active-option-border);
      box-shadow: var(--btn-group-shape-shadow);
      color: var(--btn-switcher-active-option-color);
      border-radius: 6px;
      z-index: 1;
      padding: 0 11px;
    }
  }

  &.compact {
    --pl-btn-group-height: 32px;
  }

  &.disabled {
    --color-border-default: var(--color-dis-01);
    --btn-switcher-bg: var(--color-dis-01);
    --btn-switcher-option-color: var(--color-dis-01);
    --btn-switcher-active-option-color: var(--color-dis-00);
    --btn-switcher-active-option-border: 0px;
    pointer-events: none;
    // @TODO
    tab-index: unset !important;
  }
}
