// 分割线样式
.splitter-track-style() {
  background: #e5e5e5;
  .skin-dark & {
    background: #2a3253;
  }
}

// 分割线悬停样式
.splitter-track-hover-style() {
  background: fadeout(@blue-primary, 50%);
  .skin-dark & {
    background: fadeout(@dark-primary, 50%);
  }
  .skin-red & {
    background: fadeout(@red-primary, 50%);
  }
  .skin-green & {
    background: fadeout(@green-primary, 50%);
  }
  .skin-gray & {
    background: fadeout(@gray-primary, 50%);
  }
}

// 分割线装饰条样式
.splitter-dec-bar-style() {
  background: #999999;
  .skin-dark & {
    background: rgba(153, 153, 153, 0.6);
  }
}

// 分割线装饰条悬停样式
.splitter-dec-bar-hover-style() {
  background: @blue-primary;
  .skin-dark & {
    background: @dark-primary;
  }
  .skin-red & {
    background: @red-primary;
  }
  .skin-green & {
    background: @green-primary;
  }
  .skin-gray & {
    background: @gray-primary;
  }
}

// 展开/收起按钮样式
.layout-collapse-button-style() {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 36px;
  border: 1px solid rgba(66, 132, 229, 0.2);
  background: #edf2f5;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  opacity: 1;
  pointer-events: auto;

  &:hover {
    border-color: #4284e5;

    .collapse-icon {
      color: #4284e5;
      .arrow-icon {
        border-color: #4284e5;
      }
    }
  }

  .skin-dark & {
    border: 1px solid #5565aa;
    background: #4c557c;

    .collapse-icon {
      color: #999999;
    }

    &:hover {
      .collapse-icon {
        color: #5e76d7;
      }
    }
  }

  .collapse-icon {
    color: #999999;
    font-size: 10px;
    line-height: 1;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;

    .arrow-icon {
      display: inline-block;
      width: 0;
      height: 0;
      border-style: solid;
      transition: border-color 0.2s ease;

      &.arrow-left {
        border-width: 3px 5px 3px 0;
        border-color: transparent currentColor transparent transparent;
      }

      &.arrow-right {
        border-width: 3px 0 3px 5px;
        border-color: transparent transparent transparent currentColor;
      }

      &.arrow-down {
        border-width: 5px 3px 0 3px;
        border-color: currentColor transparent transparent transparent;
      }

      &.arrow-up {
        border-width: 0 3px 5px 3px;
        border-color: transparent transparent currentColor transparent;
      }
    }
  }
}

.zhny-layout-box {
  position: relative;
  width: 100%;
  height: 100%;
  .zhny-layout-left {
    height: 100%;
  }
  .zhny-layout-right {
    height: 100%;
  }
}

.zhny-layout-box-hidden-secondary {
  & > .splitter-layout {
    & > .layout-splitter,
    & > .layout-pane:not(.layout-pane-primary) {
      display: none;
    }
  }
}

.zhny-layout-box-without-gap {
  .splitter-layout > .layout-splitter {
    position: relative;
    width: 2px;
    &::after {
      width: 2px;
      height: 100%;
      position: absolute;
      top: 0;
      left: 50%;
      transform: translatex(-50%);
      content: '';
      cursor: col-resize;
      z-index: 1;
    }
  }
}

.zhny-layout-box-always-show-line {
  .splitter-layout {
    .layout-splitter {
      &::before {
        display: block;
      }
      &::after {
        display: block;
      }
    }
  }
}

.splitter-layout {
  position: absolute;
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: row;
  &.layout-changing {
    cursor: col-resize;
  }
  > .layout-pane {
    position: relative;
    flex: 0 0 auto;
    overflow: auto;
    &.layout-pane-primary {
      flex: 1 1 auto;
    }
  }
  .layout-splitter {
    width: 10px;
    position: relative;
    flex: 0 0 auto;
    cursor: col-resize;

    // 展开/收起按钮
    .layout-collapse-button {
      .layout-collapse-button-style();
      display: none;
    }

    &::before {
      .splitter-track-style();
      display: none;
      position: absolute;
      content: '';
      transition: background 0.2s ease;
      left: 50%;
      top: 0;
      transform: translateX(-50%);
      width: 2px;
      height: 100%;
    }

    &::after {
      .splitter-dec-bar-style();
      display: none;
      position: absolute;
      content: '';
      transition: background 0.2s ease;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      width: 2px;
      height: 30px;
    }

    &:hover {
      .layout-collapse-button {
        display: flex;
      }
      &::after {
        display: block;
        .splitter-dec-bar-hover-style();
      }
      &::before {
        display: block;
        .splitter-track-hover-style();
      }
    }
  }

  &-vertical {
    flex-direction: column;

    > .layout-splitter {
      width: 100%;
      height: 10px;
      cursor: row-resize;

      // 垂直布局下的按钮样式调整
      .layout-collapse-button {
        width: 36px;
        height: 10px;
      }

      &::before {
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 100%;
        height: 2px;
      }

      &::after {
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 30px;
        height: 2px;
      }
    }
  }
}

// 折叠功能样式
.zhny-layout-box-collapsible {
  .layout-splitter {
    // 为按钮预留空间
    &::after {
      display: none;
    }
  }
}

// 折叠状态：分割线隐藏并禁用拖动
.zhny-layout-box-collapsed {
  .splitter-layout > .layout-splitter {
    width: 5px;
    cursor: default !important;
    pointer-events: none;

    &::before,
    &::after {
      display: none;
    }

    &:hover {
      &::before,
      &::after {
        display: none;
      }
    }

    .layout-collapse-button {
      display: flex;
      transform: translate(calc(-50% + 3px), -50%);
    }
  }
  .splitter-layout-vertical > .layout-splitter {
    width: 100%;
    height: 5px;

    .layout-collapse-button {
      transform: translate(-50%, calc(-50% + 3px));
    }
  }

  .splitter-layout > .layout-pane:first-child {
    overflow-x: hidden;
  }
}
