@use 'variables' as *;
@use '../button/variables' as btn;

@include export-module('split-button-layout') {
  .e-split-btn-wrapper {
    display: inline-flex;
    white-space: nowrap;
    width: min-content;
    @if $skin-name == 'Material3' {
      border-radius: $split-bgr-btn-border-radius;
      box-shadow: btn.$btn-box-shadow;
    }

    .e-split-btn {
      border-bottom-right-radius: $drop-down-zero-border-radius;
      border-top-right-radius: $drop-down-zero-border-radius;
      text-transform: none;
      @if $skin-name == 'bootstrap4' {
        padding-left: $split-btn-icon-btn-padding;
        padding-right: $split-btn-icon-btn-padding;
      }
      @else if $skin-name == 'FluentUI' {
        padding: 3px 7px;
      }
      @if $skin-name == 'Material3' or $skin-name == 'Material3-dark' {
        padding: $split-nrml-btn-padding;
        line-height: $split-nrml-btn-line-height;
        box-shadow: none;
        z-index: 1;
      }
      @if $skin-name == 'bootstrap5.3' {
        border: 0;
      }
      @if $skin-name == 'bootstrap5' or $skin-name == 'fluent2' or $skin-name == 'tailwind3' or $skin-name == 'tailwind3-dark' or $skin-name == 'tailwind' or $skin-name == 'tailwind-dark' {
        padding: $split-btn-wrapper-btn-padding;
      }
      @else {
        padding-left: $split-btn-padding-left;
        padding-right: $split-btn-padding-right;
      }

      &:focus {
        outline-offset: $split-btn-focus-outline-offset;
      }

      &:hover {
        @if $skin-name != 'bootstrap4' and $skin-name != 'bootstrap5' and $skin-name != 'bootstrap5.3' and $skin-name != 'FluentUI' and $theme-name != 'FluentUI' {
          box-shadow: none;
        }
      }

      &:focus {
        @if $skin-name == 'tailwind' or $skin-name == 'bootstrap5' or $skin-name == 'bootstrap5.3' {
          box-shadow: $split-btn-active-box-shadow;
          z-index: $split-btn-zindex;
        }
        @else {
          box-shadow: none;
        }
      }

      &:focus-visible { // only for keybord
        @if $skin-name == 'Material3' {
          box-shadow: btn.$btn-keyboard-focus-box-shadow;
        }
      }

      &.e-btn:focus-visible { // only for keybord
        @if $skin-name == 'fluent2' {
          border-right-color: $grey-black !important; /* stylelint-disable-line declaration-no-important */
          box-shadow: btn.$btn-keyboard-focus-box-shadow;
        }
      }

      &:active {
        box-shadow: $split-btn-active-box-shadow;
        z-index: $split-btn-zindex;
      }

      &.e-top-icon-btn {
        padding-bottom: $split-btn-top-icon-padding-bottom;
        padding-top: $split-btn-top-icon-padding-top;
      }

      .e-btn-icon {
        font-size: $drop-dbtn-icon-font-size;
        margin-left: $drop-down-zero-padding-margin;
        padding-right: $split-btn-icon-padding-right;
        width: $split-auto-width;
        @if $skin-name == 'Material3' {
          border-radius: btn.$btn-border-radius;
        }
      }

      .e-icon-top {
        padding-bottom: $split-btn-icon-top-padding-bottom;
        padding-right: $drop-down-zero-padding-margin;
      }

      &.e-icon-btn {
        padding-left: $split-btn-icon-btn-padding;
        padding-right: $split-btn-icon-btn-padding;
        @if $skin-name == 'bootstrap5' {
          padding: 3.75px 11px;
        }
        .e-btn-icon {
          padding-right: $drop-down-zero-padding-margin;
        }
      }
    }

    .e-dropdown-btn {
      border-bottom-left-radius: $drop-down-zero-border-radius;
      border-top-left-radius: $drop-down-zero-border-radius;
      margin-left: $split-btn-sec-btn-margin-left;
      @if $skin-name == 'Material3' {
        box-shadow: none;
      }
      @if $skin-name == 'bootstrap4' or $skin-name == 'tailwind' {
        padding-left: $split-btn-icon-btn-padding;
        padding-right: $split-btn-icon-btn-padding;
      }
      @else if $skin-name == 'FluentUI' {
        padding: 4px;
      }
      @else {
        padding-left: $drop-down-btn-padding-left;
        padding-right: $drop-down-btn-padding-right;
      }

      &:focus,
      &:hover {
        @if $skin-name != 'bootstrap4' and $skin-name != 'bootstrap5' and $skin-name != 'bootstrap5.3' and $skin-name != 'FluentUI' and $theme-name != 'FluentUI' and $theme-name != 'Material3' {
          box-shadow: none;
        }
      }

      &:active {
        box-shadow: $split-btn-active-box-shadow;
        z-index: $split-btn-zindex;
      }

      &:disabled {
        &:focus,
        &:hover,
        &:active {
          z-index: 0;
        }
      }

      &:focus {
        outline-offset: $split-btn-focus-outline-offset;
      }

      &.e-btn:focus-visible { // only for keybord
        @if $skin-name == 'fluent2' {
          margin-left: $drop-down-zero-padding-margin !important; /* stylelint-disable-line declaration-no-important */
          box-shadow: btn.$btn-keyboard-focus-box-shadow;
        }
      }
    }

    .e-btn {
      @if $skin-name != 'bootstrap4' and $skin-name != 'tailwind3' and $skin-name != 'bootstrap5' and $skin-name != 'bootstrap5.3' and $skin-name != 'FluentUI' and $theme-name != 'fluent2' and $theme-name != 'Material3' {
        box-shadow: none;
      }

      &:hover {
        @if $skin-name != 'bootstrap4' and $skin-name != 'bootstrap5' and $skin-name != 'bootstrap5.3' and $skin-name != 'FluentUI' and $theme-name != 'fluent2' {
          box-shadow: none;
        }
      }

      &:focus {
        @if $skin-name == 'tailwind' or $skin-name == 'tailwind3' or $skin-name == 'bootstrap5' or $skin-name == 'bootstrap5.3' {
          box-shadow: $split-btn-active-box-shadow;
          z-index: $split-btn-zindex;
        }
        @else {
          box-shadow: none;
        }
      }

      &:focus-visible { // only for keybord
        @if $skin-name == 'Material3' {
          box-shadow: btn.$btn-keyboard-focus-box-shadow;
        }
      }

      &:active {
        box-shadow: $split-btn-active-box-shadow;
        @if $skin-name == 'tailwind' or $skin-name == 'bootstrap5' or $skin-name == 'bootstrap5.3' {
          z-index: $split-btn-zindex;
        }
      }

      &:disabled {
        box-shadow: none;
        @if $skin-name == 'FluentUI' or $theme-name == 'FluentUI' {
          outline: 0;
          outline-offset: 0;
        }
      }

      &.e-inherit {
        &:focus,
        &:active {
          box-shadow: none;
        }
      }
    }

    &.e-rtl {
      .e-split-btn {
        border-bottom-left-radius: $drop-down-zero-border-radius;
        border-bottom-right-radius: $split-btn-border-radius;
        border-top-left-radius: $drop-down-zero-border-radius;
        border-top-right-radius: $split-btn-border-radius;
        margin-left: $split-btn-sec-btn-margin-left;
        @if $skin-name == 'bootstrap4' or $skin-name == 'FluentUI' {
          padding-left: $split-btn-icon-btn-padding;
          padding-right: $split-btn-icon-btn-padding;
        }
        @else {
          padding-left: $split-rtl-btn-padding-left;
          padding-right: $split-rtl-btn-padding-right;
        }
        @if $skin-name == 'Material3' {
          border-radius: $split-bgr-btn-border-radius;
        }

        .e-btn-icon {
          margin-right: $drop-down-zero-padding-margin;
          padding-left: $split-rtl-btn-icon-padding-left;
          padding-right: $drop-down-zero-padding-margin;
          @if $skin-name == 'Material3' {
            border-radius: btn.$btn-border-radius;
          }
        }

        .e-icon-top {
          padding-left: $drop-down-zero-padding-margin;
        }

        &.e-icon-btn {
          padding-left: $split-btn-icon-btn-padding;
          padding-right: $split-btn-icon-btn-padding;

          .e-btn-icon {
            padding-left: $drop-down-zero-padding-margin;
          }
        }
      }

      .e-dropdown-btn {
        border-bottom-left-radius: $split-btn-border-radius;
        border-bottom-right-radius: $drop-down-zero-border-radius;
        border-top-left-radius: $split-btn-border-radius;
        border-top-right-radius: $drop-down-zero-border-radius;
        margin-left: $drop-down-zero-padding-margin;
        @if $skin-name == 'Material3' {
          border-radius: $split-bgr-btn-border-radius;
          box-shadow: none;
        }
      }
    }

    &.e-vertical {
      display: inline-block;

      .e-split-btn,
      .e-dropdown-btn {
        display: block;
        width: $split-full-width;
      }

      .e-split-btn {
        border-bottom-left-radius: $drop-down-zero-border-radius;
        border-top-right-radius: $split-btn-border-radius;
        line-height: $split-btn-line-height;
        @if $skin-name == 'bootstrap4'or $skin-name == 'tailwind' {
          padding-bottom: $split-btn-icon-btn-padding;
          padding-right: $split-btn-icon-btn-padding;
        }
        @else {
          padding-bottom: $split-btn-vertical-padding-bottom;
          padding-right: $split-btn-vertical-padding-right;
        }
        @if $skin-name == 'Material3' {
          border-radius: $split-bgr-btn-border-radius;
          box-shadow: none;
        }

        .e-icon-top {
          padding-bottom: $split-btn-vertical-icon-top-padding;
        }
      }

      .e-dropdown-btn {
        border-bottom-left-radius: $split-btn-border-radius;
        border-top-right-radius: $drop-down-zero-border-radius;
        line-height: $split-btn-vertical-secondary-icon-line-height;
        margin-left: $drop-down-zero-padding-margin;
        margin-top: $split-btn-sec-btn-margin-left;
        @if $skin-name == 'bootstrap4' {
          padding-bottom: $split-btn-icon-btn-padding;
          padding-top: $split-btn-icon-btn-padding;
        }
        @else {
          padding-bottom: $drop-down-btn-vertical-padding-bottom;
          padding-top: $drop-down-btn-vertical-padding-top;
        }
        @if $skin-name == 'Material3' {
          border-radius: $split-bgr-btn-border-radius;
          box-shadow: none;
        }

        .e-icon-bottom {
          padding-top: $drop-down-zero-padding-margin;
        }
      }

      &.e-rtl {
        .e-split-btn {
          border-bottom-right-radius: $drop-down-zero-border-radius;
          border-top-left-radius: $split-btn-border-radius;
          margin-left: $drop-down-zero-padding-margin;
        }

        .e-dropdown-btn {
          border-bottom-right-radius: $split-btn-border-radius;
          border-top-left-radius: $drop-down-zero-border-radius;
        }
      }
    }
  }
}
