@use "@tencentcloud/uikit-base-component-react/dist/styles/theme/util" as *;

.setting-item {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 14px 20px 11px;
  gap: 4px;

  @include theme() {
    color: get(text-color-primary);
  }

  &--disabled {
    @include theme() {
      color: get(text-color-disabled);
    }

    pointer-events: none;
  }

  &--editing {
    // Editing state styles
  }

  &--error {
    // Error state styles
  }

  &--switch {
    gap: 16px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  &--display {
    gap: 16px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  &--display-wrap {
    gap: 4px;
    flex-direction: column;
    align-items: flex-start;

    .setting-item__content-wrapper {
      width: 100%;
      justify-content: flex-start;
    }
  }

  &__label {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;

    @include theme() {
      color: get(text-color-primary);
    }
  }

  &__content-wrapper {
    display: flex;
    flex-direction: column;
  }

  // For switch type, content should be inline
  &--switch &__content-wrapper {
    flex-direction: row;
    align-items: center;
  }

  &__content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  &__value {
    flex: 1;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;

    @include theme() {
      color: get(text-color-secondary);
    }
  }

  &__placeholder {
    @include theme() {
      color: get(text-color-tertiary);
    }
  }

  &__edit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    flex-shrink: 0;

    @include theme() {
      color: get(text-color-secondary);

      &:hover {
        background-color: get(button-color-secondary-default);
      }

      &:active {
        background-color: get(button-color-secondary-active);
      }
    }
  }

  &__edit-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  &__input {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 8px;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;

    @include theme() {
      color: get(text-color-primary);
      background-color: get(bg-color-input);
      border: 1px solid get(stroke-color-module);
    }

    &:focus {
      @include theme() {
        border-color: get(text-color-link);
        box-shadow: 0 0 0 3px get(list-color-focused);
      }
    }

    &:disabled {
      @include theme() {
        background-color: get(bg-color-input);
        color: get(text-color-secondary);
      }

      cursor: not-allowed;
    }

    &--error {
      @include theme() {
        border-color: get(text-color-error);
      }

      &:focus {
        @include theme() {
          border-color: get(text-color-error);
          box-shadow: 0 0 0 3px get(toast-color-error);
        }
      }
    }
  }

  &__textarea {
    width: 100%;
    padding: 12px 16px;
    font-weight: 400;
    border-radius: 8px;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
    resize: none;
    font-size: 14px;
    min-height: 80px;
    line-height: 1.5;

    @include theme() {
      background-color: get(bg-color-input);
      color: get(text-color-primary);
      border: 1px solid get(stroke-color-module);
    }

    &:focus {
      @include theme() {
        border-color: get(text-color-link);
        box-shadow: 0 0 0 3px get(list-color-focused);
      }
    }

    &:disabled {
      @include theme() {
        background-color: get(bg-color-input);
        color: get(text-color-secondary);
      }

      cursor: not-allowed;
    }

    &--error {
      @include theme() {
        border-color: get(text-color-error);
      }

      &:focus {
        @include theme() {
          border-color: get(text-color-error);
          box-shadow: 0 0 0 3px get(toast-color-error);
        }
      }
    }
  }

  &__error {
    font-size: 12px;
    @include theme() {
      color: get(text-color-error);
    }
    margin-top: 4px;
    line-height: 1.4;
  }

  &__actions {
    display: flex;
    flex-direction: row;
    gap: 12px;
    justify-content: flex-end;
  }

  &__btn--cancel,
  &__btn--confirm {
    // Button styles are handled by the Button component
    // Additional custom styles can be added here if needed
  }

  // Switch styles
  &__switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 24px;
    cursor: pointer;
  }

  &__switch-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 24px;
    transition: 0.2s;

    @include theme(false) {
      background-color: get(switch-color-off);
    }

    &::before {
      content: "";
      position: absolute;
      height: 18px;
      width: 18px;
      left: 3px;
      bottom: 3px;
      @include theme() {
        background-color: get(switch-color-button);
      }
      border-radius: 50%;
      transition: 0.2s;
    }
  }

  &__switch-input {
    opacity: 0;
    width: 0;
    height: 0;

    &:checked + .setting-item__switch-slider {
      @include theme(false) {
        background-color: get(switch-color-on);
      }

      &::before {
        transform: translateX(16px);
      }
    }

    &:disabled + .setting-item__switch-slider {
      opacity: 0.5;
      cursor: not-allowed;
    }
  }
}
