@import '../../../../../style/variables.less';

.pro-form-list-block-title {
  height: 14px;
  margin: @zaui-space-size-xs 0;
  padding-left: @zaui-space-size-sm;
  font-weight: 600;
  line-height: 14px;
  border-left: 4px solid @zaui-brand;
}

.pro-form-list {
  display: flex;
  padding-bottom: 0;
  .drag-icon {
    font-size: 18px;
    color: #949599;
  }

  &:nth-child(1) {
    flex: 1;
  }

  .pro-form-list-action {
    padding-bottom: var(--zaui-height-size-md, 16px);

    & > .@{ant-prefix}-space-item:first-child > .@{ant-prefix}-btn-link {
      margin-left: @zaui-space-size-sm;
    }

    & .@{ant-prefix}-btn {
      transition: none;
    }
  }

  .pro-form-list-drag-handle {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    height: 32px;
    margin-bottom: calc(var(--zaui-space-size-md; 16px) * var(--zaui-size; 1));
    padding: 0;
    padding-right: @zaui-space-size-sm;
    border: none;

    .pro-icon {
      cursor: move;
    }
  }

  > .pro-form-list-fields {
    flex: 1;
    min-width: 0;
  }
}

.pro-form-list {
  .@{ant-prefix}-tabs-nav {
    margin-bottom: 0 !important;
  }
  &.@{ant-prefix}-tabs-card {
    .@{ant-prefix}-tabs-tab {
      padding: 0 !important;
      margin-right: 4px !important;
      min-width: 70px;
    }
  }

  .single-delete {
    width: 14px !important;
    height: 14px !important;
    color: @zaui-placeholder;

    &:hover {
      color: @zaui-aide-text;
    }
  }
}

.pro-form-list-line {
  padding: var(--zaui-height-size-md, 16px);
  padding-bottom: 0;

  &:hover {
    background: rgba(0, 0, 0, 0.018);
  }
}

.pro-form-list-action-top > .pro-form-list-action {
  align-self: flex-start;
}

.pro-form-list-action-center > .pro-form-list-action {
  align-self: center;
}

.pro-form-list-action-bottom > .pro-form-list-action {
  align-self: flex-end;
}

.pro-form-list-toolbar,
.pro-form-list-action {
  .@{ant-prefix}-btn-link {
    padding: @zaui-space-size-xs 0;
  }

  .@{ant-prefix}-btn-text:hover {
    background: transparent;
  }
  .pro-form-list-tool-btn {
    .@{ant-prefix}-btn-icon {
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }

  .pro-form-list-tool-btn-less {
    &:hover {
      background: transparent !important;
    }
  }
}

.pro-form-list-tabs {
  &.@{ant-prefix}-tabs > .@{ant-prefix}-tabs-nav {
    margin-bottom: 0;
    padding-top: 8px;

    &::before {
      display: none;
    }

    .@{ant-prefix}-tabs-nav-wrap {
      min-width: 0;
      overflow-x: clip;
      overflow-y: visible;
    }

    .@{ant-prefix}-tabs-nav-list {
      overflow: visible;
      align-items: center;
      gap: 12px;
    }
  }

  &.@{ant-prefix}-tabs-card > .@{ant-prefix}-tabs-nav {
    .@{ant-prefix}-tabs-tab {
      height: 32px;
      // 覆盖全局 card Tabs 的强制内外边距，间距统一交给 nav-list。
      padding: 0 !important;
      margin: 0 !important;
      background: transparent;
      border: 0;

      &.@{ant-prefix}-tabs-tab-active .pro-form-list-tabs-label {
        color: var(--pro-form-list-tabs-primary);
        background: var(--pro-form-list-tabs-primary-bg);
        border-color: var(--pro-form-list-tabs-primary);
      }
    }

    .@{ant-prefix}-tabs-tab-btn {
      color: inherit;
      text-shadow: none;
    }

    .@{ant-prefix}-tabs-nav-add {
      width: auto;
      min-width: 32px;
      height: 32px;
      padding: 0 12px;
      margin: 0;
      color: var(--pro-form-list-tabs-muted);
      background: var(--pro-form-list-tabs-bg);
      border: 1px dashed var(--pro-form-list-tabs-border);
      border-radius: 16px;

      &:focus:not(:hover) {
        color: var(--pro-form-list-tabs-muted);
        border-color: var(--pro-form-list-tabs-border);
      }

      &:hover {
        color: var(--pro-form-list-tabs-primary-hover);
        border-color: var(--pro-form-list-tabs-primary-hover);
      }
    }
  }

  .pro-form-list-tabs-label {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    padding: 0 12px;
    color: var(--pro-form-list-tabs-text);
    background: var(--pro-form-list-tabs-bg);
    border: 1px solid var(--pro-form-list-tabs-border);
    border-radius: 16px;

    &:hover {
      color: var(--pro-form-list-tabs-primary-hover);
      border-color: var(--pro-form-list-tabs-primary-hover);
    }

    &[data-drag-over='true'] {
      border-color: var(--pro-form-list-tabs-primary-hover);
    }
  }

  .pro-form-list-tabs-title {
    white-space: nowrap;
  }

  .pro-form-list-tabs-error-badge {
    // 角标以整个胶囊为定位容器，随拖动一起移动。
    position: static;
    display: inline-flex;
    color: inherit;

    .@{ant-prefix}-badge-count {
      top: 4px;
      right: 4px;
      z-index: 2;
      pointer-events: none;
      transform: translate(50%, -50%);
      color: var(--pro-form-list-tabs-solid-text);
      background: var(--pro-form-list-tabs-error);
      box-shadow: 0 0 0 2px var(--pro-form-list-tabs-bg);
      transition: none;
      animation: none;

      .@{ant-prefix}-scroll-number-only-unit {
        transition: none;
      }
    }
  }

  .pro-form-list-tabs-title-content {
    display: inline-flex;
    gap: 4px;
    align-items: center;
  }

  .pro-form-list-tabs-add {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    white-space: nowrap;
    .pro-form-list-tabs-add-label {
      font-size: 14px;
    }
  }

  .pro-form-list-tabs-content {
    padding: 12px 0 0;
    border: 0;
  }
}

.pro-form-list-tabs,
.pro-form-list-tabs-dropdown {
  .pro-form-list-tabs-drag-handle {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    color: var(--pro-form-list-tabs-muted);
    touch-action: none;

    .pro-icon {
      cursor: move;
    }
  }

  .pro-form-list-action {
    padding-bottom: 0;

    [data-form-list-action] {
      min-width: 20px;
      height: 20px;
      padding: 0;
      color: inherit;
    }

    [data-form-list-action='delete'] {
      color: var(--pro-form-list-tabs-close);
      border-radius: 4px;
      transition: color 0.2s;

      &:hover {
        color: var(--pro-form-list-tabs-muted);
        background: transparent;
      }
    }
  }
}

.pro-form-list-tabs-dropdown {
  min-width: 180px;
  max-width: calc(100vw - 32px);

  .@{ant-prefix}-tabs-dropdown-menu-item {
    &:hover,
    &-active,
    &-selected {
      background: transparent;
    }
  }

  .@{ant-prefix}-tabs-dropdown-menu-item > span {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .pro-form-list-tabs-label {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    min-width: 0;
  }

  .pro-form-list-tabs-error-badge {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: inherit;
  }

  .pro-form-list-tabs-title-content {
    display: contents;
  }

  .pro-form-list-tabs-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .pro-form-list-action {
    order: 2;
    flex-shrink: 0;
    margin-inline-start: auto;
  }

  .@{ant-prefix}-badge-count {
    position: static;
    order: 1;
    flex-shrink: 0;
    transform: none;
  }
}

.pro-form-list-tabs-drag-overlay {
  pointer-events: none;

  .pro-form-list-tabs-label {
    width: max-content;
    min-width: 100%;
  }

  &[data-active='true'] .pro-form-list-tabs-label {
    color: var(--pro-form-list-tabs-primary);
    background: var(--pro-form-list-tabs-primary-bg);
    border-color: var(--pro-form-list-tabs-primary);
  }
}

.pro-form-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  .pro-form-list-empty-img {
    width: 80px;
    height: 80px;
  }

  .pro-form-list-empty-content {
    display: flex;
    justify-content: center;
    margin-top: var(--zaui-space-size-md, 16px);
    color: @zaui-aide-text;

    .@{ant-prefix}-btn-link {
      padding: 0;
    }
  }
}

.pro-form-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  .pro-form-list-empty-img {
    width: 80px;
    height: 80px;
  }

  .pro-form-list-empty-content {
    display: flex;
    justify-content: center;
    margin-top: var(--zaui-space-size-md, 16px);
    color: @zaui-aide-text;

    .@{ant-prefix}-btn-link {
      padding: 0;
    }
  }
}

// 左侧标题布局样式
.pro-form-list-mode-block.pro-form-list-title-left {
  .@{ant-prefix}-collapse-title {
    display: none;
  }
  .pro-form-list-left-title-wrapper {
    display: flex;
    gap: 16px;
    align-items: flex-start;

    .pro-form-list-left-title {
      flex: 0 0 80px;
      font-weight: 600;
      font-size: 14px;
      line-height: 1.4;
      color: @zaui-text;
      padding-top: 8px;
    }

    .pro-form-list-left-content {
      flex: 1;
      min-width: 0;
    }
  }

  .pro-form-list-left-action-right {
    .@{ant-prefix}-collapse-extra {
      margin-inline-start: auto;
    }
  }

  // 移动端响应式
  @media (max-width: 768px) {
    .pro-form-list-left-title-wrapper {
      flex-direction: column;
      gap: 8px;

      .pro-form-list-left-title {
        flex: none;
        width: 100%;
        padding-top: 0;
        margin-bottom: 8px;
      }
    }
  }
}
